Nx_cSourceinclude Nx_core.Backend_intf.SOpaque tensor handle.
'a is the OCaml element type; 'b tags the dtype.
Backend execution context. Carries any state required by the implementation (memory pools, command queues, ...).
Return the view tracker for t.
Element type of t.
Return the raw buffer of t.
Allocate a buffer of size_in_elements elements of dtype.
Tensor containing a single scalar value.
Tensor containing the elements of array. The array must be contiguous.
Compare <. Returns 0 or 1 as uint8.
Compare <>. Returns 0 or 1 as uint8.
Select from if_true or if_false based on a boolean tensor.
Sum over axes. Keeps reduced dimensions if keepdims is true.
Maximum over axes. Keeps reduced dimensions if keepdims is true.
Product over axes. Keeps reduced dimensions if keepdims is true.
val op_associative_scan :
axis:int ->
op:[ `Sum | `Prod | `Max | `Min ] ->
('a, 'b) t ->
('a, 'b) tInclusive scan along axis using the associative operation op.
Broadcast dimensions of size 1 to a new shape.
Change the logical shape without moving data.
Slice according to the given start/stop pairs.
Flip dimensions where the boolean array is true.
Pad with fill_value using the given configuration.
Cast elements to target_dtype.
Store src into dst at the given logical indices.
val op_threefry :
(int32, Nx_core.Dtype.int32_elt) t ->
(int32, Nx_core.Dtype.int32_elt) t ->
(int32, Nx_core.Dtype.int32_elt) tThreefry random number generator.
Gather elements from data along axis using indices. Output shape matches indices. Ranks of data and indices must match. Sizes of indices dims != axis must be <= data corresponding dims.
val op_scatter :
?mode:[ `Set | `Add ] ->
?unique_indices:bool ->
('a, 'b) t ->
(int32, Nx_core.Dtype.int32_elt) t ->
('a, 'b) t ->
int ->
('a, 'b) tScatter updates into a new tensor shaped like data_template along axis using indices. Returns a new tensor.
mode specifies how to handle duplicate indices:`Set (default): last update wins`Add: accumulate updates at duplicate indicesunique_indices: hint that indices are unique (optimization)val op_unfold :
('a, 'b) t ->
kernel_size:int array ->
stride:int array ->
dilation:int array ->
padding:(int * int) array ->
('a, 'b) tUnfold (im2col) operation. Extracts sliding local blocks from a batched input tensor. For an input of shape (N, C, *spatial_dims), produces output of shape (N, C * prod(kernel_size), L) where L is the number of blocks. Works for any number of spatial dimensions.
val op_fold :
('a, 'b) t ->
output_size:int array ->
kernel_size:int array ->
stride:int array ->
dilation:int array ->
padding:(int * int) array ->
('a, 'b) tFold (col2im) operation. Combines an array of sliding local blocks into a tensor. For an input of shape (N, C * prod(kernel_size), L), produces output of shape (N, C, *output_size). Inverse of unfold. Overlapping values are summed. Works for any number of spatial dimensions.
Matrix multiplication. For 2D tensors, computes standard matrix multiplication. For higher dimensions, performs batched matrix multiplication on the last two dimensions, broadcasting batch dimensions as needed. The last dimension of the first tensor must match the second-to-last dimension of the second tensor.
Compute the discrete Fourier transform (DFT) of the input tensor.
Compute the inverse discrete Fourier transform (IDFT) of the input tensor.
val op_rfft :
(float, 'a) t ->
dtype:(Complex.t, 'b) Nx_core.Dtype.t ->
axes:int array ->
(Complex.t, 'b) tCompute the real-valued discrete Fourier transform (RDFT) of the input tensor.
val op_irfft :
(Complex.t, 'a) t ->
dtype:(float, 'b) Nx_core.Dtype.t ->
axes:int array ->
s:int array option ->
(float, 'b) tCompute the inverse real-valued discrete Fourier transform (IRDFT) of the input tensor.
Cholesky decomposition of a positive-definite matrix.
upper: If true, returns upper triangular factor; else lower (default).QR decomposition.
reduced: If true (default), returns economy/reduced QR; else full QR.val op_svd :
full_matrices:bool ->
('a, 'b) t ->
('a, 'b) t * (float, Nx_core.Dtype.float64_elt) t * ('a, 'b) tSingular value decomposition.
full_matrices: If false (default), returns thin SVD; else full.val op_eig :
vectors:bool ->
('a, 'b) t ->
(Complex.t, Nx_core.Dtype.complex64_elt) t
* (Complex.t, Nx_core.Dtype.complex64_elt) t optionGeneral eigenvalue decomposition.
vectors: If true (default), computes eigenvectors.val op_eigh :
vectors:bool ->
('a, 'b) t ->
(float, Nx_core.Dtype.float64_elt) t * ('a, 'b) t optionSymmetric/Hermitian eigenvalue decomposition.
vectors: If true (default), computes eigenvectors.val op_triangular_solve :
upper:bool ->
transpose:bool ->
unit_diag:bool ->
('a, 'b) t ->
('a, 'b) t ->
('a, 'b) tSolve triangular system A*x = b or A^T*x = b.
upper: If true, A is upper triangular; else lower.transpose: If true, solve A^T*x = b; else A*x = b.unit_diag: If true, assume diagonal of A is all 1s.Create a strided view of the input tensor with the given shape, strides (in elements), and offset (in elements). Backends that support arbitrary strided views (e.g., native with Bigarray) can implement this as zero-copy. Other backends may fall back to copying data if necessary. Raises if the view would access out-of-bounds memory.