Skip to content

Commit a27b4a6

Browse files
committed
[Core] get_tensor_datatype where initializers don't have ValueInfo
1 parent ac766dc commit a27b4a6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/qonnx/core/modelwrapper.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,11 @@ def get_tensor_datatype(self, tensor_name):
198198
# TensorProto.INT64 : "INT64",
199199
}
200200
tensor_vi = self.get_tensor_valueinfo(tensor_name)
201-
onnx_dtype = tensor_vi.type.tensor_type.elem_type
201+
if tensor_vi is None:
202+
# some initialized tensors don't get ValueInfo even after shape inference
203+
_, onnx_dtype = self.get_initializer(tensor_name, return_dtype=True)
204+
else:
205+
onnx_dtype = tensor_vi.type.tensor_type.elem_type
202206
if onnx_dtype in onnx_dtype_to_qonnx_dtype.keys():
203207
return DataType[onnx_dtype_to_qonnx_dtype[onnx_dtype]]
204208
else:

0 commit comments

Comments
 (0)