|
InfiniOps
Operator Library for Accelerators
|
The linked backend calls operators provided by an installed third-party shared library. It supports exact exported symbols, TVM FFI entry points, and registered PyTorch Dispatcher operators when a platform package does not provide source code or a stable C API.
Linked implementations use the following layout:
CUDA providers may use <implementation>.cu instead of .cc.
The platform library file contains DSO discovery information:
A library may also provide include_glob when its transport needs installed headers. Each glob must resolve to exactly one path in the Python distribution. A library may set python_distribution_version to a PEP 440 specifier. The resolver verifies the installed distribution version before looking up its DSO. A DSO that depends on another declared platform library lists that dependency under the implementation's optional link_libraries key.
Files for an operator implementation use the provider name as their common stem. Multiple implementations for the same operator and device use distinct file stems and implementation slots.
The implementation YAML identifies the library and the exact demangled symbols required by its C++ source:
A Dispatcher implementation instead declares its exact schema and required dispatch key:
Each implementation uses exactly one contract form. The resolver rejects a partial Dispatcher contract or a binding that mixes both forms.
Keep ABI behavior in <implementation>.cc or .cu, not in YAML. Shared operator templates own reusable tensor conversion, stream guards, layout staging, and copy-back behavior. Provider sources own exact typed declarations, synthesized arguments, and provider-specific return handling.
For the torch transport, an implementation backend inherits its device C10 specialization for device identity and external-stream handling, then defines its provider-specific Call ABI.
For the tvm_ffi transport, provider sources call exported TVM FFI entry points directly. The resolver supplies installed TVM FFI headers and links the provider DSO together with every library named in link_libraries.
At configure time, scripts/resolve_linked_ops.py locates the installed Python distribution. It verifies C++ symbols with both nm and readelf; raw readelf symbols are demangled with GNU or LLVM c++filt before exact comparison. Dispatcher contracts are verified in an isolated Python process by loading the DSO, comparing the registered schema exactly, and checking the requested dispatch key. The resolver writes a CMake manifest and diagnostic JSON under generated/linked/. Generated files are not committed.
DSOs that provide Dispatcher registrations and DSOs named in link_libraries are retained with --no-as-needed only for their own link items. This prevents the linker from discarding registration code or an explicit dependency while preserving its state for unrelated libraries.
Enable the backend independently of generated ATen implementations:
WITH_TORCH=OFF disables the generated ATen backend, but WITH_LINKED=ON currently still requires an installed torch package. Linked configuration shares its Python interpreter and C++ ABI setup with the existing torch transport.
To resolve only selected linked implementation slots, pass an ops.json file through INFINI_OPS_OPS. The resolver reads each linked provider's slot from its sibling C++ header before locating external libraries, so an unselected provider does not add a package or shared-library dependency. See Build configuration for the file format.
The torch transport uses the installed PyTorch C++ headers and libraries for at::Tensor, but it does not enable the standard src/torch operator backend. Provider and PyTorch C++ ABIs must match. Configuration fails before compilation when the distribution, shared library, or an exact required symbol is missing.
InfiniOps does not bundle the provider library. Its resolved directory and the directories of its linked dependencies are recorded in the installed binary's RPATH, so a linked build is tied to that Python environment. PyTorch runtime directories are recorded for the torch transport as well. Reconfigure and rebuild after moving or replacing the provider environment. In-place changes to a resolved provider DSO are tracked as CMake configure and link dependencies.
A linked provider declares an implementation slot of 16 or greater in its Operator specialization. The slot must be unique for that operator and device.