TensorPlay

Latest development documentation · Updated 2026-09-08. A documentation snapshot for package 1.0.0 is not available.

On this page

Functions 545

#

as_tensor

functionFull reference ↗
tensorplay.as_tensor(data, dtype=None, device=None)[source]

Convert data into a tensor, sharing storage when possible.

If data is already a tensor with the requested dtype and device, it is returned as-is (no copy). Otherwise it is converted to the requested dtype and device.

Parameters:
  • data (tensor, list, or scalar) – Initial data for the tensor.

  • dtype (tensorplay.DType, optional) – the desired data type of the returned tensor.

  • device (tensorplay.Device, str, optional) – the device of the constructed tensor.

Example:

>>> x = tensorplay.tensor([1.0, 2.0])
>>> tensorplay.as_tensor(x) is x
True
>>> tensorplay.as_tensor([0, 1, 2], dtype=tensorplay.int64).dtype == tensorplay.int64
True
#

audio_to_tensor

functionFull reference ↗
tensorplay.audio_to_tensor(audio: object) tensorplay::Tensor

Optimized conversion for audio: (Time, Channels) -> (Channels, Time) with normalization

#

avg_pool2d

functionFull reference ↗
tensorplay.avg_pool2d(input, kernel_size, stride=[], padding=[], ceil_mode=False, count_include_pad=True, divisor_override=None, *, out=None)[source]
#

avg_pool3d

functionFull reference ↗
tensorplay.avg_pool3d(input, kernel_size, stride=[], padding=[], ceil_mode=False, count_include_pad=True, divisor_override=None, *, out=None)[source]
#

batch_norm

functionFull reference ↗
tensorplay.batch_norm(input, weight, bias, running_mean, running_var, training, momentum, eps)[source]
#

binary_cross_entropy_with_logits

functionFull reference ↗
tensorplay.binary_cross_entropy_with_logits(input, target, weight=None, pos_weight=None)[source]
#

binary_cross_entropy

functionFull reference ↗
tensorplay.binary_cross_entropy(input, target, weight=None, reduction=1, *, out=None)[source]
#

col2im

functionFull reference ↗
tensorplay.col2im(input, output_size, kernel_size, dilation=[], padding=[], stride=[], *, out=None)[source]
#

conv_depthwise3d

functionFull reference ↗
tensorplay.conv_depthwise3d(input, weight, kernel_size, bias, stride, padding, dilation)[source]
#

conv_transpose1d_grad_bias

functionFull reference ↗
tensorplay.conv_transpose1d_grad_bias(grad_output, input, weight, stride, padding, output_padding, groups, dilation)[source]
#

conv_transpose1d_grad_input

functionFull reference ↗
tensorplay.conv_transpose1d_grad_input(grad_output, input, weight, stride, padding, output_padding, groups, dilation)[source]
#

conv_transpose1d_grad_weight

functionFull reference ↗
tensorplay.conv_transpose1d_grad_weight(grad_output, input, weight, stride, padding, output_padding, groups, dilation)[source]
#

conv_transpose2d_grad_bias

functionFull reference ↗
tensorplay.conv_transpose2d_grad_bias(grad_output, input, weight, stride, padding, output_padding, groups, dilation)[source]
#

conv_transpose2d_grad_input

functionFull reference ↗
tensorplay.conv_transpose2d_grad_input(grad_output, input, weight, stride, padding, output_padding, groups, dilation)[source]
#

conv_transpose2d_grad_weight

functionFull reference ↗
tensorplay.conv_transpose2d_grad_weight(grad_output, input, weight, stride, padding, output_padding, groups, dilation)[source]
#

conv_transpose3d_grad_bias

functionFull reference ↗
tensorplay.conv_transpose3d_grad_bias(grad_output, input, weight, stride, padding, output_padding, groups, dilation)[source]
#

conv_transpose3d_grad_input

functionFull reference ↗
tensorplay.conv_transpose3d_grad_input(grad_output, input, weight, stride, padding, output_padding, groups, dilation)[source]
#

conv_transpose3d_grad_weight

functionFull reference ↗
tensorplay.conv_transpose3d_grad_weight(grad_output, input, weight, stride, padding, output_padding, groups, dilation)[source]
#

conv1d_grad_bias

functionFull reference ↗
tensorplay.conv1d_grad_bias(grad_output, input, weight, stride, padding, dilation, groups)[source]
#

conv1d_grad_input

functionFull reference ↗
tensorplay.conv1d_grad_input(grad_output, input, weight, stride, padding, dilation, groups)[source]
#

conv1d_grad_weight

functionFull reference ↗
tensorplay.conv1d_grad_weight(grad_output, input, weight, stride, padding, dilation, groups)[source]
#

conv2d_grad_bias

functionFull reference ↗
tensorplay.conv2d_grad_bias(grad_output, input, weight, stride, padding, dilation, groups)[source]
#

conv2d_grad_input

functionFull reference ↗
tensorplay.conv2d_grad_input(grad_output, input, weight, stride, padding, dilation, groups)[source]
#

conv2d_grad_weight

functionFull reference ↗
tensorplay.conv2d_grad_weight(grad_output, input, weight, stride, padding, dilation, groups)[source]
#

conv2d_relu

functionFull reference ↗
tensorplay.conv2d_relu(input, weight, bias=None, stride=[1, 1], padding=[0, 0], dilation=[1, 1], groups=1)[source]
#

conv2d

functionFull reference ↗
tensorplay.conv2d(input, weight, bias=None, stride=[1, 1], padding=[0, 0], dilation=[1, 1], groups=1)[source]
#

conv3d_grad_bias

functionFull reference ↗
tensorplay.conv3d_grad_bias(grad_output, input, weight, stride, padding, dilation, groups)[source]
#

conv3d_grad_input

functionFull reference ↗
tensorplay.conv3d_grad_input(grad_output, input, weight, stride, padding, dilation, groups)[source]
#

conv3d_grad_weight

functionFull reference ↗
tensorplay.conv3d_grad_weight(grad_output, input, weight, stride, padding, dilation, groups)[source]
#

convolution_backward_overrideable

functionFull reference ↗
tensorplay.convolution_backward_overrideable(grad_output, input, weight, stride, padding, dilation, transposed, output_padding, groups, output_mask)[source]
#

convolution_overrideable

functionFull reference ↗
tensorplay.convolution_overrideable(input, weight, bias, stride, padding, dilation, transposed, output_padding, groups)[source]
#

cross_entropy_loss

functionFull reference ↗
tensorplay.cross_entropy_loss(input, target, weight=None, reduction=1, ignore_index=-100, label_smoothing=0.0)[source]
#

custom_bwd

functionFull reference ↗
tensorplay.custom_bwd(bwd=None, *, device_type: str)[source]

Create a helper decorator for backward methods of custom autograd functions.

Autograd functions are subclasses of tensorplay.autograd.Function. Ensures that backward executes with the same autocast state as forward.

Parameters:

device_type (str) – Device type to use. ‘cuda’, ‘cpu’. The type is the same as the type attribute of a tensorplay.device. Thus, you may obtain the device type of a tensor using Tensor.device.type.

#

custom_fwd

functionFull reference ↗
tensorplay.custom_fwd(fwd=None, *, device_type: str, cast_inputs=None)[source]

Create a helper decorator for forward methods of custom autograd functions.

Autograd functions are subclasses of tensorplay.autograd.Function.

Parameters:
  • device_type (str) – Device type to use. ‘cuda’, ‘cpu’. The type is the same as the type attribute of a tensorplay.device. Thus, you may obtain the device type of a tensor using Tensor.device.type.

  • cast_inputs (tensorplay.dtype or None, optional, default=None) – If not None, when forward runs in an autocast-enabled region, casts incoming floating-point Tensors to the target dtype (non-floating-point Tensors are not affected), then executes forward with autocast disabled. If None, forward’s internal ops execute with the current autocast state.

Note

If the decorated forward is called outside an autocast-enabled region, custom_fwd is a no-op and cast_inputs has no effect.

#

embedding_bag

functionFull reference ↗
tensorplay.embedding_bag(input, indices=None, offsets=None, scale_grad_by_freq=False, mode=0, sparse=False, per_sample_weights=None, include_last_offset=False, padding_idx=None)[source]
#

fake_quantize_per_channel_affine_cachemask

functionFull reference ↗
tensorplay.fake_quantize_per_channel_affine_cachemask(input, scale, zero_point, axis, quant_min, quant_max)[source]
#

fake_quantize_per_tensor_affine_cachemask

functionFull reference ↗
tensorplay.fake_quantize_per_tensor_affine_cachemask(input, scale, zero_point, quant_min, quant_max)[source]
#

fft_fftfreq

functionFull reference ↗
tensorplay.fft_fftfreq(n, d=1.0, *, dtype=None, layout=None, device=None, pin_memory=None, out=None)[source]
#

fft_rfftfreq

functionFull reference ↗
tensorplay.fft_rfftfreq(n, d=1.0, *, dtype=None, layout=None, device=None, pin_memory=None, out=None)[source]
#

fork_rng

functionFull reference ↗
tensorplay.fork_rng(devices=None, enabled=True, _caller='fork_rng', _devices_kw='devices')[source]

Forks the RNG state: code inside the context gets a pristine RNG.

Saves the CPU RNG state on entry and restores it on exit, so random operations inside the block do not advance the outer stream. The saved state is restored

#

fractional_max_pool2d

functionFull reference ↗
tensorplay.fractional_max_pool2d(input, kernel_size, output_size, random_samples, *, out=None)[source]
#

fractional_max_pool3d

functionFull reference ↗
tensorplay.fractional_max_pool3d(input, kernel_size, output_size, random_samples, *, out=None)[source]
#

from_numpy

functionFull reference ↗
tensorplay.from_numpy(*args, **kwargs)

Overloaded function.

  1. from_numpy(ndarray: object) -> tensorplay::Tensor

  2. from_numpy(array: numpy.ndarray) -> tensorplay::Tensor

#

get_autocast_dtype

functionFull reference ↗
tensorplay.get_autocast_dtype(device_type: str = 'cuda') tensorplay._C.DType
#

get_num_threads

functionFull reference ↗
tensorplay.get_num_threads() int

Returns the number of threads used for parallelizing CPU operations

#

get_parallel_info

functionFull reference ↗
tensorplay.get_parallel_info() str

Returns a detailed string describing parallelization settings

#

get_thread_num

functionFull reference ↗
tensorplay.get_thread_num() int

Returns the current thread number (starting from 0) in the current parallel region, or 0 in the sequential region

#

gradient

functionFull reference ↗
tensorplay.gradient(input, *, spacing=None, dim=None, edge_order=1)[source]

The native binding only takes Tensor[] spacing / int[] dim; materialize python numbers into scalar tensors typed like input (a single scalar applies to every dimension).

#

in_parallel_region

functionFull reference ↗
tensorplay.in_parallel_region() bool

Checks whether the code runs in a parallel region

#

is_autocast_available

functionFull reference ↗
tensorplay.is_autocast_available(device_type: str) bool[source]

Return a bool indicating if autocast is available on device_type.

Parameters:

device_type (str) – Device type to use. Possible values are: ‘cuda’, ‘cpu’. The type is the same as the type attribute of a tensorplay.device. Thus, you may obtain the device type of a tensor using Tensor.device.type.

#

is_tensor

functionFull reference ↗
tensorplay.is_tensor(obj: Any, /) TypeIs[TensorBase][source]

Returns True if obj is a TensorPlay tensor.

Note that this function is simply doing isinstance(obj, Tensor). Using that isinstance check is better for type checking with mypy, and more explicit - so it’s recommended to use that instead of is_tensor.

Parameters:

obj (object) – Object to test

Example:

>>> x = tensorplay.tensor([1, 2, 3])
>>> tensorplay.is_tensor(x)
True
#

max_pool1d_with_indices

functionFull reference ↗
tensorplay.max_pool1d_with_indices(input, kernel_size, stride=[], padding=0, dilation=1, ceil_mode=False)[source]
#

max_pool2d_with_indices

functionFull reference ↗
tensorplay.max_pool2d_with_indices(input, kernel_size, stride=[], padding=[], dilation=[], ceil_mode=False, *, out=None)[source]
#

max_pool2d

functionFull reference ↗
tensorplay.max_pool2d(input, kernel_size, stride=[], padding=[0, 0], dilation=[1, 1], ceil_mode=False)[source]
#

max_pool3d_with_indices

functionFull reference ↗
tensorplay.max_pool3d_with_indices(input, kernel_size, stride=[], padding=[], dilation=[], ceil_mode=False, *, out=None)[source]
#

mkldnn_linear_backward_input

functionFull reference ↗
tensorplay.mkldnn_linear_backward_input(input_size, grad_output, weight)[source]
#

mkldnn_reorder_conv2d_weight

functionFull reference ↗
tensorplay.mkldnn_reorder_conv2d_weight(input, padding=0, stride=1, dilation=1, groups=1, input_size=None)[source]
#

mkldnn_reorder_conv3d_weight

functionFull reference ↗
tensorplay.mkldnn_reorder_conv3d_weight(input, padding=0, stride=1, dilation=1, groups=1, input_size=None)[source]
#

multi_margin_loss

functionFull reference ↗
tensorplay.multi_margin_loss(input, target, p=1, margin=1, weight=None, reduction=1, *, out=None)[source]
#

multilabel_margin_loss_forward

functionFull reference ↗
tensorplay.multilabel_margin_loss_forward(input, target, reduction, *, out=None)[source]
#

new_empty_strided

functionFull reference ↗
tensorplay.new_empty_strided(input, size, stride, dtype=None, layout=None, device=None, pin_memory=None)[source]
#

new_full

functionFull reference ↗
tensorplay.new_full(input, size, fill_value, dtype=None, layout=None, device=None, pin_memory=None)[source]
#

nll_loss_forward

functionFull reference ↗
tensorplay.nll_loss_forward(input, target, weight, reduction, ignore_index, *, out=None)[source]
#

nll_loss

functionFull reference ↗
tensorplay.nll_loss(input, target, weight=None, reduction=1, ignore_index=-100, *, out=None)[source]
#

nll_loss2d_forward

functionFull reference ↗
tensorplay.nll_loss2d_forward(input, target, weight, reduction, ignore_index, *, out=None)[source]
#

nll_loss2d

functionFull reference ↗
tensorplay.nll_loss2d(input, target, weight=None, reduction=1, ignore_index=-100, *, out=None)[source]
#

pad_sequence

functionFull reference ↗
tensorplay.pad_sequence(sequences, batch_first=False, padding_value=0.0, padding_side='right')[source]
#

quantized_add

functionFull reference ↗
tensorplay.quantized_add(a, b, a_scale, a_zero_point, b_scale, b_zero_point, out_scale, out_zero_point)[source]
#

quantized_clamp

functionFull reference ↗
tensorplay.quantized_clamp(input, self_scale, self_zero_point, out_scale, out_zero_point, min=None, max=None)[source]
#

quantized_conv2d_prepack

functionFull reference ↗
tensorplay.quantized_conv2d_prepack(weight, weight_scales, weight_zero_points, bias=None, transposed=False)[source]
#

quantized_conv2d_run

functionFull reference ↗
tensorplay.quantized_conv2d_run(input, weight_packed, bias_packed, weight_sizes, input_scale, input_zero_point, out_scale, out_zero_point, stride=1, padding=0, dilation=1, output_padding=0, groups=1, transposed=False, output_min=None, output_max=None)[source]
#

quantized_conv2d_unpack

functionFull reference ↗
tensorplay.quantized_conv2d_unpack(weight_packed, bias_packed, weight_sizes, transposed=False, depthwise=False)[source]
#

quantized_conv2d

functionFull reference ↗
tensorplay.quantized_conv2d(input, weight, bias, input_scale, input_zero_point, weight_scale, weight_zero_point, out_scale, out_zero_point, stride=1, padding=0, dilation=1, groups=1)[source]
#

quantized_div

functionFull reference ↗
tensorplay.quantized_div(a, b, a_scale, a_zero_point, b_scale, b_zero_point, out_scale, out_zero_point)[source]
#

quantized_linear

functionFull reference ↗
tensorplay.quantized_linear(input, weight, input_scale, input_zero_point, weight_scales, weight_zero_points, bias=None)[source]
#

quantized_mul

functionFull reference ↗
tensorplay.quantized_mul(a, b, a_scale, a_zero_point, b_scale, b_zero_point, out_scale, out_zero_point)[source]
#

quantized_sub

functionFull reference ↗
tensorplay.quantized_sub(a, b, a_scale, a_zero_point, b_scale, b_zero_point, out_scale, out_zero_point)[source]
#

rrelu_with_noise_

functionFull reference ↗
tensorplay.rrelu_with_noise_(input, noise, lower=0.125, upper=0.3333333333333333, training=False, generator=None)[source]
#

rrelu_with_noise

functionFull reference ↗
tensorplay.rrelu_with_noise(input, noise, lower=0.125, upper=0.3333333333333333, training=False, *, out=None)[source]
#

scaled_dot_product_attention

functionFull reference ↗
tensorplay.scaled_dot_product_attention(query, key, value, is_causal=False, impl=0)[source]
#

set_autocast_dtype

functionFull reference ↗
tensorplay.set_autocast_dtype(device_type: str, dtype: tensorplay._C.DType) None
#

set_default_device

functionFull reference ↗
tensorplay.set_default_device(device: Device) None[source]

Sets the default tensorplay.Tensor to be allocated on device. This does not affect factory function calls which are called with an explicit device argument. Factory calls will be performed as if they were passed device as an argument.

To only temporarily change the default device instead of setting it globally, use with tensorplay.device(device): instead.

The default device is initially cpu. If you set the default tensor device to another device (e.g., cuda) without a device index, tensors will be allocated on whatever the current device for the device type, even after tensorplay.cuda.set_device() is called.

Warning

This function imposes a slight performance cost on every Python call to the tensorplay API (not just factory functions).

Note

This doesn’t affect functions that create tensors that share the same memory as the input, like: tensorplay.from_numpy() and tensorplay.frombuffer()

Parameters:

device (tensorplay.device, str, int, or None) – the device to set as default, or None to clear the override. An integer is interpreted as an index for the current accelerator.

Example:

>>> # xdoctest: +SKIP("requires cuda, changes global state")
>>> tensorplay.get_default_device()
device(type='cpu')
>>> tensorplay.set_default_device('cuda')  # current device is 0
>>> tensorplay.get_default_device()
device(type='cuda', index=0)
>>> tensorplay.set_default_device('cuda')
>>> tensorplay.cuda.set_device('cuda:1')  # current device is 1
>>> tensorplay.get_default_device()
device(type='cuda', index=1)
>>> tensorplay.set_default_device('cuda:1')
>>> tensorplay.get_default_device()
device(type='cuda', index=1)
#

set_default_dtype

functionFull reference ↗
tensorplay.set_default_dtype(d: DType, /) None[source]

Sets the default floating point dtype to d. Supports floating point dtype as inputs. Other dtypes will cause tensorplay to raise an exception.

When TensorPlay is initialized its default floating point dtype is float32, and the intent of set_default_dtype(float64) is to facilitate NumPy-like type inference. The default floating point dtype is used to:

  1. Implicitly determine the default complex dtype. When the default floating type is float16, the default complex dtype is complex32. For float32, the default complex dtype is complex64. For float64, it is complex128. For bfloat16, an exception will be raised because there is no corresponding complex type for bfloat16.

  2. Infer the dtype for tensors constructed using Python floats or complex Python numbers. See examples below.

  3. Determine the result of type promotion between bool and integer tensors and Python floats and complex Python numbers.

Parameters:

d (tensorplay.dtype) – the floating point dtype to make the default.

Example

>>> # xdoctest: +SKIP("Other tests may have changed the default type. Can we reset it?")
>>> # initial default for floating point is float32
>>> # Python floats are interpreted as float32
>>> tensorplay.tensor([1.2, 3]).dtype
tensorplay.float32
>>> # initial default for floating point is complex64
>>> # Complex Python numbers are interpreted as complex64
>>> tensorplay.tensor([1.2, 3j]).dtype
tensorplay.complex64
>>> tensorplay.set_default_dtype(tensorplay.float64)
>>> # Python floats are now interpreted as float64
>>> tensorplay.tensor([1.2, 3]).dtype  # a new floating point tensor
tensorplay.float64
>>> # Complex Python numbers are now interpreted as complex128
>>> tensorplay.tensor([1.2, 3j]).dtype  # a new complex tensor
tensorplay.complex128
>>> tensorplay.set_default_dtype(tensorplay.float16)
>>> # Python floats are now interpreted as float16
>>> tensorplay.tensor([1.2, 3]).dtype  # a new floating point tensor
tensorplay.float16
>>> # Complex Python numbers are now interpreted as complex128
>>> tensorplay.tensor([1.2, 3j]).dtype  # a new complex tensor
tensorplay.complex32
#

set_deterministic_debug_mode

functionFull reference ↗
tensorplay.set_deterministic_debug_mode(debug_mode: int | str) None[source]

Sets the debug mode for deterministic operations.

Note

This is an alternative interface for tensorplay.use_deterministic_algorithms(). Refer to that function’s documentation for details about affected operations.

Parameters:

debug_mode (str or int) – If “default” or 0, don’t error or warn on nondeterministic operations. If “warn” or 1, warn on nondeterministic operations. If “error” or 2, error on nondeterministic operations.

#

set_float32_matmul_precision

functionFull reference ↗
tensorplay.set_float32_matmul_precision(precision: str) None[source]

Sets the internal precision of float32 matrix multiplications.

Running float32 matrix multiplications in lower precision may significantly increase performance, and in some programs the loss of precision has a negligible impact.

Supports three settings:

  • “highest”, float32 matrix multiplications use the float32 datatype (24 mantissa bits with 23 bits explicitly stored) for internal computations.

  • “high”, float32 matrix multiplications either use the TensorFloat32 datatype (10 mantissa bits explicitly stored) or treat each float32 number as the sum of two bfloat16 numbers (approximately 16 mantissa bits with 14 bits explicitly stored), if the appropriate fast matrix multiplication algorithms are available. Otherwise float32 matrix multiplications are computed as if the precision is “highest”. See below for more information on the bfloat16 approach.

  • “medium”, float32 matrix multiplications use the bfloat16 datatype (8 mantissa bits with 7 bits explicitly stored) for internal computations, if a fast matrix multiplication algorithm using that datatype internally is available. Otherwise float32 matrix multiplications are computed as if the precision is “high”.

Note

This does not change the output dtype of float32 matrix multiplications, it controls how the internal computation of the matrix multiplication is performed.

Note

This does not change the precision of convolution operations. Other flags, like tensorplay.backends.cudnn.allow_tf32, may control the precision of convolution operations.

Note

This flag currently only affects one native device type: CUDA. If “high” or “medium” are set then the TensorFloat32 datatype will be used when computing float32 matrix multiplications, equivalent to setting tensorplay.backends.cuda.matmul.allow_tf32 = True. When “highest” (the default) is set then the float32 datatype is used for internal computations, equivalent to setting tensorplay.backends.cuda.matmul.allow_tf32 = False.

Parameters:

precision (str) – can be set to “highest” (default), “high”, or “medium” (see above).

#

slow_conv_dilated2d

functionFull reference ↗
tensorplay.slow_conv_dilated2d(input, weight, kernel_size, bias=None, stride=1, padding=0, dilation=1)[source]
#

slow_conv_dilated3d

functionFull reference ↗
tensorplay.slow_conv_dilated3d(input, weight, kernel_size, bias=None, stride=1, padding=0, dilation=1)[source]
#

slow_conv_transpose2d

functionFull reference ↗
tensorplay.slow_conv_transpose2d(input, weight, kernel_size, bias=None, stride=1, padding=0, output_padding=0, dilation=1, *, out=None)[source]
#

slow_conv_transpose3d

functionFull reference ↗
tensorplay.slow_conv_transpose3d(input, weight, kernel_size, bias=None, stride=1, padding=0, output_padding=0, dilation=1, *, out=None)[source]
#

slow_conv3d_forward

functionFull reference ↗
tensorplay.slow_conv3d_forward(input, weight, kernel_size, bias, stride, padding, *, out=None)[source]
#

slow_conv3d

functionFull reference ↗
tensorplay.slow_conv3d(input, weight, kernel_size, bias=None, stride=1, padding=0, *, out=None)[source]
#

sparse_compressed_tensor

functionFull reference ↗
tensorplay.sparse_compressed_tensor(compressed_indices, plain_indices, values, size=None, *, dtype=None, layout=None, device=None, pin_memory=False)[source]
#

sparse_sampled_addmm

functionFull reference ↗
tensorplay.sparse_sampled_addmm(input, mat1, mat2, *, beta=1, alpha=1, out=None)[source]
#

special_shifted_chebyshev_polynomial_t

functionFull reference ↗
tensorplay.special_shifted_chebyshev_polynomial_t(x, n, *, out=None)[source]
#

special_shifted_chebyshev_polynomial_u

functionFull reference ↗
tensorplay.special_shifted_chebyshev_polynomial_u(x, n, *, out=None)[source]
#

special_shifted_chebyshev_polynomial_v

functionFull reference ↗
tensorplay.special_shifted_chebyshev_polynomial_v(x, n, *, out=None)[source]
#

special_shifted_chebyshev_polynomial_w

functionFull reference ↗
tensorplay.special_shifted_chebyshev_polynomial_w(x, n, *, out=None)[source]
#

tensor

functionFull reference ↗
tensorplay.tensor(data: object, *, dtype: tensorplay._C.DType | None = None, device: tensorplay._C.Device | None = None, pin_memory: bool = False, requires_grad: bool = False) tensorplay._C.TensorBase
#

thnn_conv2d

functionFull reference ↗
tensorplay.thnn_conv2d(input, weight, kernel_size, bias=None, stride=1, padding=0, *, out=None)[source]
#

to

functionFull reference ↗
tensorplay.to(input, dtype=None, layout=None, device=None, pin_memory=None, non_blocking=False, copy=False, memory_format=None)[source]
#

tp_cosine_embedding_loss

functionFull reference ↗
tensorplay.tp_cosine_embedding_loss(input1, input2, target, margin=0.0, reduction=1)[source]
#

tp_margin_ranking_loss

functionFull reference ↗
tensorplay.tp_margin_ranking_loss(input1, input2, target, margin=0.0, reduction=1)[source]
#

tp_poisson_nll_loss

functionFull reference ↗
tensorplay.tp_poisson_nll_loss(input, target, log_input=True, full=False, eps=1e-08, reduction=1)[source]
#

typename

functionFull reference ↗
tensorplay.typename(obj: Any, /) str[source]

String representation of the type of an object.

This function returns a fully qualified string representation of an object’s type. :param obj: The object whose type to represent :type obj: object

Returns:

the type of the object o

Return type:

str

Example

>>> x = tensorplay.tensor([1, 2, 3])
>>> tensorplay.typename(x)
'tensorplay.LongTensor'
>>> tensorplay.typename(tensorplay.nn.Parameter)
'tensorplay.nn.parameter.Parameter'
#

unique_dim_consecutive

functionFull reference ↗
tensorplay.unique_dim_consecutive(input, dim, return_inverse=False, return_counts=False)[source]
#

unique_dim

functionFull reference ↗
tensorplay.unique_dim(input, dim, sorted=True, return_inverse=False, return_counts=False)[source]
#

upsample_bicubic2d

functionFull reference ↗
tensorplay.upsample_bicubic2d(input, output_size, align_corners, scales_h=None, scales_w=None, *, out=None)[source]
#

upsample_bilinear2d

functionFull reference ↗
tensorplay.upsample_bilinear2d(input, output_size, align_corners, scales_h=None, scales_w=None, *, out=None)[source]
#

upsample_linear1d

functionFull reference ↗
tensorplay.upsample_linear1d(input, output_size, align_corners, scales=None, *, out=None)[source]
#

upsample_nearest2d

functionFull reference ↗
tensorplay.upsample_nearest2d(input, output_size, scales_h=None, scales_w=None, *, out=None)[source]
#

upsample_nearest3d

functionFull reference ↗
tensorplay.upsample_nearest3d(input, output_size, scales_d=None, scales_h=None, scales_w=None, *, out=None)[source]
#

upsample_trilinear3d

functionFull reference ↗
tensorplay.upsample_trilinear3d(input, output_size, align_corners, scales_d=None, scales_h=None, scales_w=None, *, out=None)[source]
#

use_deterministic_algorithms

functionFull reference ↗
tensorplay.use_deterministic_algorithms(mode: bool, *, warn_only: bool = False) None[source]

Sets whether TensorPlay operations must use “deterministic” algorithms. That is, algorithms which, given the same input, and when run on the same software and hardware, always produce the same output. When enabled, operations will use deterministic algorithms when available, and if only nondeterministic algorithms are available they will throw a RuntimeError when called.

Note

This setting alone is not always enough to make an application reproducible. Refer to Reproducibility for more information.

Note

tensorplay.set_deterministic_debug_mode() offers an alternative interface for this feature.

Note that deterministic operations tend to have worse performance than nondeterministic operations.

Note

This flag does not detect or prevent nondeterministic behavior caused by calling an inplace operation on a tensor with an internal memory overlap or by giving such a tensor as the out argument for an operation. In these cases, multiple writes of different data may target a single memory location, and the order of writes is not guaranteed.

Parameters:

mode (bool) – If True, makes potentially nondeterministic operations switch to a deterministic algorithm or throw a runtime error. If False, allows nondeterministic operations.

Keyword Arguments:

warn_only (bool, optional) – If True, operations that do not have a deterministic implementation will throw a warning instead of an error. Default: False

Example:

>>> # xdoctest: +SKIP
>>> tensorplay.use_deterministic_algorithms(True)
#

vision_to_tensor

functionFull reference ↗
tensorplay.vision_to_tensor(image: Annotated[numpy.typing.ArrayLike, numpy.uint8]) tensorplay::Tensor

Optimized conversion from HWC uint8 image to CHW float32 tensor (div 255)

Classes 21

#

autocast

classFull reference ↗
class tensorplay.autocast(device_type: str, dtype: Any | None = None, enabled: bool = True, cache_enabled: bool | None = None)[source]

Instances of autocast serve as context managers or decorators that allow regions of your script to run in mixed precision.

In these regions, ops run in an op-specific dtype chosen by autocast to improve performance while maintaining accuracy.

When entering an autocast-enabled region, Tensors may be any type. You should not call half() or bfloat16() on your model(s) or inputs when using autocasting.

autocast should wrap only the forward pass(es) of your network, including the loss computation(s). Backward passes under autocast are not recommended. Backward ops run in the same type that autocast used for corresponding forward ops.

Example for CUDA Devices:

# Creates model and optimizer in default precision
model = Net().cuda()
optimizer = optim.SGD(model.parameters(), ...)

for input, target in data:
    optimizer.zero_grad()

    # Enables autocasting for the forward pass (model + loss)
    with tensorplay.autocast(device_type="cuda"):
        output = model(input)
        loss = loss_fn(output, target)

    # Exits the context manager before backward()
    loss.backward()
    optimizer.step()

autocast can also be used as a decorator, e.g., on the forward method of your model:

class AutocastModel(nn.Module):
    ...

    @tensorplay.autocast(device_type="cuda")
    def forward(self, input): ...

Floating-point Tensors produced in an autocast-enabled region may be float16. After returning to an autocast-disabled region, using them with floating-point Tensors of different dtypes may cause type mismatch errors. If so, cast the Tensor(s) produced in the autocast region back to float32 (or other dtype if desired).

autocast(enabled=False) subregions can be nested in autocast-enabled regions. Locally disabling autocast can be useful, for example, if you want to force a subregion to run in a particular dtype.

The autocast state is thread-local. If you want it enabled in a new thread, the context manager or decorator must be invoked in that thread.

Parameters:
  • device_type (str, required) – Device type to use. Possible values are: ‘cuda’ and ‘cpu’. The type is the same as the type attribute of a tensorplay.device. Thus, you may obtain the device type of a tensor using Tensor.device.type.

  • enabled (bool, optional) – Whether autocasting should be enabled in the region. Default: True

  • dtype (tensorplay.dtype, optional) – Data type for ops run in autocast. It uses the default value (tensorplay.float16 for CUDA and tensorplay.bfloat16 for CPU), given by get_autocast_dtype(), if dtype is None. Default: None

  • cache_enabled (bool, optional) – Whether the weight cache inside autocast should be enabled. Default: True

#

Device

classFull reference ↗
class tensorplay.Device
is_cpu(self: tensorplay._C.Device) bool
is_cuda(self: tensorplay._C.Device) bool
is_vulkan(self: tensorplay._C.Device) bool
#

DeviceType

classFull reference ↗
class tensorplay.DeviceType

Members:

CPU

CUDA

Vulkan

Unknown

DeviceType.name -> str
#

DispatchKey

classFull reference ↗
class tensorplay.DispatchKey

Dispatch keys of the runtime, in dispatch-priority order: autocast keys outrank autograd keys, which outrank backend keys.

Members:

CPU

CUDA

Vulkan

AutogradCPU

AutogradCUDA

AutogradVulkan

AutocastCPU

AutocastCUDA

AutocastVulkan

VmapCPU

VmapCUDA

VmapVulkan

Composite

VmapMode

DynamicLayerFrontMode

DynamicLayerBackMode

DispatchKey.name -> str
#

DType

classFull reference ↗
class tensorplay.DType

Members:

uint8

int8

int16

int32

int64

uint16

uint32

uint64

float16

bfloat16

float32

float64

complex32

complex64

complex128

bcomplex32

qint8

quint8

qint32

bool

undefined

DType.name -> str
#

FileCheck

classFull reference ↗
class tensorplay.FileCheck
check(self: tensorplay._C.FileCheck, test_string: str) tensorplay._C.FileCheck
check_count(self: tensorplay._C.FileCheck, test_string: str, count: SupportsInt | SupportsIndex, exactly: bool = False) tensorplay._C.FileCheck
check_dag(self: tensorplay._C.FileCheck, test_string: str) tensorplay._C.FileCheck
check_next(self: tensorplay._C.FileCheck, test_string: str) tensorplay._C.FileCheck
check_not(self: tensorplay._C.FileCheck, test_string: str) tensorplay._C.FileCheck
check_regex(self: tensorplay._C.FileCheck, test_string: str) tensorplay._C.FileCheck
check_same(self: tensorplay._C.FileCheck, test_string: str) tensorplay._C.FileCheck
check_source_highlighted(self: tensorplay._C.FileCheck, test_string: str) tensorplay._C.FileCheck
run(self: tensorplay._C.FileCheck, test_string: str) None
#

Future

classFull reference ↗
class tensorplay.Future
add_done_callback(self: object, callback: collections.abc.Callable) None
done(self: tensorplay._C.Future) bool
is_done(self: tensorplay._C.Future) bool
set_exception(self: tensorplay._C.Future, result: object) None
set_result(self: tensorplay._C.Future, result: object) None
then(self: object, callback: collections.abc.Callable) tensorplay._C.Future
value(self: tensorplay._C.Future) object
wait(self: tensorplay._C.Future) object
#

Generator

classFull reference ↗
class tensorplay.Generator
get_state(self: tensorplay._C.Generator) tensorplay::Tensor
initial_seed(self: tensorplay._C.Generator) int
manual_seed(self: tensorplay._C.Generator, seed: SupportsInt | SupportsIndex) int
seed(self: tensorplay._C.Generator) int
set_state(self: tensorplay._C.Generator, new_state: tensorplay::Tensor) None
#

GradScaler

classFull reference ↗
class tensorplay.GradScaler(device: str = 'cuda', init_scale: float = 65536.0, growth_factor: float = 2.0, backoff_factor: float = 0.5, growth_interval: int = 2000, enabled: bool = True)[source]

An instance scaler of GradScaler.

Helps perform the steps of gradient scaling conveniently.

  • scaler.scale(loss) multiplies a given loss by scaler’s current scale factor.

  • scaler.step(optimizer) safely unscales gradients and calls optimizer.step().

  • scaler.update() updates scaler’s scale factor.

Example:

# Creates a GradScaler once at the beginning of training.
scaler = GradScaler()

for epoch in epochs:
    for input, target in data:
        optimizer.zero_grad()
        output = model(input)
        loss = loss_fn(output, target)

        # Scales loss.  Calls backward() on scaled loss to create scaled gradients.
        scaler.scale(loss).backward()

        # scaler.step() first unscales gradients of the optimizer's params.
        # If gradients don't contain infs/NaNs, optimizer.step() is then called,
        # otherwise, optimizer.step() is skipped.
        scaler.step(optimizer)

        # Updates the scale for next iteration.
        scaler.update()

scaler dynamically estimates the scale factor each iteration. To minimize gradient underflow, a large scale factor should be used. However, float16 values can “overflow” (become inf or NaN) if the scale factor is too large. Therefore, the optimal scale factor is the largest factor that can be used without incurring inf or NaN gradient values. scaler approximates the optimal scale factor over time by checking the gradients for infs and NaNs during every scaler.step(optimizer) (or optional separate scaler.unscale_(optimizer), see unscale_()).

  • If infs/NaNs are found, scaler.step(optimizer) skips the underlying optimizer.step() (so the params themselves remain uncorrupted) and update() multiplies the scale by backoff_factor.

  • If no infs/NaNs are found, scaler.step(optimizer) runs the underlying optimizer.step() as usual. If growth_interval unskipped iterations occur consecutively, update() multiplies the scale by growth_factor.

Parameters:
  • device (str, optional, default="cuda") – Device type to use. Possible values are: ‘cuda’ and ‘cpu’. The type is the same as the type attribute of a tensorplay.device. Thus, you may obtain the device type of a tensor using Tensor.device.type.

  • init_scale (float, optional, default=2.**16) – Initial scale factor.

  • growth_factor (float, optional, default=2.0) – Factor by which the scale is multiplied during update() if no inf/NaN gradients occur for growth_interval consecutive iterations.

  • backoff_factor (float, optional, default=0.5) – Factor by which the scale is multiplied during update() if inf/NaN gradients occur in an iteration.

  • growth_interval (int, optional, default=2000) – Number of consecutive iterations without inf/NaN gradients that must occur for the scale to be multiplied by growth_factor.

  • enabled (bool, optional) – If False, disables gradient scaling. step() simply invokes the underlying optimizer.step(), and other methods become no-ops. Default: True

get_backoff_factor() float[source]

Return a Python float containing the scale backoff factor.

get_growth_factor() float[source]

Return a Python float containing the scale growth factor.

get_growth_interval() int[source]

Return a Python int containing the growth interval.

get_scale() float[source]

Return a Python float containing the current scale, or 1.0 if scaling is disabled.

is_enabled() bool[source]

Return a bool indicating whether this instance is enabled.

load_state_dict(state_dict: dict[str, Any]) None[source]

Load the scaler state.

If this instance is disabled, load_state_dict() is a no-op.

Parameters:

state_dict (dict) – scaler state. Should be an object returned from a call to state_dict().

scale(outputs: TensorBase) TensorBase[source]
scale(outputs: list[TensorBase]) list[TensorBase]
scale(outputs: tuple[TensorBase, ...]) tuple[TensorBase, ...]
scale(outputs: Iterable[tensorplay.Tensor]) Iterable[tensorplay.Tensor]

Multiplies (‘scales’) a tensor or list of tensors by the scale factor.

Returns scaled outputs. If this instance of GradScaler is not enabled, outputs are returned unmodified.

Parameters:

outputs (Tensor or iterable of Tensors) – Outputs to scale.

set_backoff_factor(new_factor: float) None[source]

Set a new scale backoff factor.

Parameters:

new_scale (float) – Value to use as the new scale backoff factor.

set_growth_factor(new_factor: float) None[source]

Set a new scale growth factor.

Parameters:

new_scale (float) – Value to use as the new scale growth factor.

set_growth_interval(new_interval: int) None[source]

Set a new growth interval.

Parameters:

new_interval (int) – Value to use as the new growth interval.

state_dict() dict[str, Any][source]

Return the state of the scaler as a dict.

It contains five entries:

  • "scale" - a Python float containing the current scale

  • "growth_factor" - a Python float containing the current growth factor

  • "backoff_factor" - a Python float containing the current backoff factor

  • "growth_interval" - a Python int containing the current growth interval

  • "_growth_tracker" - a Python int containing the number of recent consecutive unskipped steps.

If this instance is not enabled, returns an empty dict.

Note

If you wish to checkpoint the scaler’s state after a particular iteration, state_dict() should be called after update().

step(optimizer: Optimizer, *args: Any, **kwargs: Any) Any[source]

Invoke unscale_(optimizer) followed by parameter update, if gradients are not infs/NaN.

step() carries out the following two operations:

  1. Internally invokes unscale_(optimizer) (unless unscale_() was explicitly called for optimizer earlier in the iteration). As part of the unscale_(), gradients are checked for infs/NaNs.

  2. If no inf/NaN gradients are found, invokes optimizer.step() using the unscaled gradients. Otherwise, optimizer.step() is skipped to avoid corrupting the params.

*args and **kwargs are forwarded to optimizer.step().

Returns the return value of optimizer.step(*args, **kwargs).

Parameters:
  • optimizer (tensorplay.optim.Optimizer) – Optimizer that applies the gradients.

  • args – Any arguments.

  • kwargs – Any keyword arguments.

Warning

Closure use is not currently supported.

unscale_(optimizer: Optimizer) None[source]

Divides (“unscales”) the optimizer’s gradient tensors by the scale factor.

unscale_() is optional, serving cases where you need to modify or inspect gradients between the backward pass(es) and step(). If unscale_() is not called explicitly, gradients will be unscaled automatically during step().

Simple example, using unscale_() to enable clipping of unscaled gradients:

...
scaler.scale(loss).backward()
scaler.unscale_(optimizer)
tensorplay.nn.utils.clip_grad_norm_(model.parameters(), max_norm)
scaler.step(optimizer)
scaler.update()
Parameters:

optimizer (tensorplay.optim.Optimizer) – Optimizer that owns the gradients to be unscaled.

Warning

unscale_() should only be called once per optimizer per step() call, and only after all gradients for that optimizer’s assigned parameters have been accumulated. Calling unscale_() twice for a given optimizer between each step() triggers a RuntimeError.

update(new_scale: float | TensorBase | None = None) None[source]

Update the scale factor.

If any optimizer steps were skipped the scale is multiplied by backoff_factor to reduce it. If growth_interval unskipped iterations occurred consecutively, the scale is multiplied by growth_factor to increase it.

Passing new_scale sets the new scale value manually. (new_scale is not used directly, it’s used to fill GradScaler’s internal scale tensor. So if new_scale was a tensor, later in-place changes to that tensor will not further affect the scale GradScaler uses internally.)

Parameters:

new_scale (float or tensorplay.Tensor, optional, default=None) – New scale factor.

Warning

update() should only be called at the end of the iteration, after scaler.step(optimizer) has been invoked for all optimizers used this iteration.

#

Layout

classFull reference ↗
class tensorplay.Layout(*values)[source]

tensor.layout returns one of these values; dense tensors report STRIDED.

as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

denominator

the denominator of a rational number in lowest terms

classmethod from_bytes(bytes, byteorder='big', *, signed=False)
imag

the imaginary part of a complex number

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

to_bytes(length=1, byteorder='big', *, signed=False)
#

MemoryFormat

classFull reference ↗
class tensorplay.MemoryFormat(*values)[source]
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

denominator

the denominator of a rational number in lowest terms

classmethod from_bytes(bytes, byteorder='big', *, signed=False)
imag

the imaginary part of a complex number

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

to_bytes(length=1, byteorder='big', *, signed=False)
#

QScheme

classFull reference ↗
class tensorplay.QScheme(*values)[source]

Quantization scheme attached to a quantized tensor’s quantizer.

as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

denominator

the denominator of a rational number in lowest terms

classmethod from_bytes(bytes, byteorder='big', *, signed=False)
imag

the imaginary part of a complex number

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

to_bytes(length=1, byteorder='big', *, signed=False)
#

Size

classFull reference ↗
class tensorplay.Size(iterable=(), /)

Sequence of tensor dimension sizes (tuple subclass).

count(value, /)

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

numel()

Product of the dimensions.

#

SymBool

classFull reference ↗
class tensorplay.SymBool
expect_bool(self: tensorplay._C.SymBool) bool
guard_bool(self: tensorplay._C.SymBool, file: str = '', line: SupportsInt | SupportsIndex = 0) bool
guard_or_false(self: tensorplay._C.SymBool, file: str = '', line: SupportsInt | SupportsIndex = 0) bool
guard_or_true(self: tensorplay._C.SymBool, file: str = '', line: SupportsInt | SupportsIndex = 0) bool
guard_size_oblivious(self: tensorplay._C.SymBool, file: str = '', line: SupportsInt | SupportsIndex = 0) bool
has_hint(self: tensorplay._C.SymBool) bool
is_symbolic(self: tensorplay._C.SymBool) bool
maybe_as_bool(self: tensorplay._C.SymBool) bool | None
statically_known_true(self: tensorplay._C.SymBool, file: str = '', line: SupportsInt | SupportsIndex = 0) bool
sym_and(self: tensorplay._C.SymBool, arg0: tensorplay._C.SymBool) tensorplay._C.SymBool
sym_not(self: tensorplay._C.SymBool) tensorplay._C.SymBool
sym_or(self: tensorplay._C.SymBool, arg0: tensorplay._C.SymBool) tensorplay._C.SymBool
sym_xor(self: tensorplay._C.SymBool, arg0: tensorplay._C.SymBool) tensorplay._C.SymBool
static symbolic(name: str, hint: bool | None = None) tensorplay._C.SymBool
to_sym_float(self: tensorplay._C.SymBool) tensorplay._C.SymFloat
to_sym_int(self: tensorplay._C.SymBool) tensorplay._C.SymInt
#

SymFloat

classFull reference ↗
class tensorplay.SymFloat
acos(self: tensorplay._C.SymFloat) tensorplay._C.SymFloat
as_integer_ratio(self: tensorplay._C.SymFloat) object
asin(self: tensorplay._C.SymFloat) tensorplay._C.SymFloat
atan(self: tensorplay._C.SymFloat) tensorplay._C.SymFloat
ceil(self: tensorplay._C.SymFloat) tensorplay._C.SymInt
conjugate(self: tensorplay._C.SymFloat) tensorplay._C.SymFloat
cos(self: tensorplay._C.SymFloat) tensorplay._C.SymFloat
cosh(self: tensorplay._C.SymFloat) tensorplay._C.SymFloat
expect_float(self: tensorplay._C.SymFloat) float
floor(self: tensorplay._C.SymFloat) tensorplay._C.SymInt
guard_float(self: tensorplay._C.SymFloat, file: str = '', line: SupportsInt | SupportsIndex = 0) float
has_hint(self: tensorplay._C.SymFloat) bool
hex(self: tensorplay._C.SymFloat) object
is_integer(self: tensorplay._C.SymFloat) tensorplay._C.SymBool
is_symbolic(self: tensorplay._C.SymFloat) bool
log2(self: tensorplay._C.SymFloat) tensorplay._C.SymFloat
max(self: tensorplay._C.SymFloat, arg0: tensorplay._C.SymFloat) tensorplay._C.SymFloat
maybe_as_float(self: tensorplay._C.SymFloat) float | None
min(self: tensorplay._C.SymFloat, arg0: tensorplay._C.SymFloat) tensorplay._C.SymFloat
round(self: tensorplay._C.SymFloat, ndigits: object = None) object
sin(self: tensorplay._C.SymFloat) tensorplay._C.SymFloat
sinh(self: tensorplay._C.SymFloat) tensorplay._C.SymFloat
sqrt(self: tensorplay._C.SymFloat) tensorplay._C.SymFloat
sym_eq(self: tensorplay._C.SymFloat, arg0: tensorplay._C.SymFloat) tensorplay._C.SymBool
sym_float(self: tensorplay._C.SymFloat) tensorplay._C.SymFloat
sym_ge(self: tensorplay._C.SymFloat, arg0: tensorplay._C.SymFloat) tensorplay._C.SymBool
sym_gt(self: tensorplay._C.SymFloat, arg0: tensorplay._C.SymFloat) tensorplay._C.SymBool
sym_int(self: tensorplay._C.SymFloat) tensorplay._C.SymInt
sym_le(self: tensorplay._C.SymFloat, arg0: tensorplay._C.SymFloat) tensorplay._C.SymBool
sym_lt(self: tensorplay._C.SymFloat, arg0: tensorplay._C.SymFloat) tensorplay._C.SymBool
sym_ne(self: tensorplay._C.SymFloat, arg0: tensorplay._C.SymFloat) tensorplay._C.SymBool
static symbolic(name: str, hint: SupportsFloat | SupportsIndex | None = None) tensorplay._C.SymFloat
tan(self: tensorplay._C.SymFloat) tensorplay._C.SymFloat
tanh(self: tensorplay._C.SymFloat) tensorplay._C.SymFloat
trunc(self: tensorplay._C.SymFloat) tensorplay._C.SymInt
#

SymInt

classFull reference ↗
class tensorplay.SymInt
as_integer_ratio(self: tensorplay._C.SymInt) tuple[tensorplay._C.SymInt, int]
bit_length(self: tensorplay._C.SymInt) int
ceil(self: tensorplay._C.SymInt) tensorplay._C.SymInt
clone(self: tensorplay._C.SymInt) tensorplay._C.SymInt
conjugate(self: tensorplay._C.SymInt) tensorplay._C.SymInt
expect_int(self: tensorplay._C.SymInt) int
floor(self: tensorplay._C.SymInt) tensorplay._C.SymInt
guard_int(self: tensorplay._C.SymInt, file: str = '', line: SupportsInt | SupportsIndex = 0) int
has_hint(self: tensorplay._C.SymInt) bool
is_heap_allocated(self: tensorplay._C.SymInt) bool
is_same(self: tensorplay._C.SymInt, arg0: tensorplay._C.SymInt) bool
is_symbolic(self: tensorplay._C.SymInt) bool
max(self: tensorplay._C.SymInt, arg0: tensorplay._C.SymInt) tensorplay._C.SymInt
maybe_as_int(self: tensorplay._C.SymInt) int | None
min(self: tensorplay._C.SymInt, arg0: tensorplay._C.SymInt) tensorplay._C.SymInt
pow_by_natural(self: tensorplay._C.SymInt, arg0: tensorplay._C.SymInt) tensorplay._C.SymInt
round(self: tensorplay._C.SymInt) tensorplay._C.SymInt
sym_eq(self: tensorplay._C.SymInt, arg0: tensorplay._C.SymInt) tensorplay._C.SymBool
sym_float(self: tensorplay._C.SymInt) tensorplay._C.SymFloat
sym_ge(self: tensorplay._C.SymInt, arg0: tensorplay._C.SymInt) tensorplay._C.SymBool
sym_gt(self: tensorplay._C.SymInt, arg0: tensorplay._C.SymInt) tensorplay._C.SymBool
sym_le(self: tensorplay._C.SymInt, arg0: tensorplay._C.SymInt) tensorplay._C.SymBool
sym_lt(self: tensorplay._C.SymInt, arg0: tensorplay._C.SymInt) tensorplay._C.SymBool
sym_ne(self: tensorplay._C.SymInt, arg0: tensorplay._C.SymInt) tensorplay._C.SymBool
static symbolic(name: str, hint: SupportsInt | SupportsIndex | None = None) tensorplay._C.SymInt
to_sym_float(self: tensorplay._C.SymInt) tensorplay._C.SymFloat
trunc(self: tensorplay._C.SymInt) tensorplay._C.SymInt
#

UntypedStorage

classFull reference ↗
class tensorplay.UntypedStorage
data_ptr(self: tensorplay._C.UntypedStorage) int
nbytes(self: tensorplay._C.UntypedStorage) int
resizable(self: tensorplay._C.UntypedStorage) bool
resize_(self: tensorplay._C.UntypedStorage, nbytes: SupportsInt | SupportsIndex) tensorplay._C.UntypedStorage
size(self: tensorplay._C.UntypedStorage) int

Attributes 1

Exceptions 1

Search documentation

Search all 1,743 documentation pages.

Keyboard shortcuts

Global

  • /Focus search
  • ?This dialog
  • ,Open settings
  • jAI assistant

Search

  • Navigate results
  • Open result
  • escClose

Package

  • mMain information
  • dDocs
  • .Code
  • -Changelog
  • tTimeline
  • sStats
  • vVersions