# InvalidArgument: \[ONNXRuntimeError\] : 2 : INVALID\_ARGUMENT : Unexpected input data type. Actual: (tensor(int32)) , expected: (tensor(int64)

**URL:** <https://discuss.huggingface.co/t/invalidargument-onnxruntimeerror-2-invalid-argument-unexpected-input-data-type-actual-tensor-int32-expected-tensor-int64/19206>\
**Category:** 🤗Optimum\
**Created:** [June 15, 2022, 4:50pm UTC](https://discuss.huggingface.co/t/invalidargument-onnxruntimeerror-2-invalid-argument-unexpected-input-data-type-actual-tensor-int32-expected-tensor-int64/19206 "2022-06-15T16:50:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Talha](https://avatars.discourse-cdn.com/v4/letter/t/a5b964/32.png) [@Talha](https://discuss.huggingface.co/u/Talha)\
**Post date:** [June 15, 2022, 4:50pm UTC](https://discuss.huggingface.co/t/invalidargument-onnxruntimeerror-2-invalid-argument-unexpected-input-data-type-actual-tensor-int32-expected-tensor-int64/19206/1 "2022-06-15T16:50:15Z")

</div>

I have trained and saved a model in lunx/ubuntu. Now when i tried to run it on windows, it throw following error

```auto
InvalidArgument Traceback (most recent call last)
Input In [19], in <cell line: 12>()
      9 return tokenizer(ex["sentence"])
     11 tokenized_ds = ds.map(partial(preprocess_fn, tokenizer=quantizer.tokenizer))
---> 12 ort_outputs = ort_model.evaluation_loop(tokenized_ds)
     13 # Extract logits!
     14 pred=ort_outputs.predictions

File e:\fiverr\upwork\venv\lib\site-packages\optimum\onnxruntime\model.py:98, in ORTModel.evaluation_loop(self, dataset)
     96 labels = None
     97 onnx_inputs = {key: np.array([inputs[key]]) for key in self.onnx_config.inputs if key in inputs}
---> 98 preds = session.run(self.onnx_named_outputs, onnx_inputs)
     99 if len(preds) == 1:
    100 preds = preds[0]

File e:\fiverr\upwork\venv\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py:192, in Session.run(self, output_names, input_feed, run_options)
    190 output_names = [output.name for output in self._outputs_meta]
    191 try:
--> 192 return self._sess.run(output_names, input_feed, run_options)
    193 except C.EPFail as err:
    194 if self._enable_fallback:

InvalidArgument: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Unexpected input data type. Actual: (tensor(int32)) , expected: (tensor(int64))

```

Code is as follow and working on linux

```auto
# %%time
from time import time
start=time()

# Create a dataset or load one from the Hub
ds = Dataset.from_dict({"sentence": list(val_df.tweet)})
# Tokenize the inputs
def preprocess_fn(ex, tokenizer):
    return tokenizer(ex["sentence"])

tokenized_ds = ds.map(partial(preprocess_fn, tokenizer=quantizer.tokenizer))
ort_outputs = ort_model.evaluation_loop(tokenized_ds)
# Extract logits!
pred=ort_outputs.predictions
end=time()
total_time=end-start
print(total_time)

```

---

<div class="post-metadata">

**Author:** ![echarlaix](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/echarlaix/32/21754_2.png) [@echarlaix](https://discuss.huggingface.co/u/echarlaix)\
**Post date:** [June 29, 2022, 12:17pm UTC](https://discuss.huggingface.co/t/invalidargument-onnxruntimeerror-2-invalid-argument-unexpected-input-data-type-actual-tensor-int32-expected-tensor-int64/19206/2 "2022-06-29T12:17:39Z")

</div>

Hi @Talha,

Did you check the data type of the array’s elements of `onnx_inputs` ?  
Can you try :

```python
onnx_inputs = {key: np.array([inputs[key]], dtype=np.int64) for key in self.onnx_config.inputs if key in inputs}

```

Also [`ORTModel`](https://github.com/huggingface/optimum/blob/main/optimum/onnxruntime/model.py#L34) was a class added for users to be able to obtain the evaluation results in order to compare their original model with the resulting optimized / quantized model, and was meant to be temporary. This class is now depreciated and we encourage users to use our new classes [`ORTModelForXxx`](https://huggingface.co/docs/optimum/onnxruntime/modeling_ort#switching-from-transformers-to-optimum-inference).

---

<div class="post-metadata">

**Author:** ![pikap](https://avatars.discourse-cdn.com/v4/letter/p/d9b06d/32.png) [@pikap](https://discuss.huggingface.co/u/pikap)\
**Post date:** [July 9, 2023, 8:03am UTC](https://discuss.huggingface.co/t/invalidargument-onnxruntimeerror-2-invalid-argument-unexpected-input-data-type-actual-tensor-int32-expected-tensor-int64/19206/3 "2023-07-09T08:03:53Z")

</div>

solution here: [https://blog.csdn.net/pipisorry/article/details/131519708#t18](https://blog.csdn.net/pipisorry/article/details/131519708#t18)
