Skip to content

Could not infer the attribute type from the elements of the passed Iterable value #2259

Open
@guarin

Description

@guarin

Describe the bug

Hi! I am trying to convert a model to onnx but running into a Could not infer the attribute type from the elements of the passed Iterable value error (stacktrace is below). The error happens because a TensorShapeProto object is passed as value to make_attribute and is raised here.

I am unsure whether this is a bug in the model code, in tf2onnx, or onnx itself. Any help would be appreciated :)

Command:

python -m tf2onnx.convert --saved-model model --output model.onnx --verbose

Stacktrace:

, ex=Could not infer the attribute type from the elements of the passed Iterable value.
Traceback (most recent call last):
  File "/opt/conda/envs/onnx/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/conda/envs/onnx/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/opt/conda/envs/onnx/lib/python3.10/site-packages/tf2onnx/convert.py", line 714, in <module>
    main()
  File "/opt/conda/envs/onnx/lib/python3.10/site-packages/tf2onnx/convert.py", line 273, in main
    model_proto, _ = _convert_common(
  File "/opt/conda/envs/onnx/lib/python3.10/site-packages/tf2onnx/convert.py", line 168, in _convert_common
    g = process_tf_graph(tf_graph, const_node_values=const_node_values,
  File "/opt/conda/envs/onnx/lib/python3.10/site-packages/tf2onnx/tfonnx.py", line 459, in process_tf_graph
    main_g, subgraphs = graphs_from_tf(tf_graph, input_names, output_names, shape_override, const_node_values,
  File "/opt/conda/envs/onnx/lib/python3.10/site-packages/tf2onnx/tfonnx.py", line 474, in graphs_from_tf
    ordered_func = resolve_functions(tf_graph)
  File "/opt/conda/envs/onnx/lib/python3.10/site-packages/tf2onnx/tf_loader.py", line 778, in resolve_functions
    _, _, _, _, _, tfunctions = tflist_to_onnx(func, {})
  File "/opt/conda/envs/onnx/lib/python3.10/site-packages/tf2onnx/tf_utils.py", line 462, in tflist_to_onnx
    onnx_node = helper.make_node(node_type, input_names, output_names, name=node.name, **attr)
  File "/opt/conda/envs/onnx/lib/python3.10/site-packages/onnx/helper.py", line 163, in make_node
    node.attribute.extend(
  File "/opt/conda/envs/onnx/lib/python3.10/site-packages/onnx/helper.py", line 164, in <genexpr>
    make_attribute(key, value)
  File "/opt/conda/envs/onnx/lib/python3.10/site-packages/onnx/helper.py", line 881, in make_attribute
    raise ValueError(
ValueError: Could not infer the attribute type from the elements of the passed Iterable value.

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 18.04*): Ubuntu 20.04
  • TensorFlow Version: 2.14.0 (the model was also generated with tensorflow 2.14)
  • Python version: 3.10
  • ONNX version (if applicable, e.g. 1.11*): 1.14.1
  • ONNXRuntime version (if applicable, e.g. 1.11*): None
  • ts2onnx version: 1.15.1

Full output logs
logs.txt

Metadata

Metadata

Assignees

Labels

bugAn unexpected problem or unintended behaviorpending on user responseWaiting for more information or validation from user

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions