Skip to content

Latest commit

 

History

History
60 lines (44 loc) · 1.91 KB

File metadata and controls

60 lines (44 loc) · 1.91 KB

Examples

InfiniOps keeps small runnable examples under examples/. They are intended for development and smoke validation of common API surfaces, not as installed downstream consumer projects.

Python Example

Run the Python GEMM example after installing the InfiniOps wheel:

python examples/gemm.py

The example creates CPU tensors with PyTorch, calls infini.ops.gemm, and prints the InfiniOps result next to torch.mm.

C++ Examples

C++ examples are built by the raw CMake project when Python binding generation is disabled:

cmake -S . -B build \
  -DINFINI_RT_ROOT=/path/to/infini-rt-prefix \
  -DWITH_CPU=ON \
  -DGENERATE_PYTHON_BINDINGS=OFF
cmake --build build -j

The generated executables are written under the CMake build tree. Exact paths depend on the generator, but common targets include:

  • tensor
  • data_type
  • gemm
  • gemm_dispatch

Build one example target explicitly:

cmake --build build --target gemm

Example Inventory

Example Language Purpose Backend notes
examples/gemm.py Python Calls infini.ops.gemm on PyTorch tensors. CPU by default.
examples/tensor.cc C++ Creates and prints an infini::ops::Tensor view. CPU host memory only.
examples/data_type.cc C++ Prints data type names and element sizes. Backend independent.
examples/gemm/gemm.cc C++ Allocates backend memory and calls Gemm::Call. Uses the enabled backend selected by examples/runtime_api.h.
examples/gemm/gemm_dispatch.cc C++ Compares two NVIDIA GEMM implementation indexes. Requires WITH_NVIDIA=ON; exits early on other builds.

Scope

The current C++ examples include in-tree development headers such as tensor.h, runtime_api.h, and backend implementation headers. A fully installed downstream CMake consumer example should be added separately once the installed C++ package boundary is tested.