Skip to content

Tensor ​

tensor.tensor ​

The tensor namespace record — from "host-tensor" import tensor binds

the whole surface at once (each field is the qualified-name string the op declarations export, so tensor.matmul(a, b) dispatches through call_host exactly like the per-name imports do).

tensor.add ​

elementwise a + b (numpy-style broadcasting).

Signature: tensor.add : (Tensor * Tensor) -> Tensor

tensor.add_backward ​

add_backward(a, b, grad_out) -> {a: da, b: db}, each unbroadcast to

the operand's shape.

Signature: tensor.add_backward : (Tensor * Tensor * Tensor) -> Value

tensor.batch_norm ​

batch_norm(input, gamma, beta, mean, var, eps?) — variadic; null

eps selects the 1e-5 default.

Signature: tensor.batch_norm : Value... -> Tensor

tensor.batch_norm_backward ​

batch_norm_backward(input, gamma, beta, mean, var, grad_out, eps?) —

primal signature + upstream grad → {input, gamma, beta} grads.

Signature: tensor.batch_norm_backward : Value... -> Value

tensor.concat ​

xs joined along axis (same rank, other axes equal).

Signature: tensor.concat : (Array * Int) -> Tensor

tensor.concat_backward ​

concat_backward(xs, axis, grad_out) -> {xs: per-input slices}.

Signature: tensor.concat_backward : (Array * Int * Tensor) -> Value

tensor.conv2d ​

conv2d(input, weight, bias?, stride?, padding?, groups?) — variadic;

null at an optional position selects the default (see the header).

Signature: tensor.conv2d : Value... -> Tensor

tensor.conv2d_backward ​

conv2d_backward(input, weight, grad_out, bias?, stride?, padding?,

groups?) — required primal args, then grad_out, then the primal's optionals in order; returns {input, weight, bias?}.

Signature: tensor.conv2d_backward : Value... -> Value

tensor.derive ​

the adjoint op name registered for name (qualified or bare local), or null.

Signature: tensor.derive : String -> Value

tensor.div ​

elementwise a / b (numpy-style broadcasting).

Signature: tensor.div : (Tensor * Tensor) -> Tensor

tensor.div_backward ​

div_backward(a, b, grad_out): da = g/b, db = −g·a/b², unbroadcast.

Signature: tensor.div_backward : (Tensor * Tensor * Tensor) -> Value

tensor.from_list ​

a tensor whose flat row-major data is xs' nested number arrays (ragged rejected).

Signature: tensor.from_list : Array -> Tensor

tensor.matmul ​

(m×k)·(k×n) dense matrix product; rank-3 sides batch over B (batch broadcasts).

Signature: tensor.matmul : (Tensor * Tensor) -> Tensor

tensor.matmul_backward ​

matmul_backward(a, b, grad_out): da = g·bᵀ, db = aᵀ·g per batch,

unbroadcast over B to each operand's shape.

Signature: tensor.matmul_backward : (Tensor * Tensor * Tensor) -> Value

tensor.max_pool ​

max_pool(input, kernel, stride?) — variadic; null stride selects

the kernel as the stride. Floor mode: trailing partial windows drop.

Signature: tensor.max_pool : Value... -> Tensor

tensor.max_pool_backward ​

max_pool_backward(input, grad_out, kernel, stride?, padding?):

each grad scatters to its window's argmax; returns {input}.

Signature: tensor.max_pool_backward : Value... -> Value

tensor.mul ​

elementwise a * b (numpy-style broadcasting).

Signature: tensor.mul : (Tensor * Tensor) -> Tensor

tensor.mul_backward ​

mul_backward(a, b, grad_out): da = g·b, db = g·a, unbroadcast.

Signature: tensor.mul_backward : (Tensor * Tensor * Tensor) -> Value

tensor.ones ​

a tensor of shape filled with 1.0.

Signature: tensor.ones : (List Int) -> Tensor

tensor.reshape ​

t re-labeled under shape (product must equal the element count).

Signature: tensor.reshape : (Tensor * (List Int)) -> Tensor

tensor.reshape_backward ​

reshape_backward(input, shape, grad_out) -> {input}.

Signature: tensor.reshape_backward : (Tensor * (List Int) * Tensor) -> Value

tensor.shape ​

the extent-per-axis list of tensor t.

Signature: tensor.shape : Tensor -> (List Int)

tensor.sub ​

elementwise a - b (numpy-style broadcasting).

Signature: tensor.sub : (Tensor * Tensor) -> Tensor

tensor.sub_backward ​

sub_backward(a, b, grad_out): da = g, db = −g, unbroadcast.

Signature: tensor.sub_backward : (Tensor * Tensor * Tensor) -> Value

tensor.to_list ​

the nested number arrays for tensor t (inverse of from_list).

Signature: tensor.to_list : Tensor -> Array

tensor.transpose ​

t with axes d0/d1 swapped.

Signature: tensor.transpose : (Tensor * Int * Int) -> Tensor

tensor.transpose_backward ​

transpose_backward(input, d0, d1, grad_out) -> {input}.

Signature: tensor.transpose_backward : (Tensor * Int * Int * Tensor) -> Value

tensor.zeros ​

a tensor of shape filled with 0.0.

Signature: tensor.zeros : (List Int) -> Tensor