Skip to content

onnx.helper.make_attribute could not infer type correctly from empty list #5216

@take-cheeze

Description

@take-cheeze

Bug Report

Is the issue related to model conversion?

Describe the bug

Since all([]) is always True passing empty list to make_attribute will be always list of ints

onnx/onnx/helper.py

Lines 858 to 860 in a021665

if all(issubclass(t, numbers.Integral) for t in types):
attr.ints.extend(value)
attr.type = AttributeProto.INTS

System information

Reproduction instructions

onnx.helper.make_attribute("attr_name", [])  # Always .type == INTS which isn't always expected

Expected behavior

For empty list make_attribute method should fail due to type inference error or there should be an explicit typed make_attribute method

Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions