microsoft / microsoft/onnxruntime
`AddCastNode` in `insert_cast_transformer.cc` sets invalid dtype `-1`
- Dominant language
- C++
- Stars
- 21.9k
- Forks
- 4.2k
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 184
Description
### Describe the issue
ORT executing the fp16 model
```
<
ir_version: 3,
opset_import: ["" : 1]
>
node_graph (float16[2,3] input0) => (float16[2,3] output0) {
output0 = RandomNormalLike (input0)
}
```
with CPU will produce an error
`onnxruntime.capi.onnxruntime_pybind11_state.InvalidGraph: [ONNXRuntimeError] : 10 : INVALID_GRAPH : This is an invalid model. In Node, ("InsertedCast_input0", Cast, "", -1) : ("input0": tensor(float16),) -> ("InsertedCast_input0": tensor(float),) , Error Mismatched attribute type in 'InsertedCast_input0 : to'`
It appears `to_type` was somehow set to `-1` in https://github.com/microsoft/onnxruntime/blob/3c2d52a995954cd9ce24b2831060c4326ab18e1c/onnxruntime/core/optimizer/insert_cast_transformer.cc#L28C23-L47
### To reproduce
As above
### Urgency
_No response_
### Platform
Linux
### OS Version
Ubuntu 22.04
### ONNX Runtime Installation
Released Package
### ONNX Runtime Version or Commit ID
1.15.0
### ONNX Runtime API
Python
### Architecture
X64
### Execution Provider
Default CPU
### Execution Provider Library Version
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.