Skip to content

AttributeError: np.cast was removed in NumPy 2.0 #2373

Open
@sum1elf

Description

@sum1elf

Describe the bug
When using tf2onnx with TensorFlow 2.18 and NumPy 2.0.2, an AttributeError occurs due to the removal of np.cast in NumPy 2.0. The error message is as follows:
File "site-packages/tf2onnx/tfonnx.py", line 77, in rewrite_constant_fold "Cast": np.cast, AttributeError: np.cast was removed in the NumPy 2.0 release. Use np.asarray(arr, dtype=dtype) instead.

System information

  • OS Platform and Distribution: Ubuntu 22.04.5 LTS
  • TensorFlow Version: 2.18
  • tf2onnx Version: 2.16.1
  • Python version: 3.10.12

To Reproduce

  1. Install TensorFlow 2.18 and tf2onnx 1.16.1.
  2. Ensure NumPy above 2.0 is installed.
  3. Run a script that uses tf2onnx.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions