Skip to content

tenzr

Namespaces

Name
tenzr::apiutils
tenzr::autograd
tenzr::check
tenzr::checkpoint
tenzr::concepts
Compile-time element-type constraints over DTypeTraits.
tenzr::data
tenzr::debug
tenzr::detail
tenzr::execution
tenzr::io
tenzr::lax
tenzr::modules
tenzr::nn
tenzr::numpy
tenzr::optim
tenzr::plax
tenzr::profiler
tenzr::python
tenzr::random
tenzr::runtime
tenzr::scipy
tenzr::sharding
tenzr::txpr
tenzr::ufunc

Classes

Name
class tenzr::AddNode
Elementwise addition of two operands.
class tenzr::ArgSortNode
class tenzr::Array
struct tenzr::bfloat16
16-bit brain floating-point element type stored as raw bits.
struct tenzr::CachedExecutable
A compiled PJRT executable together with its hash and the shape and dtype descriptors of its inputs and outputs.
class tenzr::ConcatenateNode
Join multiple operands along an axis.
class tenzr::ConvertNode
Convert an operand to another element type.
class tenzr::ConvolutionNode
class tenzr::CustomOpNode
Node backed by a custom operator registered in the OpRegistry.
struct tenzr::DeviceInfo
Description of one PJRT device: its ids, platform kind, debug string, and handle.
class tenzr::DivNode
Elementwise division of two operands.
struct tenzr::DTypeTraits
struct tenzr::DTypeTraits< bfloat16 >
DTypeTraits specialization mapping bfloat16 to DType::kBFloat16.
struct tenzr::DTypeTraits< bool >
DTypeTraits specialization mapping bool to DType::kBool.
struct tenzr::DTypeTraits< double >
DTypeTraits specialization mapping double to DType::kFloat64.
struct tenzr::DTypeTraits< float >
DTypeTraits specialization mapping float to DType::kFloat32.
struct tenzr::DTypeTraits< float16 >
DTypeTraits specialization mapping float16 to DType::kFloat16.
struct tenzr::DTypeTraits< float4_e2m1fn >
struct tenzr::DTypeTraits< float6_e2m3fn >
struct tenzr::DTypeTraits< float6_e3m2fn >
struct tenzr::DTypeTraits< float8_e3m4 >
DTypeTraits specialization mapping float8_e3m4 to DType::kFloat8E3M4.
struct tenzr::DTypeTraits< float8_e4m3 >
DTypeTraits specialization mapping float8_e4m3 to DType::kFloat8E4M3.
struct tenzr::DTypeTraits< float8_e4m3b11fnuz >
struct tenzr::DTypeTraits< float8_e4m3fn >
DTypeTraits specialization mapping float8_e4m3fn to DType::kFloat8E4M3FN.
struct tenzr::DTypeTraits< float8_e4m3fnuz >
struct tenzr::DTypeTraits< float8_e5m2 >
DTypeTraits specialization mapping float8_e5m2 to DType::kFloat8E5M2.
struct tenzr::DTypeTraits< float8_e5m2fnuz >
struct tenzr::DTypeTraits< float8_e8m0fnu >
struct tenzr::DTypeTraits< int1 >
DTypeTraits specialization mapping int1 to DType::kInt1.
struct tenzr::DTypeTraits< int16_t >
DTypeTraits specialization mapping int16_t to DType::kInt16.
struct tenzr::DTypeTraits< int2 >
DTypeTraits specialization mapping int2 to DType::kInt2.
struct tenzr::DTypeTraits< int32_t >
DTypeTraits specialization mapping int32_t to DType::kInt32.
struct tenzr::DTypeTraits< int4 >
DTypeTraits specialization mapping int4 to DType::kInt4.
struct tenzr::DTypeTraits< int64_t >
DTypeTraits specialization mapping int64_t to DType::kInt64.
struct tenzr::DTypeTraits< int8_t >
DTypeTraits specialization mapping int8_t to DType::kInt8.
struct tenzr::DTypeTraits< uint1 >
DTypeTraits specialization mapping uint1 to DType::kUInt1.
struct tenzr::DTypeTraits< uint16_t >
DTypeTraits specialization mapping uint16_t to DType::kUInt16.
struct tenzr::DTypeTraits< uint2 >
DTypeTraits specialization mapping uint2 to DType::kUInt2.
struct tenzr::DTypeTraits< uint32_t >
DTypeTraits specialization mapping uint32_t to DType::kUInt32.
struct tenzr::DTypeTraits< uint4 >
DTypeTraits specialization mapping uint4 to DType::kUInt4.
struct tenzr::DTypeTraits< uint64_t >
DTypeTraits specialization mapping uint64_t to DType::kUInt64.
struct tenzr::DTypeTraits< uint8_t >
DTypeTraits specialization mapping uint8_t to DType::kUInt8.
class tenzr::DynamicSliceNode
class tenzr::DynamicUpdateSliceNode
struct tenzr::ExecutableInfo
Best-effort metadata for a compiled PJRT executable (fields may be unset by some plugins).
class tenzr::ExecutionEngine
Compiles and executes tensor graphs, dispatching work through the hardware manager and JIT cache.
struct tenzr::ExecutionResult
Result of executing a graph, holding device-resident buffers plus lazily materialized host storage for its outputs.
struct tenzr::float16
class tenzr::GatherNode
Gather slices of an operand at the given indices.
class tenzr::HardwareManager
Owns the loaded PJRT plugin and client, exposing device enumeration and platform metadata.
class tenzr::JitCache
Process-wide cache of compiled executables keyed by namespaced structural hashes.
class tenzr::MatmulNode
Matrix multiplication of two operands.
class tenzr::MemoryPool
Process-wide cache of reusable PinnedBuffer allocations, keyed by size.
class tenzr::Mesh
Named grid of devices defining axes used by sharding specifications.
class tenzr::MulNode
Elementwise multiplication of two operands.
class tenzr::NamedSharding
Pairs a device Mesh with a PartitionSpec to describe a tensor layout.
struct tenzr::NetworkParameters
Latency and bandwidth constants of the modeled network.
class tenzr::Node
struct tenzr::OpDef
class tenzr::OpRegistrationBuilder
class tenzr::OpRegistry
Process-wide registry of custom operator definitions, keyed by name.
class tenzr::PadNode
Pad an operand with a fill value at the edges and between elements.
class tenzr::PartitionSpec
Per-dimension list of mesh axis names describing how a tensor is partitioned.
class tenzr::PinnedBuffer
class tenzr::PjrtProfiler
Drives the optional PJRT profiler extension and captures a serialized XPlane profile.
class tenzr::ReduceNode
class tenzr::ReduceWindowNode
class tenzr::ReluNode
Elementwise rectified linear unit.
class tenzr::ReshapeNode
View of an operand reshaped to a new shape.
class tenzr::ScatterNode
class tenzr::Shape
Shape of an array: the ordered extents of its dimensions.
class tenzr::ShardingSpec
class tenzr::SigmoidNode
Elementwise logistic sigmoid.
struct tenzr::Slice
Per-axis slicing bounds (start, stop, step) used to restrict arrays and layouts.
class tenzr::SliceNode
View of an operand restricted by per-axis slice bounds.
class tenzr::StridedLayout
class tenzr::SubNode
Elementwise subtraction of two operands.
class tenzr::TenzrException
Exception type produced by TENZR_THROW and TENZR_CHECK, carrying a formatted message.
class tenzr::TorusCostModel
Analytic cost model comparing torus and ring all-reduce times.
struct tenzr::TorusDimensions
Extents of a three-dimensional torus network.
class tenzr::TransposeNode
View of an operand with its dimensions reordered by a permutation.
class tenzr::UFunc
class tenzr::UFuncRegistry
Process-wide registry of named ufuncs, including the standard built-ins.
class tenzr::VariableNode

Types

Name
enum class LogLevel
enum class uint8_t DType
enum class uint8_t CastingMode
enum class NodeKind
enum class ReduceOp
enum class OpCategory
enum class ShardingType
enum class UFuncOp
using std::function< Shape(const std::vector< Shape > &)> ShapeInferenceFn
using std::function< DType(const std::vector< DType > &)> DTypeInferenceFn
Computes an output dtype from the input dtypes.
using std::function< std::string(const std::string &result_name, const std::string &result_type, const std::vector< std::string > &input_names, const std::vector< std::string > &input_types)> EmitFn
Emits the StableHLO text that computes this operator.
using Array Tensor
Backwards-compatibility alias for canonical tenzr::Array.

Functions

Name
LogLevel GetInitialLogLevel()
LogLevel & CurrentLogLevel()
void SetLogLevel(LogLevel level)
uint64_t ComputeAstHash(const std::shared_ptr< Node > & node)
Array array(const std::vector< float > & data)
Create a 1-D array from data.
Array array(const std::vector< float > & data, Shape shape)
Create an array of shape by copying data.
Array array(std::initializer_list< float > data)
Create a 1-D array from an initializer list.
Array array(std::initializer_list< float > data, Shape shape)
Create an array of shape from an initializer list.
Array array(std::initializer_list< std::initializer_list< float > > matrix_data)
Create a 2-D array from a nested initializer list.
Array Matrix(std::initializer_list< std::initializer_list< float > > m)
Create a 2-D array from a nested initializer list.
Array Zeros(Shape shape, DType dtype =DType::kFloat32)
Create a zero-filled array of shape.
Array Ones(Shape shape, DType dtype =DType::kFloat32)
Create a one-filled array of shape.
Array Full(Shape shape, double value, DType dtype =DType::kFloat32)
Create an array of shape filled with value.
Array Sum(const Array & a, std::optional< std::vector< int64_t > > dims =std::nullopt, bool keepdims =false)
Sum a over dims, or all dimensions when nullopt.
Array Mean(const Array & a, std::optional< std::vector< int64_t > > dims =std::nullopt, bool keepdims =false)
Arithmetic mean of a over dims, or all dimensions when nullopt.
Array Max(const Array & a, std::optional< std::vector< int64_t > > dims =std::nullopt, bool keepdims =false)
Maximum of a over dims, or all dimensions when nullopt.
Array Min(const Array & a, std::optional< std::vector< int64_t > > dims =std::nullopt, bool keepdims =false)
Minimum of a over dims, or all dimensions when nullopt.
Array Prod(const Array & a, std::optional< std::vector< int64_t > > dims =std::nullopt, bool keepdims =false)
Product of a over dims, or all dimensions when nullopt.
Array Arange(float start, float stop, float step =1.0f)
Create a 1-D range [start, stop) sampled with step.
Array Eye(int64_t n, DType dtype =DType::kFloat32)
Create an n by n identity matrix.
Array Divide(const Array & a, const Array & b)
Array Matmul(const Array & a, const Array & b)
Array Reshape(const Array & a, Shape new_shape)
Array Relu(const Array & a)
Array sigmoid(const Array & a)
Array tanh(const Array & a)
Array Exp(const Array & a)
Array Log(const Array & a)
Array Abs(const Array & a)
Array Neg(const Array & a)
Array Sin(const Array & a)
Array Cos(const Array & a)
Array Sqrt(const Array & a)
Array Rsqrt(const Array & a)
Array Ceil(const Array & a)
Array Floor(const Array & a)
Array Round(const Array & a)
Array Sign(const Array & a)
Array Cbrt(const Array & a)
Array Tan(const Array & a)
Array Expm1(const Array & a)
Array Log1p(const Array & a)
Array IsFinite(const Array & a)
Array LogicalNot(const Array & a)
Array Silu(const Array & a)
Array Gelu(const Array & a)
Array Pow(const Array & a, const Array & b)
Array Remainder(const Array & a, const Array & b)
Array Atan2(const Array & a, const Array & b)
Array Minimum(const Array & a, const Array & b)
Array Maximum(const Array & a, const Array & b)
Array Clamp(const Array & x, const Array & min, const Array & max)
Array Select(const Array & pred, const Array & on_true, const Array & on_false)
Elementwise selection: on_true where pred holds, otherwise on_false.
Array Equal(const Array & a, const Array & b)
Array NotEqual(const Array & a, const Array & b)
Array GreaterEqual(const Array & a, const Array & b)
Array GreaterThan(const Array & a, const Array & b)
Array LessEqual(const Array & a, const Array & b)
Array LessThan(const Array & a, const Array & b)
Array operator-(const Array & a)
Array operator+(const Array & a, double s)
Array operator+(double s, const Array & a)
Array operator-(const Array & a, double s)
Array operator-(double s, const Array & a)
Array operator*(const Array & a, double s)
Array operator*(double s, const Array & a)
Array operator/(const Array & a, double s)
Array operator/(double s, const Array & a)
std::ostream & operator<<(std::ostream & os, const Array & t)
TENZR_DECLARE_NARROW_FLOAT(float4_e2m1fn )
4-bit floating-point element type (2 exponent, 1 mantissa bits).
TENZR_DECLARE_NARROW_FLOAT(float8_e3m4 )
8-bit floating-point element type (3 exponent, 4 mantissa bits).
TENZR_DECLARE_NARROW_FLOAT(float8_e4m3 )
8-bit floating-point element type (4 exponent, 3 mantissa bits).
TENZR_DECLARE_NARROW_FLOAT(float8_e4m3fn )
TENZR_DECLARE_NARROW_FLOAT(float8_e4m3fnuz )
TENZR_DECLARE_NARROW_FLOAT(float8_e4m3b11fnuz )
TENZR_DECLARE_NARROW_FLOAT(float8_e5m2 )
8-bit floating-point element type (5 exponent, 2 mantissa bits).
TENZR_DECLARE_NARROW_FLOAT(float8_e5m2fnuz )
TENZR_DECLARE_NARROW_FLOAT(float8_e8m0fnu )
TENZR_DECLARE_NARROW_FLOAT(float6_e2m3fn )
TENZR_DECLARE_NARROW_FLOAT(float6_e3m2fn )
TENZR_DECLARE_SUBBYTE_INT(int1 , int8_t )
1-bit signed integer element type.
TENZR_DECLARE_SUBBYTE_INT(uint1 , uint8_t )
1-bit unsigned integer element type.
TENZR_DECLARE_SUBBYTE_INT(int2 , int8_t )
2-bit signed integer element type.
TENZR_DECLARE_SUBBYTE_INT(uint2 , uint8_t )
2-bit unsigned integer element type.
TENZR_DECLARE_SUBBYTE_INT(int4 , int8_t )
4-bit signed integer element type.
TENZR_DECLARE_SUBBYTE_INT(uint4 , uint8_t )
4-bit unsigned integer element type.
size_t SizeOf(DType dtype)
std::string_view ToString(DType dtype)
std::string_view ToMlirType(DType dtype)
PJRT_Buffer_Type ToPjrtBufferType(DType dtype)
DType FromPjrtBufferType(PJRT_Buffer_Type type)
bool IsFloatingPoint(DType dtype)
Whether dtype is a floating-point type.
bool IsIntegral(DType dtype)
Whether dtype is an integral type.
bool IsBoolean(DType dtype)
Whether dtype is boolean.
bool IsSignedIntegral(DType dtype)
Whether dtype is a signed integral type.
bool IsUnsignedIntegral(DType dtype)
Whether dtype is an unsigned integral type.
DType PromoteTypes(DType a, DType b)
bool CanCast(DType from, DType to, CastingMode mode =CastingMode::kSafe)
template <typename T >
constexpr DType
DtypeOf()
void CollectNodesPostorder(const std::shared_ptr< Node > & root, std::vector< std::shared_ptr< Node > > & order, std::unordered_map< uint64_t, bool > & visited)
Collect a Node DAG in deterministic postorder (inputs before node, deduplicated by id).
std::vector< std::shared_ptr< Node > > CollectNodesPostorder(const std::shared_ptr< Node > & root)
Collect a Node DAG in postorder (convenience overload allocating its own visited set).
std::vector< std::shared_ptr< VariableNode > > CollectParameters(const std::shared_ptr< Node > & root)
Collect the graph's VariableNode leaves in the shared postorder (executable argument order).
std::string PjrtErrorMessage(const PJRT_Api * api, PJRT_Error * err)
Human-readable text for a PJRT error, guarded for plugins without PJRT_Error_Message.
void PjrtErrorDestroy(const PJRT_Api * api, PJRT_Error * err)
Destroy a PJRT error handle, guarded for plugins without PJRT_Error_Destroy.
PJRT_Executable * PjrtLoadedExecutableGet(const PJRT_Api * api, PJRT_LoadedExecutable * loaded)
Wrap a PJRT_LoadedExecutable as a PJRT_Executable, or nullptr when the plugin does not support it.
ExecutableInfo PjrtExecutableInfo(const PJRT_Api * api, PJRT_LoadedExecutable * loaded)
Collect the output count, fingerprint, and generated-code size; unsupported fields stay at their defaults.
const char * Version()

Types Documentation

enum LogLevel

Enumerator Value Description
kDebug 0
kInfo 1
kWarn 2
kError 3

enum DType

Enumerator Value Description
kBool
kFloat32
kFloat64
kInt32
kInt64
kFloat16
kBFloat16
kFloat8E4M3FN
kFloat8E5M2
kInt8
kUInt8
kInt16
kUInt16
kUInt32
kUInt64
kFloat8E3M4
kFloat8E4M3
kFloat8E4M3FNUZ
kFloat8E4M3B11FNUZ
kFloat8E5M2FNUZ
kFloat8E8M0FNU
kFloat6E2M3FN
kFloat6E3M2FN
kFloat4E2M1FN
kInt1
kUInt1
kInt2
kUInt2
kInt4
kUInt4

enum CastingMode

Enumerator Value Description
kNo
kEquiv
kSafe
kSameKind
kUnsafe

enum NodeKind

Enumerator Value Description
kVariable
kAdd
kMul
kSub
kDiv
kMatmul
kConvolution
kReshape
kTranspose
kSlice
kRelu
kSigmoid
kCustomOp
kConvert
kReduce
kReduceWindow
kPad
kGather
kScatter
kDynamicSlice
kDynamicUpdateSlice
kArgSort
kConcatenate

enum ReduceOp

Enumerator Value Description
kSum
kProd
kMax
kMin

enum OpCategory

Enumerator Value Description
kParameter
kConstant
kUnaryElementwise
kBinaryElementwise
kContraction
kReduction
kView
kCustom

enum ShardingType

Enumerator Value Description
kReplicated
kTiled
kManual

enum UFuncOp

Enumerator Value Description
kAdd
kSubtract
kMultiply
kDivide
kMaximum
kMinimum
kNegative
kAbsolute
kExponential
kLogarithm
kSquareRoot
kSin
kCos
kTanh
kSigmoid

using ShapeInferenceFn

using tenzr::ShapeInferenceFn = typedef std::function<Shape(const std::vector<Shape>&)>;

using DTypeInferenceFn

using tenzr::DTypeInferenceFn = typedef std::function<DType(const std::vector<DType>&)>;

Computes an output dtype from the input dtypes.

using EmitFn

using tenzr::EmitFn = typedef std::function<std::string(const std::string& result_name, const std::string& result_type, const std::vector<std::string>& input_names, const std::vector<std::string>& input_types)>;

Emits the StableHLO text that computes this operator.

using Tensor

using tenzr::Tensor = typedef Array;

Backwards-compatibility alias for canonical tenzr::Array.

Functions Documentation

function GetInitialLogLevel

inline LogLevel GetInitialLogLevel()

Return: The configured initial level.

Resolves the initial log level from the TENZR_LOG_LEVEL environment variable, defaulting to Warn.

function CurrentLogLevel

inline LogLevel & CurrentLogLevel()

Return: A mutable reference to the process-wide level.

Returns the global log level, initializing it from the environment on first use.

function SetLogLevel

inline void SetLogLevel(
    LogLevel level
)

Parameters:

  • level The new level.

Sets the process-wide log level.

function ComputeAstHash

uint64_t ComputeAstHash(
    const std::shared_ptr< Node > & node
)

Parameters:

  • node Root node of the graph.
  • node Root of the expression graph to hash.

Return:

  • Hash identifying the graph structure and constants.
  • Stable hash of the graph structure.

Compute a stable hash of an AST graph. Compute a structural FNV-1a hash of an AST rooted at node.

function array

inline Array array(
    const std::vector< float > & data
)

Create a 1-D array from data.

function array

inline Array array(
    const std::vector< float > & data,
    Shape shape
)

Create an array of shape by copying data.

function array

inline Array array(
    std::initializer_list< float > data
)

Create a 1-D array from an initializer list.

function array

inline Array array(
    std::initializer_list< float > data,
    Shape shape
)

Create an array of shape from an initializer list.

function array

inline Array array(
    std::initializer_list< std::initializer_list< float > > matrix_data
)

Create a 2-D array from a nested initializer list.

function Matrix

inline Array Matrix(
    std::initializer_list< std::initializer_list< float > > m
)

Create a 2-D array from a nested initializer list.

function Zeros

inline Array Zeros(
    Shape shape,
    DType dtype =DType::kFloat32
)

Create a zero-filled array of shape.

function Ones

inline Array Ones(
    Shape shape,
    DType dtype =DType::kFloat32
)

Create a one-filled array of shape.

function Full

inline Array Full(
    Shape shape,
    double value,
    DType dtype =DType::kFloat32
)

Create an array of shape filled with value.

function Sum

inline Array Sum(
    const Array & a,
    std::optional< std::vector< int64_t > > dims =std::nullopt,
    bool keepdims =false
)

Sum a over dims, or all dimensions when nullopt.

function Mean

inline Array Mean(
    const Array & a,
    std::optional< std::vector< int64_t > > dims =std::nullopt,
    bool keepdims =false
)

Arithmetic mean of a over dims, or all dimensions when nullopt.

function Max

inline Array Max(
    const Array & a,
    std::optional< std::vector< int64_t > > dims =std::nullopt,
    bool keepdims =false
)

Maximum of a over dims, or all dimensions when nullopt.

function Min

inline Array Min(
    const Array & a,
    std::optional< std::vector< int64_t > > dims =std::nullopt,
    bool keepdims =false
)

Minimum of a over dims, or all dimensions when nullopt.

function Prod

inline Array Prod(
    const Array & a,
    std::optional< std::vector< int64_t > > dims =std::nullopt,
    bool keepdims =false
)

Product of a over dims, or all dimensions when nullopt.

function Arange

inline Array Arange(
    float start,
    float stop,
    float step =1.0f
)

Create a 1-D range [start, stop) sampled with step.

function Eye

inline Array Eye(
    int64_t n,
    DType dtype =DType::kFloat32
)

Create an n by n identity matrix.

function Divide

inline Array Divide(
    const Array & a,
    const Array & b
)

function Matmul

inline Array Matmul(
    const Array & a,
    const Array & b
)

function Reshape

inline Array Reshape(
    const Array & a,
    Shape new_shape
)

function Relu

inline Array Relu(
    const Array & a
)

function sigmoid

inline Array sigmoid(
    const Array & a
)

function tanh

inline Array tanh(
    const Array & a
)

function Exp

inline Array Exp(
    const Array & a
)

function Log

inline Array Log(
    const Array & a
)

function Abs

inline Array Abs(
    const Array & a
)

function Neg

inline Array Neg(
    const Array & a
)

function Sin

inline Array Sin(
    const Array & a
)

function Cos

inline Array Cos(
    const Array & a
)

function Sqrt

inline Array Sqrt(
    const Array & a
)

function Rsqrt

inline Array Rsqrt(
    const Array & a
)

function Ceil

inline Array Ceil(
    const Array & a
)

function Floor

inline Array Floor(
    const Array & a
)

function Round

inline Array Round(
    const Array & a
)

function Sign

inline Array Sign(
    const Array & a
)

function Cbrt

inline Array Cbrt(
    const Array & a
)

function Tan

inline Array Tan(
    const Array & a
)

function Expm1

inline Array Expm1(
    const Array & a
)

function Log1p

inline Array Log1p(
    const Array & a
)

function IsFinite

inline Array IsFinite(
    const Array & a
)

function LogicalNot

inline Array LogicalNot(
    const Array & a
)

function Silu

inline Array Silu(
    const Array & a
)

function Gelu

inline Array Gelu(
    const Array & a
)

function Pow

inline Array Pow(
    const Array & a,
    const Array & b
)

function Remainder

inline Array Remainder(
    const Array & a,
    const Array & b
)

function Atan2

inline Array Atan2(
    const Array & a,
    const Array & b
)

function Minimum

inline Array Minimum(
    const Array & a,
    const Array & b
)

function Maximum

inline Array Maximum(
    const Array & a,
    const Array & b
)

function Clamp

inline Array Clamp(
    const Array & x,
    const Array & min,
    const Array & max
)

function Select

inline Array Select(
    const Array & pred,
    const Array & on_true,
    const Array & on_false
)

Elementwise selection: on_true where pred holds, otherwise on_false.

function Equal

inline Array Equal(
    const Array & a,
    const Array & b
)

function NotEqual

inline Array NotEqual(
    const Array & a,
    const Array & b
)

function GreaterEqual

inline Array GreaterEqual(
    const Array & a,
    const Array & b
)

function GreaterThan

inline Array GreaterThan(
    const Array & a,
    const Array & b
)

function LessEqual

inline Array LessEqual(
    const Array & a,
    const Array & b
)

function LessThan

inline Array LessThan(
    const Array & a,
    const Array & b
)

function operator-

inline Array operator-(
    const Array & a
)

function operator+

inline Array operator+(
    const Array & a,
    double s
)

function operator+

inline Array operator+(
    double s,
    const Array & a
)

function operator-

inline Array operator-(
    const Array & a,
    double s
)

function operator-

inline Array operator-(
    double s,
    const Array & a
)

function operator*

inline Array operator*(
    const Array & a,
    double s
)

function operator*

inline Array operator*(
    double s,
    const Array & a
)

function operator/

inline Array operator/(
    const Array & a,
    double s
)

function operator/

inline Array operator/(
    double s,
    const Array & a
)

function operator<<

std::ostream & operator<<(
    std::ostream & os,
    const Array & t
)

function TENZR_DECLARE_NARROW_FLOAT

TENZR_DECLARE_NARROW_FLOAT(
    float4_e2m1fn 
)

4-bit floating-point element type (2 exponent, 1 mantissa bits).

function TENZR_DECLARE_NARROW_FLOAT

TENZR_DECLARE_NARROW_FLOAT(
    float8_e3m4 
)

8-bit floating-point element type (3 exponent, 4 mantissa bits).

function TENZR_DECLARE_NARROW_FLOAT

TENZR_DECLARE_NARROW_FLOAT(
    float8_e4m3 
)

8-bit floating-point element type (4 exponent, 3 mantissa bits).

function TENZR_DECLARE_NARROW_FLOAT

TENZR_DECLARE_NARROW_FLOAT(
    float8_e4m3fn 
)

8-bit finite-only floating-point element type (4 exponent, 3 mantissa bits).

function TENZR_DECLARE_NARROW_FLOAT

TENZR_DECLARE_NARROW_FLOAT(
    float8_e4m3fnuz 
)

8-bit finite-only floating-point element type (4 exponent, 3 mantissa bits) with an unsigned zero.

function TENZR_DECLARE_NARROW_FLOAT

TENZR_DECLARE_NARROW_FLOAT(
    float8_e4m3b11fnuz 
)

8-bit finite-only floating-point element type (4 exponent, 3 mantissa bits), bias-11 exponent, and an unsigned zero.

function TENZR_DECLARE_NARROW_FLOAT

TENZR_DECLARE_NARROW_FLOAT(
    float8_e5m2 
)

8-bit floating-point element type (5 exponent, 2 mantissa bits).

function TENZR_DECLARE_NARROW_FLOAT

TENZR_DECLARE_NARROW_FLOAT(
    float8_e5m2fnuz 
)

8-bit finite-only floating-point element type (5 exponent, 2 mantissa bits) with an unsigned zero.

function TENZR_DECLARE_NARROW_FLOAT

TENZR_DECLARE_NARROW_FLOAT(
    float8_e8m0fnu 
)

8-bit finite-only scale element type (8 exponent, 0 mantissa bits) with an unsigned zero.

function TENZR_DECLARE_NARROW_FLOAT

TENZR_DECLARE_NARROW_FLOAT(
    float6_e2m3fn 
)

6-bit finite-only floating-point element type (2 exponent, 3 mantissa bits).

function TENZR_DECLARE_NARROW_FLOAT

TENZR_DECLARE_NARROW_FLOAT(
    float6_e3m2fn 
)

6-bit finite-only floating-point element type (3 exponent, 2 mantissa bits).

function TENZR_DECLARE_SUBBYTE_INT

TENZR_DECLARE_SUBBYTE_INT(
    int1 ,
    int8_t 
)

1-bit signed integer element type.

function TENZR_DECLARE_SUBBYTE_INT

TENZR_DECLARE_SUBBYTE_INT(
    uint1 ,
    uint8_t 
)

1-bit unsigned integer element type.

function TENZR_DECLARE_SUBBYTE_INT

TENZR_DECLARE_SUBBYTE_INT(
    int2 ,
    int8_t 
)

2-bit signed integer element type.

function TENZR_DECLARE_SUBBYTE_INT

TENZR_DECLARE_SUBBYTE_INT(
    uint2 ,
    uint8_t 
)

2-bit unsigned integer element type.

function TENZR_DECLARE_SUBBYTE_INT

TENZR_DECLARE_SUBBYTE_INT(
    int4 ,
    int8_t 
)

4-bit signed integer element type.

function TENZR_DECLARE_SUBBYTE_INT

TENZR_DECLARE_SUBBYTE_INT(
    uint4 ,
    uint8_t 
)

4-bit unsigned integer element type.

function SizeOf

size_t SizeOf(
    DType dtype
)

Parameters:

  • dtype The scalar type.
  • dtype Element type.

Return:

  • The element size in bytes.
  • Size in bytes.

Size in bytes of a single element of dtype. Byte width of a scalar of dtype.

function ToString

std::string_view ToString(
    DType dtype
)

Parameters:

  • dtype The scalar type.
  • dtype Element type.

Return:

  • The name.
  • Dtype name, or "unknown" for an unrecognized value.

Canonical lowercase name of dtype, such as "float32". Canonical lowercase name of dtype.

function ToMlirType

std::string_view ToMlirType(
    DType dtype
)

Parameters:

  • dtype The scalar type.
  • dtype Element type.

Return:

  • The MLIR type string.
  • MLIR type string such as "f32".

MLIR type spelling for dtype, such as "f32". MLIR element type corresponding to dtype.

function ToPjrtBufferType

PJRT_Buffer_Type ToPjrtBufferType(
    DType dtype
)

Parameters:

  • dtype The scalar type.
  • dtype Element type.

Return:

  • The corresponding PJRT_Buffer_Type.
  • The corresponding PJRT_Buffer_Type.

Map dtype to its PJRT buffer element type. Map a DType to its PJRT buffer type.

function FromPjrtBufferType

DType FromPjrtBufferType(
    PJRT_Buffer_Type type
)

Parameters:

  • type The PJRT buffer type.
  • type PJRT buffer type.

Return:

  • The corresponding DType.
  • The corresponding DType.

Map a PJRT buffer element type back to a Tenzr DType. Map a PJRT buffer type back to a DType.

function IsFloatingPoint

bool IsFloatingPoint(
    DType dtype
)

Whether dtype is a floating-point type.

Parameters:

  • dtype Element type.

Return: true for float, bfloat, and 8-bit float types.

Whether dtype is one of the floating-point types.

function IsIntegral

bool IsIntegral(
    DType dtype
)

Whether dtype is an integral type.

Parameters:

  • dtype Element type.

Return: true for signed and unsigned integer types.

Whether dtype is one of the integer types.

function IsBoolean

bool IsBoolean(
    DType dtype
)

Whether dtype is boolean.

Parameters:

  • dtype Element type.

Return: true for DType::Bool.

Whether dtype is boolean.

function IsSignedIntegral

bool IsSignedIntegral(
    DType dtype
)

Whether dtype is a signed integral type.

Parameters:

  • dtype Element type.

Return: true for int8/16/32/64.

Whether dtype is a signed integer type.

function IsUnsignedIntegral

bool IsUnsignedIntegral(
    DType dtype
)

Whether dtype is an unsigned integral type.

Parameters:

  • dtype Element type.

Return: true for uint8/16/32/64.

Whether dtype is an unsigned integer type.

function PromoteTypes

DType PromoteTypes(
    DType a,
    DType b
)

Parameters:

  • a First operand dtype.
  • b Second operand dtype.
  • a Left operand type.
  • b Right operand type.

Return:

  • The promoted dtype.
  • The promoted type, throwing when no implicit path exists (8-bit floats).

Result dtype of a Python/NumPy-style type promotion between a and b. Determine the result type of a binary operation on a and b following JAX/OpenXLA promotion rules.

function CanCast

bool CanCast(
    DType from,
    DType to,
    CastingMode mode =CastingMode::kSafe
)

Parameters:

  • from Source dtype.
  • to Destination dtype.
  • mode Casting rule.
  • from Source type.
  • to Destination type.
  • mode Casting safety level.

Return:

  • true if the cast is allowed.
  • true when the cast is allowed.

Whether a value of from may be cast to to under mode. Test whether a cast from from to to is permitted under mode.

function DtypeOf

template <typename T >
inline constexpr DType DtypeOf()

Template Parameters:

  • T A supported C++ arithmetic type.

Return: The matching DType.

Compile-time DType for the C++ type T.

function CollectNodesPostorder

void CollectNodesPostorder(
    const std::shared_ptr< Node > & root,
    std::vector< std::shared_ptr< Node > > & order,
    std::unordered_map< uint64_t, bool > & visited
)

Collect a Node DAG in deterministic postorder (inputs before node, deduplicated by id).

function CollectNodesPostorder

std::vector< std::shared_ptr< Node > > CollectNodesPostorder(
    const std::shared_ptr< Node > & root
)

Collect a Node DAG in postorder (convenience overload allocating its own visited set).

function CollectParameters

std::vector< std::shared_ptr< VariableNode > > CollectParameters(
    const std::shared_ptr< Node > & root
)

Collect the graph's VariableNode leaves in the shared postorder (executable argument order).

function PjrtErrorMessage

inline std::string PjrtErrorMessage(
    const PJRT_Api * api,
    PJRT_Error * err
)

Human-readable text for a PJRT error, guarded for plugins without PJRT_Error_Message.

function PjrtErrorDestroy

inline void PjrtErrorDestroy(
    const PJRT_Api * api,
    PJRT_Error * err
)

Destroy a PJRT error handle, guarded for plugins without PJRT_Error_Destroy.

function PjrtLoadedExecutableGet

inline PJRT_Executable * PjrtLoadedExecutableGet(
    const PJRT_Api * api,
    PJRT_LoadedExecutable * loaded
)

Wrap a PJRT_LoadedExecutable as a PJRT_Executable, or nullptr when the plugin does not support it.

function PjrtExecutableInfo

inline ExecutableInfo PjrtExecutableInfo(
    const PJRT_Api * api,
    PJRT_LoadedExecutable * loaded
)

Collect the output count, fingerprint, and generated-code size; unsupported fields stay at their defaults.

function Version

const char * Version()

Return: Version string, e.g. "0.0.17".

Return the linked library's semantic version string.