tenzr::python¶
Namespaces¶
| Name |
|---|
| tenzr::python::dlpack_abi |
Functions¶
| Name | |
|---|---|
| template <typename Nd > Array |
ArrayFromNdarray(const Nd & nd, std::optional< DType > dtype_opt) Build a Tenzr Array from a contiguous buffer-protocol ndarray view. |
| bool | TryMlDtypeFromName(const std::string & name, DType & out) |
| Array | PyToArray(nb::handle obj, std::optional< DType > dtype_opt =std::nullopt) |
| nb::object | ArrayToNdarray(Array a, nb::handle owner) |
| DType | PromotedBinaryDtype(const Array & a, nb::handle other, bool force_float) |
| template <typename Op > Array |
BinaryArith(const Array & a, nb::handle other, bool force_float, Op op) |
| template <typename Cmp > Array |
BinaryCmp(const Array & a, nb::handle other, Cmp cmp) |
| Array | ArrayGetitem(const Array & a_in, nb::handle key) |
| std::vector< int64_t > | ParseAxes(nb::handle axis) |
| Array | TryFromDlpackZerocopy(nb::handle obj) |
| nb::object | ElementToPy(const void * p, DType dt) Convert one host element to a Python scalar with exact dtype semantics. |
| nb::object | BuildNestedList(const uint8_t * base, const StridedLayout & lay, const Array & a, size_t dim, int64_t offset, size_t elem) |
| nb::object | ArrayTolist(const Array & a_orig) NumPy-free tolist(): materialize, then build a nested Python list from host memory. |
| nb::object | ArrayScalar(const Array & a) Read the single element of a 1-element Array as a Python scalar (NumPy/JAX item() semantics; C++ cousin: Array::item |
| std::string | ArrayRepr(const Array & a) |
| void | BindDTypeEnum(nb::module_ & m) |
| void | BindShape(nb::module_ & m) |
| void | BindArrayModuleFunctions(nb::module_ & m) |
| void | BindArray(nb::module_ & m) Register the Array type and its NumPy-style API surface. |
| void | BindTransforms(nb::module_ & m) Register jit, grad, vjp, jvp, vmap, and related transforms. |
| void | BindPlax(nb::module_ & m) Register the plax primitive namespace. |
| void | BindRandom(nb::module_ & m) Register the random namespace and functional PRNG distributions. |
| void | BindSharding(nb::module_ & m) Register mesh, PartitionSpec, and NamedSharding bindings. |
| void | BindScipy(nb::module_ & m) Register the scipy special/linalg/optimize namespace. |
| void | BindProfiler(nb::module_ & m) Register the profiler and trace-export bindings. |
| nb::dlpack::dtype | ToDlpackDtype(DType dt) |
| DType | FromDlpackDtype(nb::dlpack::dtype d) |
| double | ReadScalarAsDouble(const void * ptr, DType dt) Read the first element of a host buffer as a double (used for the tracing scalar fast-path). |
| DType | PythonScalarDtype(nb::handle obj) Convert a Python scalar to the "weak" DType used for JAX-style promotion. Python bool -> Bool, int -> Int32, float -> kFloat32 (weak typing). |
| DType | DefaultScalarDtype(nb::handle obj) DType for a Python scalar when no explicit dtype is requested (NumPy-like defaults: bool->Bool, int->Int64, float->Float64). |
Functions Documentation¶
function ArrayFromNdarray¶
Build a Tenzr Array from a contiguous buffer-protocol ndarray view.
function TryMlDtypeFromName¶
function PyToArray¶
function ArrayToNdarray¶
function PromotedBinaryDtype¶
function BinaryArith¶
template <typename Op >
inline Array BinaryArith(
const Array & a,
nb::handle other,
bool force_float,
Op op
)
function BinaryCmp¶
function ArrayGetitem¶
function ParseAxes¶
function TryFromDlpackZerocopy¶
Try to import a CPU DLPack producer with zero copy. Returns an undefined Array (is_defined() == false) when the tensor cannot be consumed zero-copy, so the caller can fall back to a NumPy-based copy.
function ElementToPy¶
Convert one host element to a Python scalar with exact dtype semantics.
function BuildNestedList¶
nb::object BuildNestedList(
const uint8_t * base,
const StridedLayout & lay,
const Array & a,
size_t dim,
int64_t offset,
size_t elem
)
function ArrayTolist¶
NumPy-free tolist(): materialize, then build a nested Python list from host memory.
function ArrayScalar¶
Read the single element of a 1-element Array as a Python scalar (NumPy/JAX item() semantics; C++ cousin: Array::item
function ArrayRepr¶
function BindDTypeEnum¶
Parameters:
- m Extension module to populate.
Register the Array type and its NumPy-style operations.
function BindShape¶
function BindArrayModuleFunctions¶
function BindArray¶
Register the Array type and its NumPy-style API surface.
Parameters:
- m Extension module to populate.
Register the Array type and its NumPy-style operations.
function BindTransforms¶
Register jit, grad, vjp, jvp, vmap, and related transforms.
Parameters:
- m Extension module to populate.
Register jit, grad, vjp, jvp, vmap, and related transforms.
function BindPlax¶
Register the plax primitive namespace.
Parameters:
- m Extension module to populate.
Register the plax primitive namespace.
function BindRandom¶
Register the random namespace and functional PRNG distributions.
Parameters:
- m Extension module to populate.
Register the random namespace and functional PRNG distributions.
function BindSharding¶
Register mesh, PartitionSpec, and NamedSharding bindings.
Parameters:
- m Extension module to populate.
Register mesh, PartitionSpec, and NamedSharding bindings.
function BindScipy¶
Register the scipy special/linalg/optimize namespace.
Parameters:
- m Extension module to populate.
Register the scipy special, linalg, and optimize namespaces.
function BindProfiler¶
Register the profiler and trace-export bindings.
Parameters:
- m Extension module to populate.
Register the profiler trace export API.
function ToDlpackDtype¶
function FromDlpackDtype¶
function ReadScalarAsDouble¶
Read the first element of a host buffer as a double (used for the tracing scalar fast-path).
function PythonScalarDtype¶
Convert a Python scalar to the "weak" DType used for JAX-style promotion. Python bool -> Bool, int -> Int32, float -> kFloat32 (weak typing).
function DefaultScalarDtype¶
DType for a Python scalar when no explicit dtype is requested (NumPy-like defaults: bool->Bool, int->Int64, float->Float64).