Skip to content

Patch raw PyTorch reshape under NumPy public backend#3721

Open
FlorianPfaff wants to merge 3 commits into
mainfrom
bugfix/raw-pytorch-reshape-default-backend
Open

Patch raw PyTorch reshape under NumPy public backend#3721
FlorianPfaff wants to merge 3 commits into
mainfrom
bugfix/raw-pytorch-reshape-default-backend

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

Summary

  • add an import-time compatibility hook for raw pyrecest._backend.pytorch.reshape
  • coerce array-like reshape inputs through the raw PyTorch backend rather than the active public backend
  • cover the NumPy-public-backend case with a subprocess regression test

Bug fixed

When PYRECEST_BACKEND=numpy, importing pyrecest left pyrecest._backend.pytorch.reshape as the raw torch.reshape function. Calls such as raw_pytorch.reshape([1, 2, 3, 4], np.array([2, 2])) therefore failed because torch.reshape does not accept Python lists or NumPy-style shape arrays directly. The new hook patches the raw PyTorch helper regardless of the selected public backend while only updating pyrecest.backend.reshape when the public backend is actually PyTorch.

Testing

  • Added tests/backend_support/test_raw_pytorch_reshape_contract.py
  • Not run locally; this execution environment cannot clone the GitHub repository directly.

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 61.06s
✅ JSON prettier 7 0 0 0 1.01s
✅ JSON v8r 7 0 0 4.29s
✅ MARKDOWN markdownlint 68 0 0 0 1.8s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.71s
✅ PYTHON black 1207 37 0 0 59.22s
✅ PYTHON isort 1207 72 0 0 2.86s
✅ REPOSITORY checkov yes no no 47.56s
✅ REPOSITORY gitleaks yes no no 11.19s
✅ REPOSITORY git_diff yes no no 0.32s
✅ REPOSITORY secretlint yes no no 45.8s
✅ REPOSITORY syft yes no no 5.02s
✅ REPOSITORY trivy-sbom yes no no 5.21s
✅ REPOSITORY trufflehog yes no no 15.09s
✅ YAML prettier 11 0 0 0 0.67s
✅ YAML v8r 11 0 0 8.92s
✅ YAML yamllint 11 0 0 0.53s

Notices

📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining SECURITY_SUGGESTIONS: false)

See detailed reports in MegaLinter artifacts

Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)

  • Documentation: Custom Flavors
  • Command: npx mega-linter-runner@9.5.0 --custom-flavor-setup --custom-flavor-linters PYTHON_BLACK,PYTHON_ISORT,COPYPASTE_JSCPD,JSON_V8R,JSON_PRETTIER,MARKDOWN_MARKDOWNLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,REPOSITORY_CHECKOV,REPOSITORY_GIT_DIFF,REPOSITORY_GITLEAKS,REPOSITORY_SECRETLINT,REPOSITORY_SYFT,REPOSITORY_TRIVY_SBOM,REPOSITORY_TRUFFLEHOG,YAML_PRETTIER,YAML_YAMLLINT,YAML_V8R

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant