Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tensor dtype error #72

Open
sreedattaSanjay opened this issue Mar 7, 2024 · 2 comments
Open

Tensor dtype error #72

sreedattaSanjay opened this issue Mar 7, 2024 · 2 comments
Labels
question Further information is requested

Comments

@sreedattaSanjay
Copy link

Hello
I'm trying to use the bert_mha_layernorm_fuse() function in the examples.py

The problem is when I'm trying to infer the fused model I'm getting a dtype mismatch error
After a little debugging, I found out that in Tensor() class if the instance of tensor is str
you are automatically assigning dtype as numpy.float32

from .node import Node
if isinstance(t, str):
self.name = t
self.proto = None
self.shape = []
self.numpy = None
self.type = DYNAMIC_TENSOR if t != '' else STATIC_TENSOR
self.dtype = numpy.float32

Due to this output tensors that are Dynamic and do not have any value are loaded as float32 tensors

In my case, the output tensor dtype should be int but it is float32

onnxruntime.capi.onnxruntime_pybind11_state.Fail: [ONNXRuntimeError] : 1 : FAIL : Load model from bertsquad_mha_layernorm.onnx failed:Type Error: Type (tensor(int32)) of output arg (bert/encoder/Shape:0) of node (bert/encoder/Shape) does not match expected type (tensor(int64)).

Here is the original bertsquad-12 model
orig_model_bert

And here is the fused model
bert_MHA_Layernorm_model

Can you please let me know how to resolve this issue? Is there a function that lets us save model with proper datatypes

@sreedattaSanjay
Copy link
Author

Is there any script in your local testing that lets us infer the models you have created in the examples.py?
If yes can you please let us use it
Thank you

@ThanatosShinji
Copy link
Owner

The link from the README is out of date, you can use this link to download the BERT model

@ThanatosShinji ThanatosShinji added the question Further information is requested label Mar 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants