Fix Type-confusion: raw-pointer bind_input causing OOB write

Merged
SE
5mo ago
+41-0

Description

NOTE: Replacement of #28781. The original PR was accidentally affected by an unexpected agentic AI commit.

Fix a pytest collection error in the Windows GPU CUDA CI pipeline caused by test_convert_tf_models_to_pytorch.py failing to locate convert_tf_models_to_pytorch.py at module load time.

Two changes were made:

  • onnxruntime/test/python/transformers/test_convert_tf_models_to_pytorch.py: Updated the path resolution logic to first check if convert_tf_models_to_pytorch.py is in the same directory as the test file (the case after CMake copies it into the build output), then fall back to the correct source-tree path using parents[2] (resolving to the onnxruntime/ subdirectory, three levels up from test/python/transformers/).

  • cmake/onnxruntime_python.cmake: Added a cmake -E copy command to deploy convert_tf_models_to_pytorch.py from onnxruntime/python/tools/transformers/ into the transformers/ build output directory alongside the existing test files, so the first-choice path resolution works in CI.

Motivation and Context

The CI job Windows GPU CUDA CI Pipeline Test Job was failing during pytest collection with:

FileNotFoundError: 'D:\\a\\_work\\_temp\\onnxruntime\\python\\tools\\transformers\\convert_tf_models_to_pytorch.py'

The test used a hardcoded parents[4] offset assuming the test file resided at onnxruntime/test/python/transformers/ in the source tree (where parents[4] = repo root). In CI, pytest test files are copied to the build output directory (e.g. $runner_temp/build/RelWithDebInfo/RelWithDebInfo/transformers/), where parents[4] resolves to the runner's temp directory rather than the workspace root, so the source file was never found and collection aborted with exit code 2.