I tried changed code but the problem persists.
This is the conversion code that I use.
from hailo_sdk_client import ClientRunner
chosen_hw_arch = 'hailo8'
onnx_model_name = 'TrainedModel6'
onnx_path = 'my_env/TrainedModel6.onnx'
runner = ClientRunner(hw_arch=chosen_hw_arch)
hn, npz = runner.translate_onnx_model(
onnx_path,
onnx_model_name,
start_node_names=['input'],
end_node_names=['output'],
net_input_shapes={'input': [1, 1, 200]}
)
However, I still get this error
[info] Translation started on ONNX model TrainedModel6
[info] Restored ONNX model TrainedModel6 (completion time: 00:00:00.01)
[info] Extracted ONNXRuntime meta-data for Hailo model (completion time: 00:00:00.01)
[info] Simplified ONNX model for a parsing retry attempt (completion time: 00:00:00.02)
---------------------------------------------------------------------------
UnsupportedModelError Traceback (most recent call last)
File ~/my_env/lib/python3.10/site-packages/hailo_sdk_client/sdk_backend/parser/parser.py:220, in Parser.translate_onnx_model(self, model, net_name, start_node_names, end_node_names, net_input_shapes, augmented_path, disable_shape_inference, disable_rt_metadata_extraction, net_input_format, **kwargs)
219 try:
--> 220 parsing_results = self._parse_onnx_model_to_hn(
221 onnx_model=onnx_model,
222 net_name=valid_net_name,
223 start_node_names=start_node_names,
224 end_node_names=end_node_names,
225 net_input_shapes=net_input_shapes,
226 disable_shape_inference=disable_shape_inference,
227 net_input_format=net_input_format,
228 )
230 except Exception as e:
File ~/my_env/lib/python3.10/site-packages/hailo_sdk_client/sdk_backend/parser/parser.py:300, in Parser._parse_onnx_model_to_hn(self, onnx_model, net_name, start_node_names, end_node_names, net_input_shapes, disable_shape_inference, net_input_format, **kwargs)
298 self._logger.warning(f"ONNX shape inference failed: {e!s}")
--> 300 return self.parse_model_to_hn(
301 onnx_model,
302 None,
303 net_name,
304 start_node_names,
305 end_node_names,
306 nn_framework=NNFramework.ONNX,
307 output_shapes=output_shapes,
308 net_input_format=net_input_format,
309 **kwargs,
310 )
File ~/my_env/lib/python3.10/site-packages/hailo_sdk_client/sdk_backend/parser/parser.py:351, in Parser.parse_model_to_hn(self, model, values, net_name, start_node_names, end_node_names, nn_framework, output_shapes, net_input_format, rename_layers_by_blocks)
349 raise BackendRuntimeException(f"Unsupported NN framework {nn_framework}")
--> 351 fuser = HailoNNFuser(converter.convert_model(), net_name, converter.end_node_names)
352 hailo_nn = fuser.convert_model()
File ~/my_env/lib/python3.10/site-packages/hailo_sdk_client/model_translator/translator.py:88, in HailoNNConverter.convert_model(self)
87 self._handle_tokens_matmul()
---> 88 self._calculate_shapes(validate_shapes=False)
89 self._add_output_layers()
File ~/my_env/lib/python3.10/site-packages/hailo_sdk_client/model_translator/onnx_translator/onnx_translator.py:194, in ONNXConverter._calculate_shapes(self, validate_shapes)
193 self._update_meta_graph()
--> 194 self._layers_graph.calculate_shapes(meta_edges_graph=self._meta_graph, validate_shapes=validate_shapes)
File ~/my_env/lib/python3.10/site-packages/hailo_sdk_common/hailo_nn/hailo_nn.py:755, in HailoNN.calculate_shapes(self, meta_edges_graph, validate_shapes)
753 layer.output_copies = self.get_number_of_successors(layer)
--> 755 layer.update_output_shapes(hn_stage=self.net_params.stage, validate_shapes=validate_shapes)
File ~/my_env/lib/python3.10/site-packages/hailo_sdk_common/hailo_nn/hn_layers/layer.py:458, in Layer.update_output_shapes(self, **kwargs)
457 output_shape = self._calc_output_shape()
--> 458 self.output_shapes = [output_shape[:] for _ in range(self.output_copies)]
File ~/my_env/lib/python3.10/site-packages/hailo_sdk_common/hailo_nn/hn_layers/layer.py:487, in Layer.output_shapes(self, output_shapes)
486 for shape in output_shapes:
--> 487 self._append_output_shape(shape)
File ~/my_env/lib/python3.10/site-packages/hailo_sdk_common/hailo_nn/hn_layers/layer.py:461, in Layer._append_output_shape(self, output_shape)
460 def _append_output_shape(self, output_shape):
--> 461 self._check_valid_shape(output_shape)
462 self.append_output_shape(output_shape)
File ~/my_env/lib/python3.10/site-packages/hailo_sdk_common/hailo_nn/hn_layers/layer.py:454, in Layer._check_valid_shape(self, shape)
453 if any(dim == 0 for dim in shape):
--> 454 raise UnsupportedModelError(f"Unexpected zero dimension in shape {shape} at {self.full_name_msg}")
UnsupportedModelError: Unexpected zero dimension in shape [-1, 4, 0, 64] at base conv layer base_conv1 (translated from /conv/Conv)
During handling of the above exception, another exception occurred:
UnsupportedModelError Traceback (most recent call last)
Cell In[4], line 2
1 runner = ClientRunner(hw_arch=chosen_hw_arch)
----> 2 hn, npz = runner.translate_onnx_model(
3 onnx_path,
4 onnx_model_name,
5 start_node_names=['input'],
6 end_node_names=['output'],
7 net_input_shapes={'input': [1, 1, 200]}
8 )
File ~/my_env/lib/python3.10/site-packages/hailo_sdk_common/states/states.py:16, in allowed_states.<locals>.wrap.<locals>.wrapped_func(self, *args, **kwargs)
12 if self._state not in states:
13 raise InvalidStateException(
14 f"The execution of {func.__name__} is not available under the state: {self._state.value}",
15 )
---> 16 return func(self, *args, **kwargs)
File ~/my_env/lib/python3.10/site-packages/hailo_sdk_client/runner/client_runner.py:1158, in ClientRunner.translate_onnx_model(self, model, net_name, start_node_names, end_node_names, net_input_shapes, augmented_path, disable_shape_inference, disable_rt_metadata_extraction, net_input_format, **kwargs)
1115 """
1116 DFC API for parsing an ONNX model. This creates a runner with loaded HN (model) and
1117 parameters.
(...)
1155
1156 """
1157 parser = Parser()
-> 1158 parser.translate_onnx_model(
1159 model=model,
1160 net_name=net_name,
1161 start_node_names=start_node_names,
1162 end_node_names=end_node_names,
1163 net_input_shapes=net_input_shapes,
1164 augmented_path=augmented_path,
1165 disable_shape_inference=disable_shape_inference,
1166 disable_rt_metadata_extraction=disable_rt_metadata_extraction,
1167 net_input_format=net_input_format,
1168 **kwargs,
1169 )
1171 return self._finalize_parsing(parser.return_data)
File ~/my_env/lib/python3.10/site-packages/hailo_sdk_client/sdk_backend/parser/parser.py:260, in Parser.translate_onnx_model(self, model, net_name, start_node_names, end_node_names, net_input_shapes, augmented_path, disable_shape_inference, disable_rt_metadata_extraction, net_input_format, **kwargs)
257 milestone = self._format_time_milestone(start_time)
258 self._logger.info(f"Simplified ONNX model for a parsing retry attempt (completion time: {milestone})")
--> 260 parsing_results = self._parse_onnx_model_to_hn(
261 onnx_model=simplified_model,
262 net_name=valid_net_name,
263 start_node_names=start_node_names,
264 end_node_names=end_node_names,
265 net_input_shapes=net_input_shapes,
266 disable_shape_inference=disable_shape_inference,
267 net_input_format=net_input_format,
268 **kwargs,
269 )
271 milestone = self._format_time_milestone(start_time)
272 self._logger.info(f"Translation completed on ONNX model {valid_net_name} (completion time: {milestone})")
File ~/my_env/lib/python3.10/site-packages/hailo_sdk_client/sdk_backend/parser/parser.py:300, in Parser._parse_onnx_model_to_hn(self, onnx_model, net_name, start_node_names, end_node_names, net_input_shapes, disable_shape_inference, net_input_format, **kwargs)
297 except Exception as e:
298 self._logger.warning(f"ONNX shape inference failed: {e!s}")
--> 300 return self.parse_model_to_hn(
301 onnx_model,
302 None,
303 net_name,
304 start_node_names,
305 end_node_names,
306 nn_framework=NNFramework.ONNX,
307 output_shapes=output_shapes,
308 net_input_format=net_input_format,
309 **kwargs,
310 )
File ~/my_env/lib/python3.10/site-packages/hailo_sdk_client/sdk_backend/parser/parser.py:351, in Parser.parse_model_to_hn(self, model, values, net_name, start_node_names, end_node_names, nn_framework, output_shapes, net_input_format, rename_layers_by_blocks)
348 else:
349 raise BackendRuntimeException(f"Unsupported NN framework {nn_framework}")
--> 351 fuser = HailoNNFuser(converter.convert_model(), net_name, converter.end_node_names)
352 hailo_nn = fuser.convert_model()
353 hailo_nn.validate_stage(HnStage.HN)
File ~/my_env/lib/python3.10/site-packages/hailo_sdk_client/model_translator/translator.py:88, in HailoNNConverter.convert_model(self)
86 self._handle_inner_product_matmul()
87 self._handle_tokens_matmul()
---> 88 self._calculate_shapes(validate_shapes=False)
89 self._add_output_layers()
90 self._handle_fused_layers()
File ~/my_env/lib/python3.10/site-packages/hailo_sdk_client/model_translator/onnx_translator/onnx_translator.py:194, in ONNXConverter._calculate_shapes(self, validate_shapes)
192 def _calculate_shapes(self, validate_shapes=True):
193 self._update_meta_graph()
--> 194 self._layers_graph.calculate_shapes(meta_edges_graph=self._meta_graph, validate_shapes=validate_shapes)
File ~/my_env/lib/python3.10/site-packages/hailo_sdk_common/hailo_nn/hailo_nn.py:755, in HailoNN.calculate_shapes(self, meta_edges_graph, validate_shapes)
752 else:
753 layer.output_copies = self.get_number_of_successors(layer)
--> 755 layer.update_output_shapes(hn_stage=self.net_params.stage, validate_shapes=validate_shapes)
File ~/my_env/lib/python3.10/site-packages/hailo_sdk_common/hailo_nn/hn_layers/layer.py:458, in Layer.update_output_shapes(self, **kwargs)
456 def update_output_shapes(self, **kwargs):
457 output_shape = self._calc_output_shape()
--> 458 self.output_shapes = [output_shape[:] for _ in range(self.output_copies)]
File ~/my_env/lib/python3.10/site-packages/hailo_sdk_common/hailo_nn/hn_layers/layer.py:487, in Layer.output_shapes(self, output_shapes)
485 self._output_shapes = []
486 for shape in output_shapes:
--> 487 self._append_output_shape(shape)
File ~/my_env/lib/python3.10/site-packages/hailo_sdk_common/hailo_nn/hn_layers/layer.py:461, in Layer._append_output_shape(self, output_shape)
460 def _append_output_shape(self, output_shape):
--> 461 self._check_valid_shape(output_shape)
462 self.append_output_shape(output_shape)
File ~/my_env/lib/python3.10/site-packages/hailo_sdk_common/hailo_nn/hn_layers/layer.py:454, in Layer._check_valid_shape(self, shape)
449 raise UnsupportedModelError(
450 f"Unexpected dimension in shape {shape} at {self.full_name_msg}. "
451 f"Dimension must be of type 'int' or 'long'",
452 )
453 if any(dim == 0 for dim in shape):
--> 454 raise UnsupportedModelError(f"Unexpected zero dimension in shape {shape} at {self.full_name_msg}")
UnsupportedModelError: Unexpected zero dimension in shape [-1, 4, 0, 64] at base conv layer base_conv1 (translated from /conv/Conv)
I have also attached the onnx structure I viewed using netron.