Skip to contents

Tensor Creation

Functions for creating and initializing tensors

nv_tensor() nv_scalar() nv_empty()
AnvilTensor
is_tensorish()
Tensor-like Objects
nv_fill()
Fill Constant
nv_iota()
Iota
nv_seq()
Sequence
nv_aten() AbstractTensor()
Abstract Tensor Class

Tensor attributes and converters

Functions for querying tensor attributes and converting them

ambiguous()
Get Ambiguity of a Tensor
dtype()
Get the data type of a tensor
shape()
Get the shape of a tensor
ndims()
Get the number of dimensions of a tensor
device()
Get the device of a tensor
platform(<AbstractTensor>)
Platform for AbstractTensor
platform()
Get the platform of a tensor or buffer
as_array()
Convert a tensor to an R array
as_raw()
Convert a tensor to a raw vector
as_dtype()
Convert to a TensorDataType
is_dtype()
Check if an object is a TensorDataType

Tensor Serialization

Functions for serializing and deserializing tensors

nv_save()
Save tensors to a file
nv_read()
Read tensors from a file
nv_serialize()
Serialize tensors to raw bytes
nv_unserialize()
Deserialize tensors from raw bytes

Type conversion and promotion

Functions for type conversion and promotion

nv_convert()
Convert Data Type
nv_bitcast_convert()
Bitcast Conversion
nv_promote_to_common()
Promote Tensors to a Common Dtype
nv_broadcast_scalars()
Broadcast Scalars to Common Shape
nv_broadcast_tensors()
Broadcast Tensors to a Common Shape
nv_broadcast_to()
Broadcast to Shape
common_dtype()
Type Promotion Rules

Tensor manipulation

Functions for reshaping and rearranging tensors

Arithmetic operations

Basic arithmetic operations on tensors

nv_add()
Addition
nv_sub()
Subtraction
nv_mul()
Multiplication
nv_div()
Division
nv_pow()
Power
nv_negate()
Negation
nv_remainder()
Remainder

Comparison operations

Element-wise comparison operations

nv_eq()
Equal
nv_ne()
Not Equal
nv_gt()
Greater Than
nv_ge()
Greater Than or Equal
nv_lt()
Less Than
nv_le()
Less Than or Equal

Mathematical functions

Mathematical and trigonometric functions

nv_abs()
Absolute Value
nv_sqrt()
Square Root
nv_rsqrt()
Reciprocal Square Root
nv_cbrt()
Cube Root
nv_exp()
Exponential
nv_expm1()
Exponential Minus One
nv_log()
Natural Logarithm
nv_log1p()
Log Plus One
nv_sine()
Sine
nv_cosine()
Cosine
nv_tan()
Tangent
nv_tanh()
Hyperbolic Tangent
nv_atan2()
Arctangent 2
nv_sign()
Sign
nv_floor()
Floor
nv_ceil()
Ceiling
nv_round()
Round
nv_logistic()
Logistic (Sigmoid)
nv_is_finite()
Is Finite

Reduction operations

Operations that reduce tensor dimensions

nv_reduce_sum()
Sum Reduction
nv_reduce_mean()
Mean Reduction
nv_reduce_prod()
Product Reduction
nv_reduce_max()
Max Reduction
nv_reduce_min()
Min Reduction
nv_reduce_any()
Any Reduction
nv_reduce_all()
All Reduction

Linear algebra

Linear algebra operations

nv_matmul()
Matrix Multiplication

Logical and bitwise operations

Logical and bitwise operations on tensors

nv_and()
Logical And
nv_or()
Logical Or
nv_xor()
Logical Xor
nv_not()
Logical Not
nv_shift_left()
Shift Left
nv_shift_right_logical()
Logical Shift Right
nv_shift_right_arithmetic()
Arithmetic Shift Right
nv_popcnt()
Population Count

Element-wise operations

Other element-wise tensor operations

nv_min()
Minimum
nv_max()
Maximum
nv_clamp()
Clamp

Control flow

Control flow operations

nv_if()
Conditional Branching
nv_while()
While Loop
nv_ifelse()
Conditional Element Selection

Random number generation

Functions for generating random numbers

nv_runif()
Sample from a Uniform Distribution
nv_rnorm()
Sample from a Normal Distribution
nv_rbinom()
Sample from a Binomial Distribution
nv_rdunif()
Sample from a Discrete Uniform Distribution
nv_rng_state()
Generate RNG State

Transformations

Code transformations

trace_fn()
Trace an R function into a Graph
gradient()
Gradient
value_and_gradient()
Value and Gradient
transform_gradient()
Transform a graph to its gradient
jit()
JIT compile a function
xla()
Ahead-of-time compile a function to XLA
jit_eval()
JIT-compile and evaluate an expression
compile_to_xla()
Trace, lower, and compile a function to an XLA executable
stablehlo()
Lower a graph to StableHLO

Debugging

Debugging utilities and tools

debug_box()
Create a Debug Box
nv_print()
Print Tensor
DebugBox()
Debug Box Class

Internal Data Structures and Functions

Internal data structures and functions

shape_abstract() ndims_abstract() dtype_abstract() ambiguous_abstract()
Abstract Properties
to_abstract()
Convert to Abstract Tensor
GraphDescriptor()
Graph Descriptor
GraphValue()
Graph Value
AnvilBox
AnvilBox
AnvilGraph()
Graph of Primitive Calls
GraphNode
Graph Node
GraphBox()
Graph Box
GraphLiteral()
Graph Literal
graph_desc_add()
Add a Primitive Call to a Graph Descriptor
local_descriptor()
Create a graph
.current_descriptor()
Get the current graph
subgraphs()
Get Subgraphs from Higher-Order Primitive
prim()
Get a Primitive
AnvilPrimitive()
AnvilPrimitive
PrimitiveCall()
Primitive Call
register_primitive()
Register a Primitive
nv_aten() AbstractTensor()
Abstract Tensor Class
ConcreteTensor()
Concrete Tensor Class
LiteralTensor()
Literal Tensor Class
IotaTensor()
Iota Tensor Class
eq_type() neq_type()
Compare AbstractTensor Types
at2vt()
Convert AbstractTensor to ValueType
vt2at()
Convert ValueType to AbstractTensor
is_tensorish()
Tensor-like Objects
Shape()
Create a Shape object

Tree utilities

Utilities for working with nested structures

flatten()
Flatten
unflatten()
Unflatten
build_tree()
Build Tree
reindex_tree()
Reindex Tree
tree_size()
Tree Size
filter_list_node()
Filter List Node

Primitives

Low-level primitive operations (nvl_* functions)

nvl_abs()
Primitive Absolute Value
nvl_add()
Primitive Addition
nvl_and()
Primitive And
nvl_atan2()
Primitive Atan2
nvl_bitcast_convert()
Primitive Bitcast Convert
nvl_broadcast_in_dim()
Primitive Broadcast
nvl_cbrt()
Primitive Cube Root
nvl_ceil()
Primitive Ceiling
nvl_clamp()
Primitive Clamp
nvl_concatenate()
Primitive Concatenate
nvl_convert()
Primitive Convert
nvl_cosine()
Primitive Cosine
nvl_div()
Primitive Division
nvl_dot_general()
Primitive Dot General
nvl_dynamic_slice()
Primitive Dynamic Slice
nvl_dynamic_update_slice()
Primitive Dynamic Update Slice
nvl_eq()
Primitive Equal
nvl_exp()
Primitive Exponential
nvl_expm1()
Primitive Exponential Minus One
nvl_fill()
Primitive Fill
nvl_floor()
Primitive Floor
nvl_gather()
Primitive Gather
nvl_ge()
Primitive Greater Equal
nvl_gt()
Primitive Greater Than
nvl_if()
Primitive If
nvl_ifelse()
Primitive Ifelse
nvl_iota()
Primitive Iota
nvl_is_finite()
Primitive Is Finite
nvl_le()
Primitive Less Equal
nvl_log()
Primitive Logarithm
nvl_log1p()
Primitive Log Plus One
nvl_logistic()
Primitive Logistic (Sigmoid)
nvl_lt()
Primitive Less Than
nvl_max()
Primitive Maximum
nvl_min()
Primitive Minimum
nvl_mul()
Primitive Multiplication
nvl_ne()
Primitive Not Equal
nvl_negate()
Primitive Negation
nvl_not()
Primitive Not
nvl_or()
Primitive Or
nvl_pad()
Primitive Pad
nvl_popcnt()
Primitive Population Count
nvl_pow()
Primitive Power
nvl_print()
Primitive Print
nvl_reduce_all()
Primitive All Reduction
nvl_reduce_any()
Primitive Any Reduction
nvl_reduce_max()
Primitive Max Reduction
nvl_reduce_min()
Primitive Min Reduction
nvl_reduce_prod()
Primitive Product Reduction
nvl_reduce_sum()
Primitive Sum Reduction
nvl_remainder()
Primitive Remainder
nvl_reshape()
Primitive Reshape
nvl_reverse()
Primitive Reverse
nvl_rng_bit_generator()
Primitive RNG Bit Generator
nvl_round()
Primitive Round
nvl_rsqrt()
Primitive Reciprocal Square Root
nvl_scatter()
Primitive Scatter
nvl_shift_left()
Primitive Shift Left
nvl_shift_right_arithmetic()
Primitive Arithmetic Shift Right
nvl_shift_right_logical()
Primitive Logical Shift Right
nvl_sign()
Primitive Sign
nvl_sine()
Primitive Sine
nvl_sqrt()
Primitive Square Root
nvl_static_slice()
Primitive Static Slice
nvl_sub()
Primitive Subtraction
nvl_tan()
Primitive Tangent
nvl_tanh()
Primitive Hyperbolic Tangent
nvl_transpose()
Primitive Transpose
nvl_while()
Primitive While Loop
nvl_xor()
Primitive Xor