Skip to content

feat!: align max unpool with PyTorch Python API#813

Draft
voltjia wants to merge 1 commit into
masterfrom
feat/align-max-unpool-python-api
Draft

feat!: align max unpool with PyTorch Python API#813
voltjia wants to merge 1 commit into
masterfrom
feat/align-max-unpool-python-api

Conversation

@voltjia

@voltjia voltjia commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Align max_unpool2d and max_unpool3d with PyTorch's Python geometry order using one full public interface per operator.
  • Add shared output-size resolution, a handwritten max_unpool2d Torch adapter, overload-aware vector code generation, and focused CPU/NVIDIA coverage.

Motivation

The existing operators expose ATen's resolved output_size, stride, padding contract rather than the public functional API. Public callers therefore cannot use PyTorch's geometry contract directly. The generated max_unpool2d.out adapter also cannot implement Python-level geometry resolution by itself.

No standalone issue is associated with this alignment follow-up.

Type of Change

  • feat - new feature / new operator / new platform
  • fix - bug fix
  • perf - performance improvement (no behavioral change)
  • refactor - code restructuring without behavior change
  • test - adding or fixing tests only
  • docs - documentation only
  • build / ci - build system or CI configuration
  • chore - tooling, formatting, or other non-code changes
  • Breaking change

Platforms Affected

  • CPU (WITH_CPU)
  • NVIDIA (WITH_NVIDIA)
  • Iluvatar (WITH_ILUVATAR)
  • MetaX (WITH_METAX)
  • Cambricon (WITH_CAMBRICON)
  • Moore (WITH_MOORE)
  • Ascend (WITH_ASCEND)
  • PyTorch C++ bindings (WITH_TORCH)
  • Build system / CMake / CI
  • Python bindings / user-facing API

Smoke Test Result

Host: ssh nvidia
Image: accelerator-dev/nvidia:latest
PyTorch: 2.10.0a0+b4e4ee8

cmake ... -DWITH_CPU=ON -DWITH_NVIDIA=ON -DWITH_TORCH=ON \
  -DINFINI_OPS_OPS=max_unpool2d,max_unpool3d \
  -DINFINI_OPS_TORCH_OPS=max_unpool2d,max_unpool3d
cmake --build build-nvidia --target ops -j 16
Build passed; codegen emitted 1 max_unpool3d overload and the handwritten max_unpool2d adapter was linked.

python -m pytest tests/test_generate_wrappers.py -q
14 passed

python -m pytest tests/test_torch_ops.py -k max_unpool --devices cpu nvidia -q
36 passed

Test Results on Supported Platforms

Platform Affected Build / Smoke Result Full Result / Notes
CPU Yes targeted build passed 2D/3D geometry cases passed
NVIDIA Yes targeted build passed 2D/3D geometry cases passed
Iluvatar No N/A - not affected N/A - not affected
MetaX No N/A - not affected N/A - not affected
Cambricon No N/A - not affected N/A - not affected
Moore No N/A - not affected N/A - not affected
Ascend No N/A - not affected N/A - not affected

Benchmark / Performance Impact

N/A. Geometry is resolved once per operator construction/call; the underlying ATen kernels are unchanged.

Notes for Reviewers

API alignment

Interface Signature Alignment basis
InfiniOps 2D max_unpool2d(input, indices, kernel_size, stride, padding, output_size, out) PyTorch Python geometry order; explicit out remains last per CONTRIBUTING.md.
PyTorch 2D F.max_unpool2d(input, indices, kernel_size, stride=None, padding=0, output_size=None) Pinned PyTorch source
InfiniOps 3D max_unpool3d(input, indices, kernel_size, stride, padding, output_size, out) PyTorch Python geometry order; explicit out remains last per CONTRIBUTING.md.
PyTorch 3D F.max_unpool3d(input, indices, kernel_size, stride=None, padding=0, output_size=None) Pinned PyTorch source
Deprecated 3D compatibility max_unpool3d(input, indices, output_size, stride, padding, out) Preserves the pre-alignment 3D interface for migration.
  • No prefix/default convenience overloads are added; C++ callers supply the optional values explicitly.
  • The old 2D and new 2D signatures have the same C++ type sequence, so they cannot coexist as overloads. This is the direct breaking replacement reflected by feat!.
  • max_unpool2d is removed from scripts/torch_ops.yaml because its ATen schema exposes resolved output_size, not the public Python geometry contract. The handwritten adapter resolves geometry and then calls at::max_unpool2d_out.
  • Ruff 0.15.22 and clang-format 21.1.8 checks passed.

@voltjia
voltjia changed the base branch from master to fix/pin-ruff-version July 24, 2026 07:54
@voltjia
voltjia force-pushed the feat/align-max-unpool-python-api branch from 5d3dbd8 to ee86516 Compare July 24, 2026 08:02
Base automatically changed from fix/pin-ruff-version to master July 24, 2026 08:13
@voltjia
voltjia force-pushed the feat/align-max-unpool-python-api branch from ee86516 to 429c64e Compare July 24, 2026 08:27
@voltjia
voltjia force-pushed the feat/align-max-unpool-python-api branch from 429c64e to dea272d Compare July 24, 2026 11:08
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