Created
May 23, 2020 20:29
-
-
Save dreiss/33963e24f89a1ac8b8387d5f11bfc71a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--------------------------------------------------------------------------- | |
ValueError Traceback (most recent call last) | |
<ipython-input-13-c9831efca396> in <module> | |
----> 1 torch.onnx.export(Model(), torch.zeros(1,1,1,1), MODEL_FILE, opset_version=11) | |
2 | |
3 loaded = onnx.load(MODEL_FILE) | |
~/work/pytorch/torch/onnx/__init__.py in export(model, args, f, export_params, verbose, training, input_names, output_names, aten, export_raw_ir, operator_export_type, opset_version, _retain_param_name, do_constant_folding, example_outputs, strip_doc_string, dynamic_axes, keep_initializers_as_inputs, custom_opsets, enable_onnx_checker, use_external_data_format) | |
170 do_constant_folding, example_outputs, | |
171 strip_doc_string, dynamic_axes, keep_initializers_as_inputs, | |
--> 172 custom_opsets, enable_onnx_checker, use_external_data_format) | |
173 | |
174 | |
~/work/pytorch/torch/onnx/utils.py in export(model, args, f, export_params, verbose, training, input_names, output_names, aten, export_raw_ir, operator_export_type, opset_version, _retain_param_name, do_constant_folding, example_outputs, strip_doc_string, dynamic_axes, keep_initializers_as_inputs, custom_opsets, enable_onnx_checker, use_external_data_format) | |
90 dynamic_axes=dynamic_axes, keep_initializers_as_inputs=keep_initializers_as_inputs, | |
91 custom_opsets=custom_opsets, enable_onnx_checker=enable_onnx_checker, | |
---> 92 use_external_data_format=use_external_data_format) | |
93 | |
94 | |
~/work/pytorch/torch/onnx/utils.py in _export(model, args, f, export_params, verbose, training, input_names, output_names, operator_export_type, export_type, example_outputs, propagate, opset_version, _retain_param_name, do_constant_folding, strip_doc_string, dynamic_axes, keep_initializers_as_inputs, fixed_batch_size, custom_opsets, add_node_names, enable_onnx_checker, use_external_data_format) | |
528 example_outputs, propagate, | |
529 _retain_param_name, val_do_constant_folding, | |
--> 530 fixed_batch_size=fixed_batch_size) | |
531 | |
532 # TODO: Don't allocate a in-memory string for the protobuf | |
~/work/pytorch/torch/onnx/utils.py in _model_to_graph(model, args, verbose, input_names, output_names, operator_export_type, example_outputs, propagate, _retain_param_name, do_constant_folding, _disable_torch_constant_prop, fixed_batch_size) | |
382 graph = _optimize_graph(graph, operator_export_type, | |
383 _disable_torch_constant_prop=_disable_torch_constant_prop, | |
--> 384 fixed_batch_size=fixed_batch_size, params_dict=params_dict) | |
385 | |
386 if isinstance(model, torch.jit.ScriptModule) or isinstance(model, torch.jit.ScriptFunction): | |
~/work/pytorch/torch/onnx/utils.py in _optimize_graph(graph, operator_export_type, _disable_torch_constant_prop, fixed_batch_size, params_dict) | |
186 torch._C._jit_pass_erase_number_types(graph) | |
187 | |
--> 188 graph = torch._C._jit_pass_onnx(graph, operator_export_type) | |
189 torch._C._jit_pass_lint(graph) | |
190 | |
~/work/pytorch/torch/onnx/__init__.py in _run_symbolic_function(*args, **kwargs) | |
203 def _run_symbolic_function(*args, **kwargs): | |
204 from torch.onnx import utils | |
--> 205 return utils._run_symbolic_function(*args, **kwargs) | |
206 | |
207 | |
~/work/pytorch/torch/onnx/utils.py in _run_symbolic_function(g, n, inputs, env, operator_export_type) | |
780 .format(op_name, opset_version, op_name)) | |
781 op_fn = sym_registry.get_registered_op(op_name, '', opset_version) | |
--> 782 return op_fn(g, *inputs, **attrs) | |
783 | |
784 elif ns == "prim": | |
~/work/pytorch/torch/onnx/symbolic_opset11.py in symbolic_fn(g, input, output_size, *args) | |
112 def _interpolate(name, dim, interpolate_mode): | |
113 def symbolic_fn(g, input, output_size, *args): | |
--> 114 scales, align_corners = sym_help._get_interpolate_attributes(g, interpolate_mode, args) | |
115 align_corners = sym_help._maybe_get_scalar(align_corners) | |
116 coordinate_transformation_mode = "asymmetric" if interpolate_mode == "nearest" \ | |
~/work/pytorch/torch/onnx/symbolic_helper.py in _get_interpolate_attributes(g, mode, args) | |
295 align_corners = args[0] | |
296 scales = args[1:] | |
--> 297 scales = _interpolate_get_scales_if_available(g, scales) | |
298 return scales, align_corners | |
299 | |
~/work/pytorch/torch/onnx/symbolic_helper.py in _interpolate_get_scales_if_available(g, scales) | |
271 | |
272 def _interpolate_get_scales_if_available(g, scales): | |
--> 273 available_scales = _maybe_get_const(scales[0], 'f') != -1 and not _is_none(scales[0]) | |
274 | |
275 if not available_scales: | |
~/work/pytorch/torch/onnx/symbolic_helper.py in _maybe_get_const(value, desc) | |
90 def _maybe_get_const(value, desc): | |
91 if _is_value(value) and value.node().kind() == 'onnx::Constant': | |
---> 92 return _parse_arg(value, desc) | |
93 return value | |
94 | |
~/work/pytorch/torch/onnx/symbolic_helper.py in _parse_arg(value, desc) | |
63 return int(tval) | |
64 elif desc == 'f': | |
---> 65 return float(tval) | |
66 elif desc == 'b': | |
67 return bool(tval) | |
ValueError: only one element tensors can be converted to Python scalars |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment