Skip to content

Commit 74f957a

Browse files
Re-land Python buffer inputs after internal CI fixes (pytorch#23535)
## Summary Corrected re-land of pytorch#23088 after pytorch#23532. - accept NumPy arrays and other CPU Python buffer providers directly - retain borrowed storage for the runtime input lifetime - handle empty and read-only buffers safely - reject resized borrowed inputs before execution - preserve all existing Torch-input behavior - avoid importing torch on buffer-only call paths ## Internal CI fixes - removed unsupported ChannelsLast3d bridging from the portable Torch path - restored legacy RuntimeError behavior for unsupported Torch layouts - kept the zero-source tensor-copy behavior unchanged - added regression coverage for buffer-only calls and empty tensor copies ## Test plan - Python syntax validation - internal ATen and portable pybindings targets - internal standard and custom-library variants - low-level ATen tensor utility tests Differential Revision: D123893454
1 parent 9b5758f commit 74f957a

7 files changed

Lines changed: 803 additions & 40 deletions

File tree

‎extension/pybindings/README.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ CMAKE_ARGS="-DEXECUTORCH_BUILD_VULKAN=ON" ./install_executorch.sh
2828
## Classes
2929
### ExecuTorchModule
3030
- `plan_execute()`: Plan and execute.
31-
- `run_method()`: Run method.
32-
- `forward()`: Forward. This takes a pytree-flattend PyTorch-tensor-based input.
31+
- `run_method()`: Run a method with either PyTorch tensors or objects that
32+
implement Python's buffer protocol, such as NumPy arrays. A call must use a
33+
single tensor protocol; PyTorch tensors and buffers cannot be mixed.
34+
- `forward()`: Forward. A single buffer may be passed directly; multiple
35+
inputs are passed as a flat sequence.
3336
- `has_etdump()`: Check if etdump is available.
3437
- `write_etdump_result_to_file()`: Write etdump result to a file.
3538
- `__call__()`: Call method.

0 commit comments

Comments
 (0)