Lednik7 / CLIP-ONNX

It is a simple library to speed up CLIP inference up to 3x (K80 GPU)
MIT License
193 stars 25 forks source link

Replace the operator of "torch.einsum" #4

Open zhangnju opened 2 years ago

zhangnju commented 2 years ago

q, k, v = (torch.einsum("tbh, oh -> tbo", x, self.attn.in_proj_weight) + self.attn.in_proj_bias).contiguous().chunk( 3, dim=-1)

@Lednik7 Thanks for your great work on Clip-ONNX. for the pytorch operator of "torch.einsum" , if we don't want to use this operator , do you have other codes to replace this operator? this operator is not friendly to some Inference engine, like NV TensorRT, so if you have other codes to replace einsum, that will be better

Lednik7 commented 2 years ago

Hi @zhangnju Thank you for using my development and looking for bugs. In the next free time I will try to fix it. I'll let you know when it's ready

Lednik7 commented 2 years ago

I updated the library, now everything works?

aaronrmm commented 3 months ago

I am able to run your model with your onnx code, but I similarly have a problem converting to tensorrt. I tried with tensorrt versions 8.5.2.2, and 8.6.1, and the error for both is at the aten_unsqueeze op:

[06/17/2024-14:43:59] [E] [TRT] ModelImporter.cpp:726: While parsing node number 0 [aten_unsqueeze -> "unsqueeze"]:
[06/17/2024-14:43:59] [E] [TRT] ModelImporter.cpp:727: --- Begin node ---
[06/17/2024-14:43:59] [E] [TRT] ModelImporter.cpp:728: input: "l_x_"
output: "unsqueeze"
name: "aten_unsqueeze_1"
op_type: "aten_unsqueeze"
attribute {
  name: "dim"
  i: 2
  type: INT
}
doc_string: ""
domain: "pkg.onnxscript.torch_lib"

[06/17/2024-14:43:59] [E] [TRT] ModelImporter.cpp:729: --- End node ---
[06/17/2024-14:43:59] [E] [TRT] ModelImporter.cpp:731: ERROR: builtin_op_importers.cpp:5427 In function importFallbackPluginImporter:
[8] Assertion failed: creator && "Plugin not found, are the plugin name, version, and namespace correct?"
[06/17/2024-14:43:59] [E] Failed to parse onnx file
[06/17/2024-14:43:59] [E] Parsing model failed
[06/17/2024-14:43:59] [E] Failed to create engine from model or file.
[06/17/2024-14:43:59] [E] Engine set up failed