|
InfiniOps
Operator Library for Accelerators
|
InfiniOps operators are C++ classes with generated Python bindings. They share a common dispatch model across devices and backend implementations.
Python users call generated functions from infini.ops:
C++ users call documented operator classes:
For calls that need a stream, workspace, or implementation selection, pass Handle and Config explicitly:
Each operator has:
src/base/<op>.hsrc/native/.../ops/<op>/src/torch/ops/<op>/generated/tests/test_<op>.pyOperator<Key, Device, Index> specializations provide concrete implementations. Device selects the backend and Index selects the implementation slot for that operator on that backend.
Implementation indexes are local to an operator and device. Use an explicit index only when the backend exposes multiple implementations for the same operator.
Generated ATen-backed wrappers reserve implementation index 8. Hand-written backend implementations must avoid colliding with existing implementations for the same operator.
Operator::Call(...) caches constructed operator instances per thread. The cache key includes the config implementation index and tensor/scalar geometry. Tests can call clear_cache() on generated Python operator classes for module isolation.
Code that changes tensor geometry, backend implementation selection, or workspace assumptions should account for this caching behavior.
Set INFINI_OPS_TRACE_CALLS=1 to print each call that reaches the InfiniOps dispatcher. Each line starts with the triggering environment variable and is followed by a JSON object containing the operator, device, and implementation index:
Tracing is disabled by default.
The standard path for a native operator is:
src/base/<op>.h.src/native/.../ops/<op>/.tests/test_<op>.py.Before defining the public base interface, follow Operator API Alignment to select an upstream target and design the canonical name, parameter list, overloads, and return contract.
For PyTorch ATen-backed operators, see Adding ATen-backed operators. That page explains the generated backend path and the hand-written ATen backend path.
Smoke builds use an operator allowlist to keep routine validation short:
Then run:
Use full builds and broader tests for shared dispatch, wrapper generation, backend infrastructure, or high-risk operator changes.