electriclilies commented on a change in pull request #7429:
URL: https://github.com/apache/tvm/pull/7429#discussion_r574643286
##########
File path: python/tvm/relay/frontend/onnx.py
##########
@@ -2850,12 +2879,16 @@ def from_onnx(self, graph, opset, freeze_params=False,
get_output_expr=False):
for init_tensor in graph.initializer:
if not init_tensor.name.strip():
raise ValueError("Tensor's name is required.")
- self._params[init_tensor.name] = self._parse_array(init_tensor)
- self._nodes[init_tensor.name] = new_var(
- init_tensor.name,
- shape=self._params[init_tensor.name].shape,
- dtype=self._params[init_tensor.name].dtype,
- )
+ if freeze_params:
+ array = self._parse_array(init_tensor)
+ self._nodes[init_tensor.name] = _expr.const(array)
+ else:
+ self._params[init_tensor.name] = self._parse_array(init_tensor)
Review comment:
You could pull `array = self._parse_array(init_tensor)` out of the if /
else statement
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]