Skip to content

feat: align elu with PyTorch Python API#811

Merged
voltjia merged 1 commit into
masterfrom
feat/align-elu-python-api
Jul 27, 2026
Merged

feat: align elu with PyTorch Python API#811
voltjia merged 1 commit into
masterfrom
feat/align-elu-python-api

Conversation

@voltjia

@voltjia voltjia commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Expose one primary elu(input, alpha, out) interface matching PyTorch's public attribute.
  • Keep the previous ATen-derived scale and input_scale interface as a [[deprecated]] compatibility overload.

Motivation

The public InfiniOps ELU interface exposed internal ATen implementation parameters that do not appear in torch.nn.functional.elu. The earlier revision also added an alpha=1.0 convenience overload; this revision removes it to keep the overload set minimal.

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=elu -DINFINI_OPS_TORCH_OPS=elu
cmake --build build-nvidia --target ops -j 16
Build passed; codegen emitted 1 ATen implementation overload.

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

python -m pytest tests/test_torch_ops.py -k elu --devices cpu nvidia -q
18 passed

Test Results on Supported Platforms

Platform Affected Build / Smoke Result Full Result / Notes
CPU Yes targeted build passed Primary and deprecated paths passed
NVIDIA Yes targeted build passed Primary and deprecated paths 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. The primary interface delegates to the existing ATen implementation with scale=1.0 and input_scale=1.0.

Notes for Reviewers

API alignment

Interface Signature Alignment basis
InfiniOps primary elu(input, alpha, out) Matches PyTorch's out-of-place public attribute; explicit out remains last per CONTRIBUTING.md.
PyTorch public API F.elu(input, alpha=1.0, inplace=False) Pinned PyTorch source
Deprecated compatibility elu(input, alpha, scale, input_scale, out) Preserves the pre-alignment ATen-derived interface for migration.
  • C++ callers pass alpha=1.0 explicitly when they want the PyTorch default.
  • The existing test_op path was extended instead of adding another test function.
  • 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:53
@voltjia
voltjia force-pushed the feat/align-elu-python-api branch from a5603ce to bb7ed2f 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-elu-python-api branch from bb7ed2f to e4cd313 Compare July 24, 2026 08:27
@voltjia
voltjia force-pushed the feat/align-elu-python-api branch from e4cd313 to b7e2bf0 Compare July 24, 2026 11:07
@voltjia voltjia changed the title feat: align ELU with PyTorch Python API feat: align elu with PyTorch Python API Jul 27, 2026
@voltjia
voltjia marked this pull request as ready for review July 27, 2026 01:12
@voltjia
voltjia requested a review from a team July 27, 2026 01:12
@voltjia
voltjia merged commit d619deb into master Jul 27, 2026
19 of 20 checks passed
@voltjia
voltjia deleted the feat/align-elu-python-api branch July 27, 2026 01:15
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