Skip to content

Accept memory_format kwarg on rand/randn/randint _like ops - #3011

Open
fruet (gabrielfruet) wants to merge 1 commit into
microsoft:mainfrom
gabrielfruet:fix/rand-like-memory-format
Open

Accept memory_format kwarg on rand/randn/randint _like ops#3011
fruet (gabrielfruet) wants to merge 1 commit into
microsoft:mainfrom
gabrielfruet:fix/rand-like-memory-format

Conversation

@gabrielfruet

Copy link
Copy Markdown
Contributor

Exporting rand_like, randn_like, or randint_like with memory_format=torch.preserve_format raised a ConversionError: the torchlib signatures dropped the memory_format kwarg the aten schema declares. Adds it as a no-op trailing kwarg on the four *_like random ops, matching what #2994 did for full_like.

Fixes #3002.

Changes:

  • ops/core.py: add memory_format to aten_rand_like, aten_randn_like, aten_randint_like, aten_randint_like_low_dtype
  • e2e tests: export each op with memory_format=torch.preserve_format

Testing: the new tests assert export succeeds rather than value equality, since these ops are non-deterministic.

@justinchuby

Copy link
Copy Markdown
Collaborator

Could you resolve merge conflicts? Thanks

@codecov

codecov Bot commented Aug 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.63%. Comparing base (9ef0aac) to head (0417850).
⚠️ Report is 14 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3011   +/-   ##
=======================================
  Coverage   72.63%   72.63%           
=======================================
  Files         265      265           
  Lines       32204    32210    +6     
  Branches     3041     3042    +1     
=======================================
+ Hits        23391    23397    +6     
  Misses       7779     7779           
  Partials     1034     1034           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@gabrielfruet
fruet (gabrielfruet) force-pushed the fix/rand-like-memory-format branch from 0417850 to 1bb8ef4 Compare August 24, 2026 18:38
@gabrielfruet

fruet (gabrielfruet) commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

Justin Chu (@justinchuby) Conflicts are resolved! Thank you for approving :)

It still needs a re-approval since I pushed again

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

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

torch.ops.aten.rand_like ONNX export failure

2 participants