latest (dev)
Copy
Latest development documentation · Updated 2026-10-08
tensorplay.nn.attention.bias API
Functions 2
causal_lower_right
functionFull reference ↗- tensorplay.nn.attention.bias.causal_lower_right(*size) CausalBias[source]
Creates a lower-right triangular causal bias.
This function generates a lower-right triangular matrix to represent causal attention bias with a diagonal offset set so that the inclusive values are aligned to the lower right corner of the matrix.
The equivalent code for constructing this bias is:
diagonal_offset = size[1] - size[0] tensorplay.tril( tensorplay.ones(size, dtype=tensorplay.bool), diagonal=diagonal_offset, )For instance, with shape=(3,4), the materialized bias tensor will be:
[[1, 1, 0, 0], [1, 1, 1, 0], [1, 1, 1, 1]]- Parameters:
size – The size of the bias matrix.
- Returns:
The LOWER_RIGHT triangular causal bias variant.
- Return type:
causal_upper_left
functionFull reference ↗- tensorplay.nn.attention.bias.causal_upper_left(*size) CausalBias[source]
Creates an upper-left triangular causal bias.
This function generates an upper-left triangular matrix to represent causal attention bias with a diagonal offset set so that the inclusive values are aligned to the upper left corner of the matrix. This equivalent to the is_causal=True argument in scaled_dot_product_attention.
The equivalent code for constructing this bias is:
tensorplay.tril(tensorplay.ones(size, dtype=tensorplay.bool))For instance, with shape=(3,4), the materialized bias tensor will be:
[[1, 0, 0, 0], [1, 1, 0, 0], [1, 1, 1, 0]]- Parameters:
size – The size of the bias matrix.
- Returns:
The UPPER_LEFT triangular causal bias variant.
- Return type:
Classes 2
CausalBias
classFull reference ↗- class tensorplay.nn.attention.bias.CausalBias(variant: CausalVariant, seq_len_q: int, seq_len_kv: int)[source]
A bias representing causal attention patterns. For an overview of the bias structure, see the
CausalVariantenum.This class is used for defining causal (triangular) attention biases. For constructing the bias, there exist two factory functions:
causal_upper_left()andcausal_lower_right().Example:
from tensorplay.nn.attention.bias import causal_lower_right bsz, num_heads, seqlen_q, seqlen_kv, head_dim = 32, 8, 4, 12, 8 # Create a lower-right causal bias attn_bias = causal_lower_right(seqlen_q, seqlen_kv) q = tensorplay.randn( bsz, num_heads, seqlen_q, head_dim, device="cuda", dtype=tensorplay.float16 ) k = tensorplay.randn( bsz, num_heads, seqlen_kv, head_dim, device="cuda", dtype=tensorplay.float16 ) v = tensorplay.randn( bsz, num_heads, seqlen_kv, head_dim, device="cuda", dtype=tensorplay.float16 ) out = F.scaled_dot_product_attention(q, k, v, attn_bias)Warning
This class is a prototype and subject to change.
- abs()
abs(Tensor self) -> Tensor
- abs_()
abs_(Tensor(a!) self) -> Tensor(a!)
- absolute()
absolute(Tensor self) -> Tensor
- absolute_()
absolute_(Tensor(a!) self) -> Tensor(a!)
- acos()
acos(Tensor self) -> Tensor
- acos_()
acos_(Tensor(a!) self) -> Tensor(a!)
- acosh()
acosh(Tensor self) -> Tensor
- acosh_()
acosh_(Tensor(a!) self) -> Tensor(a!)
- add()
add.Tensor(Tensor self, Tensor other, *, Scalar alpha=1) -> Tensoradd.Scalar(Tensor self, Scalar other, Scalar alpha=1) -> Tensor
- add_(other, *, alpha=1) Tensor
In-place version of
tensorplay.Tensor.add()
- addbmm()
addbmm(Tensor self, Tensor batch1, Tensor batch2, *, Scalar beta=1, Scalar alpha=1) -> Tensor
- addbmm_()
addbmm_(Tensor(a!) self, Tensor batch1, Tensor batch2, *, Scalar beta=1, Scalar alpha=1) -> Tensor(a!)
- addcdiv()
addcdiv(Tensor self, Tensor tensor1, Tensor tensor2, *, Scalar value=1) -> Tensor
- addcdiv_()
addcdiv_(Tensor(a!) self, Tensor tensor1, Tensor tensor2, *, Scalar value=1) -> Tensor(a!)
- addcmul()
addcmul(Tensor self, Tensor tensor1, Tensor tensor2, *, Scalar value=1) -> Tensor
- addcmul_()
addcmul_(Tensor(a!) self, Tensor tensor1, Tensor tensor2, *, Scalar value=1) -> Tensor(a!)
- addmm()
addmm(Tensor self, Tensor mat1, Tensor mat2, *, Scalar beta=1, Scalar alpha=1) -> Tensor
- addmm_()
addmm_(Tensor(a!) self, Tensor mat1, Tensor mat2, *, Scalar beta=1, Scalar alpha=1) -> Tensor(a!)
- addmv()
addmv(Tensor self, Tensor mat, Tensor vec, *, Scalar beta=1, Scalar alpha=1) -> Tensor
- addmv_()
addmv_(Tensor(a!) self, Tensor mat, Tensor vec, *, Scalar beta=1, Scalar alpha=1) -> Tensor(a!)
- addr()
addr(Tensor self, Tensor vec1, Tensor vec2, *, Scalar beta=1, Scalar alpha=1) -> Tensor
- addr_()
addr_(Tensor(a!) self, Tensor vec1, Tensor vec2, *, Scalar beta=1, Scalar alpha=1) -> Tensor(a!)
- adjoint()
adjoint(Tensor(a) self) -> Tensor(a)
- airy_ai()
airy_ai(Tensor self) -> Tensor
- alias()
alias(Tensor(a) self) -> Tensor(a)
- all()
all(Tensor self) -> Tensorall.dim(Tensor self, int dim, bool keepdim=False) -> Tensorall.dims(Tensor self, int[]? dim=None, bool keepdim=False) -> Tensor
- allclose()
allclose(Tensor self, Tensor other, float rtol=1e-05, float atol=1e-08, bool equal_nan=False) -> bool
- alpha_dropout_()
alpha_dropout_(Tensor(a!) self, float p=0.5, bool train=True) -> Tensor(a!)
- aminmax()
aminmax(Tensor self, int[] dim=[], bool keepdim=False) -> (Tensor min, Tensor max)
- angle()
angle(Tensor self) -> Tensor
- any()
any(Tensor self) -> Tensorany.dim(Tensor self, int dim, bool keepdim=False) -> Tensorany.dims(Tensor self, int[]? dim=None, bool keepdim=False) -> Tensor
- arccos()
arccos(Tensor self) -> Tensor
- arccos_()
arccos_(Tensor(a!) self) -> Tensor(a!)
- arccosh()
arccosh(Tensor self) -> Tensor
- arccosh_()
arccosh_(Tensor(a!) self) -> Tensor(a!)
- arcsin()
arcsin(Tensor self) -> Tensor
- arcsin_()
arcsin_(Tensor(a!) self) -> Tensor(a!)
- arcsinh()
arcsinh(Tensor self) -> Tensor
- arcsinh_()
arcsinh_(Tensor(a!) self) -> Tensor(a!)
- arctan()
arctan(Tensor self) -> Tensor
- arctan2()
arctan2(Tensor self, Tensor other) -> Tensor
- arctan2_()
arctan2_(Tensor(a!) self, Tensor other) -> Tensor(a!)
- arctan_()
arctan_(Tensor(a!) self) -> Tensor(a!)
- arctanh()
arctanh(Tensor self) -> Tensor
- arctanh_()
arctanh_(Tensor(a!) self) -> Tensor(a!)
- argmax()
argmax(Tensor self, int? dim=None, bool keepdim=False) -> Tensor
- argmin()
argmin(Tensor self, int? dim=None, bool keepdim=False) -> Tensor
- argsort()
argsort(Tensor self, int dim=-1, bool descending=False) -> Tensorargsort.stable(Tensor self, *, bool stable, int dim=-1, bool descending=False) -> Tensor
- argwhere()
argwhere(Tensor self) -> Tensor
- as_strided_()
as_strided_(Tensor(a!) self, SymInt[] size, SymInt[] stride, SymInt? storage_offset=None) -> Tensor(a!)
- as_strided_scatter()
as_strided_scatter(Tensor self, Tensor src, SymInt[] size, SymInt[] stride, SymInt? storage_offset=None) -> Tensor
- asin()
asin(Tensor self) -> Tensor
- asin_()
asin_(Tensor(a!) self) -> Tensor(a!)
- asinh()
asinh(Tensor self) -> Tensor
- asinh_()
asinh_(Tensor(a!) self) -> Tensor(a!)
- atan()
atan(Tensor self) -> Tensor
- atan2()
atan2(Tensor self, Tensor other) -> Tensor
- atan2_()
atan2_(Tensor(a!) self, Tensor other) -> Tensor(a!)
- atan_()
atan_(Tensor(a!) self) -> Tensor(a!)
- atanh()
atanh(Tensor self) -> Tensor
- atanh_()
atanh_(Tensor(a!) self) -> Tensor(a!)
- backward(self: tensorplay._C.TensorBase, gradient: tensorplay._C.TensorBase | None = None, retain_graph: bool | None = None, create_graph: bool = False, inputs: object = None) None
- baddbmm()
baddbmm(Tensor self, Tensor batch1, Tensor batch2, *, Scalar beta=1, Scalar alpha=1) -> Tensor
- baddbmm_()
baddbmm_(Tensor(a!) self, Tensor batch1, Tensor batch2, *, Scalar beta=1, Scalar alpha=1) -> Tensor(a!)
- bernoulli()
bernoulli(Tensor self, *, Generator? generator=None) -> Tensorbernoulli.p(Tensor self, float p, *, Generator? generator=None) -> Tensor
- bernoulli_(p=0.5, *, generator=None) Tensor
Fills each element of this tensor with an independent sample from the Bernoulli distribution with success probability
p, which may be a scalar or a tensor of per-element probabilities. The tensor may hold an integral dtype; each sample is written as 0 or 1.
- bessel_j0()
bessel_j0(Tensor self) -> Tensor
- bessel_j1()
bessel_j1(Tensor self) -> Tensor
- bessel_y0()
bessel_y0(Tensor self) -> Tensor
- bessel_y1()
bessel_y1(Tensor self) -> Tensor
- bincount()
bincount(Tensor self, Tensor? weights=None, SymInt minlength=0) -> Tensor
- bitwise_and()
bitwise_and.Tensor(Tensor self, Tensor other) -> Tensorbitwise_and.Scalar(Tensor self, Scalar other) -> Tensor
- bitwise_and_()
bitwise_and_.Tensor(Tensor(a!) self, Tensor other) -> Tensor(a!)bitwise_and_.Scalar(Tensor(a!) self, Scalar other) -> Tensor(a!)
- bitwise_left_shift()
bitwise_left_shift.Tensor(Tensor self, Tensor other) -> Tensorbitwise_left_shift.Tensor_Scalar(Tensor self, Scalar other) -> Tensor
- bitwise_left_shift_()
bitwise_left_shift_.Tensor(Tensor(a!) self, Tensor other) -> Tensor(a!)bitwise_left_shift_.Tensor_Scalar(Tensor(a!) self, Scalar other) -> Tensor(a!)
- bitwise_not()
bitwise_not(Tensor self) -> Tensor
- bitwise_not_()
bitwise_not_(Tensor(a!) self) -> Tensor(a!)
- bitwise_or()
bitwise_or.Tensor(Tensor self, Tensor other) -> Tensorbitwise_or.Scalar(Tensor self, Scalar other) -> Tensor
- bitwise_or_()
bitwise_or_.Tensor(Tensor(a!) self, Tensor other) -> Tensor(a!)bitwise_or_.Scalar(Tensor(a!) self, Scalar other) -> Tensor(a!)
- bitwise_right_shift()
bitwise_right_shift.Tensor(Tensor self, Tensor other) -> Tensorbitwise_right_shift.Tensor_Scalar(Tensor self, Scalar other) -> Tensor
- bitwise_right_shift_()
bitwise_right_shift_.Tensor(Tensor(a!) self, Tensor other) -> Tensor(a!)bitwise_right_shift_.Tensor_Scalar(Tensor(a!) self, Scalar other) -> Tensor(a!)
- bitwise_xor()
bitwise_xor.Tensor(Tensor self, Tensor other) -> Tensorbitwise_xor.Scalar(Tensor self, Scalar other) -> Tensor
- bitwise_xor_()
bitwise_xor_.Tensor(Tensor(a!) self, Tensor other) -> Tensor(a!)bitwise_xor_.Scalar(Tensor(a!) self, Scalar other) -> Tensor(a!)
- bmm()
bmm(Tensor self, Tensor mat2) -> Tensor
- broadcast_to()
broadcast_to(Tensor self, SymInt[] size) -> Tensor
- bucketize(boundaries, *, out_int32=False, right=False, out=None)
Bucket indices of self against a sorted 1-D boundaries tensor.
- cauchy_()
cauchy_(Tensor(a!) self, float median=0.0, float sigma=1.0, *, Generator? generator=None) -> Tensor(a!)
- ccol_indices()
ccol_indices(Tensor(a) self) -> Tensor(a)
- ceil()
ceil(Tensor self) -> Tensor
- ceil_()
ceil_(Tensor(a!) self) -> Tensor(a!)
- celu()
celu(Tensor self, Scalar alpha=1.0) -> Tensor
- celu_()
celu_(Tensor(a!) self, Scalar alpha=1.0) -> Tensor(a!)
- chalf()
chalf(Tensor self, *, MemoryFormat? memory_format=None) -> Tensor
- channel_shuffle()
channel_shuffle(Tensor self, SymInt groups) -> Tensor
- cholesky()
cholesky(Tensor self, bool upper=False) -> Tensor
- cholesky_inverse()
cholesky_inverse(Tensor self, bool upper=False) -> Tensor
- cholesky_solve()
cholesky_solve(Tensor self, Tensor input2, bool upper=False) -> Tensor
- chunk()
chunk(Tensor(a -> *) self, int chunks, int dim=0) -> Tensor(a)[]
- clamp()
clamp.Tensor(Tensor self, Tensor? min=None, Tensor? max=None) -> Tensorclamp(Tensor self, Scalar? min=None, Scalar? max=None) -> Tensor
- clamp_()
clamp_.Tensor(Tensor(a!) self, Tensor? min=None, Tensor? max=None) -> Tensor(a!)clamp_(Tensor(a!) self, Scalar? min=None, Scalar? max=None) -> Tensor(a!)
- clamp_max()
clamp_max.Tensor(Tensor self, Tensor max) -> Tensorclamp_max(Tensor self, Scalar max) -> Tensor
- clamp_max_()
clamp_max_.Tensor(Tensor(a!) self, Tensor max) -> Tensor(a!)clamp_max_(Tensor(a!) self, Scalar max) -> Tensor(a!)
- clamp_min()
clamp_min.Tensor(Tensor self, Tensor min) -> Tensorclamp_min(Tensor self, Scalar min) -> Tensor
- clamp_min_()
clamp_min_.Tensor(Tensor(a!) self, Tensor min) -> Tensor(a!)clamp_min_(Tensor(a!) self, Scalar min) -> Tensor(a!)
- clip()
clip.Tensor(Tensor self, Tensor? min=None, Tensor? max=None) -> Tensorclip(Tensor self, Scalar? min=None, Scalar? max=None) -> Tensor
- clip_()
clip_.Tensor(Tensor(a!) self, Tensor? min=None, Tensor? max=None) -> Tensor(a!)clip_(Tensor(a!) self, Scalar? min=None, Scalar? max=None) -> Tensor(a!)
- clone()
clone(Tensor self, *, MemoryFormat? memory_format=None) -> Tensor
- combinations()
combinations(Tensor self, int r=2, bool with_replacement=False) -> Tensor
- conj()
conj(Tensor(a) self) -> Tensor(a)
- conj_physical()
conj_physical(Tensor self) -> Tensor
- conj_physical_()
conj_physical_(Tensor(a!) self) -> Tensor(a!)
- contiguous()
contiguous(Tensor(a) self, *, MemoryFormat memory_format=Contiguous) -> Tensor(a)
- copy_()
copy_(Tensor(a!) self, Tensor src, bool non_blocking=False) -> Tensor(a!)
- copysign()
copysign.Tensor(Tensor self, Tensor other) -> Tensorcopysign.Scalar(Tensor self, Scalar other) -> Tensor
- copysign_()
copysign_.Tensor(Tensor(a!) self, Tensor other) -> Tensor(a!)copysign_.Scalar(Tensor(a!) self, Scalar other) -> Tensor(a!)
- corrcoef()
corrcoef(Tensor self) -> Tensor
- cos()
cos(Tensor self) -> Tensor
- cos_()
cos_(Tensor(a!) self) -> Tensor(a!)
- cosh()
cosh(Tensor self) -> Tensor
- cosh_()
cosh_(Tensor(a!) self) -> Tensor(a!)
- cot()
cot(Tensor self) -> Tensor
- cov()
cov(Tensor self, *, int correction=1, Tensor? fweights=None, Tensor? aweights=None) -> Tensor
- cpu()
Returns a copy of this object in CPU memory. If this object is already in CPU memory, then no copy is performed and the original object is returned.
- cross()
cross(Tensor self, Tensor other, int? dim=None) -> Tensor
- csc()
csc(Tensor self) -> Tensor
- cuda(device=None, non_blocking=False)
Returns a copy of this object in CUDA memory. If this object is already in CUDA memory and on the correct device, then no copy is performed and the original object is returned.
- cummax()
cummax(Tensor self, int dim) -> (Tensor values, Tensor indices)
- cummin()
cummin(Tensor self, int dim) -> (Tensor values, Tensor indices)
- cumprod()
cumprod(Tensor self, int dim, ScalarType? dtype=None) -> Tensor
- cumprod_()
cumprod_(Tensor(a!) self, int dim, ScalarType? dtype=None) -> Tensor(a!)
- cumsum()
cumsum(Tensor self, int dim=0, ScalarType? dtype=None) -> Tensor
- cumsum_()
cumsum_(Tensor(a!) self, int dim=0, ScalarType? dtype=None) -> Tensor(a!)
- data_ptr(self: tensorplay._C.TensorBase) int
- defined(self: tensorplay._C.TensorBase) bool
- deg2rad()
deg2rad(Tensor self) -> Tensor
- deg2rad_()
deg2rad_(Tensor(a!) self) -> Tensor(a!)
- dequantize()
dequantize.self(Tensor self) -> Tensor
- det()
det(Tensor self) -> Tensor
- detach_copy()
detach_copy(Tensor self) -> Tensor
- diag()
diag(Tensor self, int diagonal=0) -> Tensor
- diag_embed()
diag_embed(Tensor self, int offset=0, int dim1=-2, int dim2=-1) -> Tensor
- diagflat()
diagflat(Tensor self, int offset=0) -> Tensor
- diagonal()
diagonal(Tensor(a) self, int offset=0, int dim1=0, int dim2=1) -> Tensor(a)
- diagonal_scatter()
diagonal_scatter(Tensor self, Tensor src, int offset=0, int dim1=0, int dim2=1) -> Tensor
- diff()
diff(Tensor self, int n=1, int dim=-1, Tensor? prepend=None, Tensor? append=None) -> Tensor
- digamma()
digamma(Tensor self) -> Tensor
- digamma_()
digamma_(Tensor(a!) self) -> Tensor(a!)
- dim() int
- dim_order(self: tensorplay._C.TensorBase) tuple
- dist()
dist(Tensor self, Tensor other, Scalar p=2) -> Tensor
- div()
div.Tensor(Tensor self, Tensor other) -> Tensordiv.Tensor_mode(Tensor self, Tensor other, *, str? rounding_mode) -> Tensordiv.Scalar_mode(Tensor self, Scalar other, *, str? rounding_mode) -> Tensordiv.Scalar(Tensor self, Scalar other) -> Tensor
- div_(value, *, rounding_mode=None) Tensor
In-place version of
tensorplay.Tensor.div()
- divide()
divide.Tensor(Tensor self, Tensor other) -> Tensordivide.Tensor_mode(Tensor self, Tensor other, *, str? rounding_mode) -> Tensordivide.Scalar(Tensor self, Scalar other) -> Tensordivide.Scalar_mode(Tensor self, Scalar other, *, str? rounding_mode) -> Tensor
- divide_(value, *, rounding_mode=None) Tensor
In-place version of
tensorplay.Tensor.divide()
- dot()
dot(Tensor self, Tensor tensor) -> Tensor
- dropout_()
dropout_(Tensor(a!) self, float p=0.5, bool train=True) -> Tensor(a!)
- dsplit(split_size_or_sections) List of Tensors
Splits a tensor of at least three dimensions into views along the third axis.
split_size_or_sectionsis either the number of equal sections or the list of sizes of each section.See
tensorplay.dsplit()
- element_size(self: tensorplay._C.TensorBase) int
- elu()
elu(Tensor self, Scalar alpha=1, Scalar scale=1, Scalar input_scale=1) -> Tensor
- elu_()
elu_(Tensor(a!) self, Scalar alpha=1, Scalar scale=1, Scalar input_scale=1) -> Tensor(a!)
- entr()
entr(Tensor self) -> Tensor
- eq()
eq.Tensor(Tensor self, Tensor other) -> Tensoreq.Scalar(Tensor self, Scalar other) -> Tensor
- eq_()
eq_.Tensor(Tensor(a!) self, Tensor other) -> Tensor(a!)eq_.Scalar(Tensor(a!) self, Scalar other) -> Tensor(a!)
- equal(other) bool
True if two tensors have the same size and elements, False otherwise.
- erf()
erf(Tensor self) -> Tensor
- erf_()
erf_(Tensor(a!) self) -> Tensor(a!)
- erfc()
erfc(Tensor self) -> Tensor
- erfc_()
erfc_(Tensor(a!) self) -> Tensor(a!)
- erfcx()
erfcx(Tensor self) -> Tensor
- erfinv()
erfinv(Tensor self) -> Tensor
- erfinv_()
erfinv_(Tensor(a!) self) -> Tensor(a!)
- exp()
exp(Tensor self) -> Tensor
- exp2()
exp2(Tensor self) -> Tensor
- exp2_()
exp2_(Tensor(a!) self) -> Tensor(a!)
- exp_()
exp_(Tensor(a!) self) -> Tensor(a!)
- expand()
expand(Tensor(a) self, SymInt[] size, *, bool implicit=False) -> Tensor(a)
- expand_as()
expand_as(Tensor(a) self, Tensor other) -> Tensor(a)
- expm1()
expm1(Tensor self) -> Tensor
- expm1_()
expm1_(Tensor(a!) self) -> Tensor(a!)
- exponential_()
exponential_(Tensor(a!) self, float lambd=1.0, *, Generator? generator=None) -> Tensor(a!)
- feature_alpha_dropout_()
feature_alpha_dropout_(Tensor(a!) self, float p=0.5, bool train=True) -> Tensor(a!)
- feature_dropout_()
feature_dropout_(Tensor(a!) self, float p=0.5, bool train=True) -> Tensor(a!)
- fill_()
fill_.Tensor(Tensor(a!) self, Tensor value) -> Tensor(a!)fill_.Scalar(Tensor(a!) self, Scalar value) -> Tensor(a!)
- fill_diagonal_()
fill_diagonal_(Tensor(a!) self, Scalar fill_value, bool wrap=False) -> Tensor(a!)
- fix()
fix(Tensor self) -> Tensor
- fix_()
fix_(Tensor(a!) self) -> Tensor(a!)
- flatten()
flatten.using_ints(Tensor(a) self, int start_dim=0, int end_dim=-1) -> Tensor(a)
- flip()
flip(Tensor self, int[] dims=[]) -> Tensor
- fliplr()
fliplr(Tensor self) -> Tensor
- flipud()
flipud(Tensor self) -> Tensor
- float_power()
float_power(Tensor self, Tensor exponent) -> Tensorfloat_power.Tensor_Tensor(Tensor self, Tensor exponent) -> Tensorfloat_power.Tensor_Scalar(Tensor self, Scalar exponent) -> Tensor
- float_power_()
float_power_.Tensor(Tensor(a!) self, Tensor exponent) -> Tensor(a!)float_power_.Scalar(Tensor(a!) self, Scalar exponent) -> Tensor(a!)
- floor()
floor(Tensor self) -> Tensor
- floor_()
floor_(Tensor(a!) self) -> Tensor(a!)
- floor_divide()
floor_divide(Tensor self, Tensor other) -> Tensorfloor_divide.Scalar(Tensor self, Scalar other) -> Tensor
- floor_divide_()
floor_divide_.Tensor(Tensor(a!) self, Tensor other) -> Tensor(a!)floor_divide_.Scalar(Tensor(a!) self, Scalar other) -> Tensor(a!)
- fmax()
fmax(Tensor self, Tensor other) -> Tensor
- fmin()
fmin(Tensor self, Tensor other) -> Tensor
- fmod()
fmod.Tensor(Tensor self, Tensor other) -> Tensorfmod.Scalar(Tensor self, Scalar other) -> Tensor
- fmod_()
fmod_.Tensor(Tensor(a!) self, Tensor other) -> Tensor(a!)fmod_.Scalar(Tensor(a!) self, Scalar other) -> Tensor(a!)
- frac()
frac(Tensor self) -> Tensor
- frac_()
frac_(Tensor(a!) self) -> Tensor(a!)
- frexp()
frexp.Tensor(Tensor self) -> (Tensor mantissa, Tensor exponent)
- gather()
gather(Tensor self, int dim, Tensor index) -> Tensor
- gcd()
gcd(Tensor self, Tensor other) -> Tensor
- gcd_()
gcd_(Tensor(a!) self, Tensor other) -> Tensor(a!)
- ge()
ge.Tensor(Tensor self, Tensor other) -> Tensorge.Scalar(Tensor self, Scalar other) -> Tensor
- ge_()
ge_.Tensor(Tensor(a!) self, Tensor other) -> Tensor(a!)ge_.Scalar(Tensor(a!) self, Scalar other) -> Tensor(a!)
- gelu()
gelu(Tensor self, str approximate="none") -> Tensor
- gelu_()
gelu_(Tensor(a!) self, str approximate="none") -> Tensor(a!)
- geometric_()
geometric_(Tensor(a!) self, float p, *, Generator? generator=None) -> Tensor(a!)
- geqrf()
geqrf(Tensor self) -> (Tensor a, Tensor tau)
- ger()
ger(Tensor self, Tensor vec2) -> Tensor
- get_device() int
- glu()
glu(Tensor self, int dim=-1) -> Tensor
- greater()
greater(Tensor self, Tensor other) -> Tensorgreater.Tensor(Tensor self, Tensor other) -> Tensorgreater.Scalar(Tensor self, Scalar other) -> Tensor
- greater_()
greater_.Tensor(Tensor(a!) self, Tensor other) -> Tensor(a!)greater_.Scalar(Tensor(a!) self, Scalar other) -> Tensor(a!)
- greater_equal()
greater_equal(Tensor self, Tensor other) -> Tensorgreater_equal.Tensor(Tensor self, Tensor other) -> Tensorgreater_equal.Scalar(Tensor self, Scalar other) -> Tensor
- greater_equal_()
greater_equal_.Tensor(Tensor(a!) self, Tensor other) -> Tensor(a!)greater_equal_.Scalar(Tensor(a!) self, Scalar other) -> Tensor(a!)
- gt()
gt.Tensor(Tensor self, Tensor other) -> Tensorgt.Scalar(Tensor self, Scalar other) -> Tensor
- gt_()
gt_.Tensor(Tensor(a!) self, Tensor other) -> Tensor(a!)gt_.Scalar(Tensor(a!) self, Scalar other) -> Tensor(a!)
- hardshrink()
hardshrink(Tensor self, Scalar lambd=0.5) -> Tensor
- hardshrink_backward()
hardshrink_backward(Tensor grad_out, Tensor self, Scalar lambd) -> Tensor
- hardsigmoid()
hardsigmoid(Tensor self) -> Tensor
- hardsigmoid_()
hardsigmoid_(Tensor(a!) self) -> Tensor(a!)
- hardswish()
hardswish(Tensor self) -> Tensor
- hardswish_()
hardswish_(Tensor(a!) self) -> Tensor(a!)
- hardtanh()
hardtanh(Tensor self, Scalar min_val=-1, Scalar max_val=1) -> Tensor
- hardtanh_()
hardtanh_(Tensor(a!) self, Scalar min_val=-1, Scalar max_val=1) -> Tensor(a!)
- hash_tensor()
hash_tensor(Tensor self, int[1] dim=[], *, bool keepdim=False, int mode=0) -> Tensor
- heaviside()
heaviside(Tensor self, Tensor values) -> Tensor
- heaviside_()
heaviside_(Tensor(a!) self, Tensor values) -> Tensor(a!)
- histc()
histc(Tensor self, int bins=100, Scalar min=0, Scalar max=0) -> Tensor
- histogram()
histogram.bins_tensor(Tensor self, Tensor bins, *, Tensor? weight=None, bool density=False) -> (Tensor hist, Tensor bin_edges)histogram.bin_ct(Tensor self, int bins=100, *, float[]? range=None, Tensor? weight=None, bool density=False) -> (Tensor hist, Tensor bin_edges)
- hsplit(split_size_or_sections) List of Tensors
Splits a tensor of at least two dimensions into views along the second axis.
split_size_or_sectionsis either the number of equal sections or the list of sizes of each section.See
tensorplay.hsplit()
- hypot()
hypot(Tensor self, Tensor other) -> Tensor
- hypot_()
hypot_(Tensor(a!) self, Tensor other) -> Tensor(a!)
- i0()
i0(Tensor self) -> Tensor
- i0_()
i0_(Tensor(a!) self) -> Tensor(a!)
- i0e()
i0e(Tensor self) -> Tensor
- i1()
i1(Tensor self) -> Tensor
- i1e()
i1e(Tensor self) -> Tensor
- igamma()
igamma(Tensor self, Tensor other) -> Tensor
- igamma_()
igamma_(Tensor(a!) self, Tensor other) -> Tensor(a!)
- igammac()
igammac(Tensor self, Tensor other) -> Tensor
- igammac_()
igammac_(Tensor(a!) self, Tensor other) -> Tensor(a!)
- index()
index.Tensor(Tensor self, Tensor?[] indices) -> Tensor
- index_add()
index_add(Tensor self, int dim, Tensor index, Tensor source) -> Tensor
- index_add_()
index_add_(Tensor(a!) self, int dim, Tensor index, Tensor source) -> Tensor(a!)
- index_copy()
index_copy(Tensor self, int dim, Tensor index, Tensor source) -> Tensor
- index_copy_()
index_copy_(Tensor(a!) self, int dim, Tensor index, Tensor source) -> Tensor(a!)
- index_fill()
index_fill.Tensor(Tensor self, int dim, Tensor index, Tensor value) -> Tensorindex_fill.int_Tensor(Tensor self, int dim, Tensor index, Tensor value) -> Tensorindex_fill.Scalar(Tensor self, int dim, Tensor index, Scalar value) -> Tensorindex_fill.int_Scalar(Tensor self, int dim, Tensor index, Scalar value) -> Tensor
- index_fill_()
index_fill_.Tensor(Tensor(a!) self, int dim, Tensor index, Tensor value) -> Tensor(a!)index_fill_.int_Tensor(Tensor(a!) self, int dim, Tensor index, Tensor value) -> Tensor(a!)index_fill_.Scalar(Tensor(a!) self, int dim, Tensor index, Scalar value) -> Tensor(a!)index_fill_.int_Scalar(Tensor(a!) self, int dim, Tensor index, Scalar value) -> Tensor(a!)
- index_put()
index_put(Tensor self, Tensor?[] indices, Tensor values, bool accumulate=False) -> Tensor
- index_put_()
index_put_(Tensor(a!) self, Tensor?[] indices, Tensor values, bool accumulate=False) -> Tensor(a!)
- index_reduce()
index_reduce(Tensor self, int dim, Tensor index, Tensor source, str reduce, *, bool include_self=True) -> Tensor
- index_reduce_()
index_reduce_(Tensor(a!) self, int dim, Tensor index, Tensor source, str reduce, *, bool include_self=True) -> Tensor(a!)
- index_select()
index_select(Tensor self, int dim, Tensor index) -> Tensor
- indices()
indices(Tensor(a) self) -> Tensor(a)
- inner()
inner(Tensor self, Tensor other) -> Tensor
- int_repr()
int_repr(Tensor self) -> Tensor
- inverse()
inverse(Tensor self) -> Tensor
- is_channels_last(self: tensorplay._C.TensorBase) bool
- is_channels_last_2d(self: tensorplay._C.TensorBase) bool
- is_channels_last_3d(self: tensorplay._C.TensorBase) bool
- is_complex(self: tensorplay._C.TensorBase) bool
- is_conj()
is_conj(Tensor self) -> bool
- is_distributed()
is_distributed(Tensor self) -> bool
- is_inference()
is_inference(Tensor self) -> bool
- is_neg()
is_neg(Tensor self) -> bool
- is_nested()
is_nested(Tensor self) -> bool
- is_nonzero()
is_nonzero(Tensor self) -> bool
- is_quantized()
is_quantized(Tensor self) -> bool
- is_same_size()
is_same_size(Tensor self, Tensor other) -> bool
- is_set_to()
is_set_to(Tensor self, Tensor tensor) -> bool
- is_signed()
is_signed(Tensor self) -> bool
- is_sparse_bsc(self: tensorplay._C.TensorBase) bool
- is_sparse_bsr(self: tensorplay._C.TensorBase) bool
- is_sparse_compressed(self: tensorplay._C.TensorBase) bool
- is_sparse_csc(self: tensorplay._C.TensorBase) bool
- is_sparse_csr(self: tensorplay._C.TensorBase) bool
- isclose()
isclose(Tensor self, Tensor other, float rtol=1e-05, float atol=1e-08, bool equal_nan=False) -> Tensor
- isfinite()
isfinite(Tensor self) -> Tensor
- isinf()
isinf(Tensor self) -> Tensor
- isnan()
isnan(Tensor self) -> Tensor
- isneginf()
isneginf(Tensor self) -> Tensor
- isposinf()
isposinf(Tensor self) -> Tensor
- isreal()
isreal(Tensor self) -> Tensor
- item()
item(Tensor self) -> Scalar
- itemsize(self: tensorplay._C.TensorBase) int
- kron()
kron(Tensor self, Tensor other) -> Tensor
- kthvalue()
kthvalue(Tensor self, SymInt k, int dim=-1, bool keepdim=False) -> (Tensor values, Tensor indices)
- lcm()
lcm(Tensor self, Tensor other) -> Tensor
- lcm_()
lcm_(Tensor(a!) self, Tensor other) -> Tensor(a!)
- ldexp()
ldexp(Tensor self, Tensor other) -> Tensorldexp.Tensor(Tensor self, Tensor other) -> Tensor
- ldexp_()
ldexp_(Tensor(a!) self, Tensor other) -> Tensor(a!)
- le()
le.Tensor(Tensor self, Tensor other) -> Tensorle.Scalar(Tensor self, Scalar other) -> Tensor
- le_()
le_.Tensor(Tensor(a!) self, Tensor other) -> Tensor(a!)le_.Scalar(Tensor(a!) self, Scalar other) -> Tensor(a!)
- leaky_relu()
leaky_relu(Tensor self, Scalar negative_slope=0.01) -> Tensor
- leaky_relu_()
leaky_relu_(Tensor(a!) self, Scalar negative_slope=0.01) -> Tensor(a!)
- lerp()
lerp.Tensor(Tensor self, Tensor end, Tensor weight) -> Tensorlerp(Tensor self, Tensor end, Scalar weight) -> Tensorlerp.Scalar(Tensor self, Tensor end, Scalar weight) -> Tensor
- lerp_()
lerp_.Tensor(Tensor(a!) self, Tensor end, Tensor weight) -> Tensor(a!)lerp_.Scalar(Tensor(a!) self, Tensor end, Scalar weight) -> Tensor(a!)
- less()
less(Tensor self, Tensor other) -> Tensorless.Tensor(Tensor self, Tensor other) -> Tensorless.Scalar(Tensor self, Scalar other) -> Tensor
- less_()
less_.Tensor(Tensor(a!) self, Tensor other) -> Tensor(a!)less_.Scalar(Tensor(a!) self, Scalar other) -> Tensor(a!)
- less_equal()
less_equal(Tensor self, Tensor other) -> Tensorless_equal.Tensor(Tensor self, Tensor other) -> Tensorless_equal.Scalar(Tensor self, Scalar other) -> Tensor
- less_equal_()
less_equal_.Tensor(Tensor(a!) self, Tensor other) -> Tensor(a!)less_equal_.Scalar(Tensor(a!) self, Scalar other) -> Tensor(a!)
- lgamma()
lgamma(Tensor self) -> Tensor
- lgamma_()
lgamma_(Tensor(a!) self) -> Tensor(a!)
- log()
log(Tensor self) -> Tensor
- log10()
log10(Tensor self) -> Tensor
- log10_()
log10_(Tensor(a!) self) -> Tensor(a!)
- log1p()
log1p(Tensor self) -> Tensor
- log1p_()
log1p_(Tensor(a!) self) -> Tensor(a!)
- log2()
log2(Tensor self) -> Tensor
- log2_()
log2_(Tensor(a!) self) -> Tensor(a!)
- log_()
log_(Tensor(a!) self) -> Tensor(a!)
- log_ndtr()
log_ndtr(Tensor self) -> Tensor
- log_normal_()
log_normal_(Tensor(a!) self, float mean=1.0, float std=2.0, *, Generator? generator=None) -> Tensor(a!)
- log_sigmoid()
log_sigmoid(Tensor self) -> Tensor
- log_softmax()
log_softmax(Tensor self, int dim, ScalarType dtype=Undefined) -> Tensorlog_softmax.int(Tensor self, int dim, ScalarType? dtype=None) -> Tensor
- logaddexp()
logaddexp(Tensor self, Tensor other) -> Tensor
- logaddexp2()
logaddexp2(Tensor self, Tensor other) -> Tensor
- logcumsumexp()
logcumsumexp(Tensor self, int dim, ScalarType? dtype=None) -> Tensor
- logdet()
logdet(Tensor self) -> Tensor
- logical_and()
logical_and(Tensor self, Tensor other) -> Tensor
- logical_and_()
logical_and_(Tensor(a!) self, Tensor other) -> Tensor(a!)
- logical_not()
logical_not(Tensor self) -> Tensor
- logical_not_()
logical_not_(Tensor(a!) self) -> Tensor(a!)
- logical_or()
logical_or(Tensor self, Tensor other) -> Tensor
- logical_or_()
logical_or_(Tensor(a!) self, Tensor other) -> Tensor(a!)
- logical_xor()
logical_xor(Tensor self, Tensor other) -> Tensor
- logical_xor_()
logical_xor_(Tensor(a!) self, Tensor other) -> Tensor(a!)
- logit()
logit(Tensor self, Scalar? eps=None) -> Tensor
- logit_()
logit_(Tensor(a!) self, Scalar? eps=None) -> Tensor(a!)
- logit_backward()
logit_backward(Tensor grad_output, Tensor self, Scalar? eps=None) -> Tensor
- logsumexp()
logsumexp(Tensor self, int[1] dim, bool keepdim=False) -> Tensor
- lt()
lt.Tensor(Tensor self, Tensor other) -> Tensorlt.Scalar(Tensor self, Scalar other) -> Tensor
- lt_()
lt_.Tensor(Tensor(a!) self, Tensor other) -> Tensor(a!)lt_.Scalar(Tensor(a!) self, Scalar other) -> Tensor(a!)
- lu_solve()
lu_solve(Tensor self, Tensor LU_data, Tensor LU_pivots) -> Tensor
- map2_(self: object, tensor1: tensorplay._C.TensorBase, tensor2: tensorplay._C.TensorBase, callable: object) object
- masked_fill()
masked_fill.Tensor(Tensor self, Tensor mask, Tensor value) -> Tensormasked_fill(Tensor self, Tensor mask, Scalar value) -> Tensormasked_fill.Scalar(Tensor self, Tensor mask, Scalar value) -> Tensor
- masked_fill_()
masked_fill_.Tensor(Tensor(a!) self, Tensor mask, Tensor value) -> Tensor(a!)masked_fill_(Tensor(a!) self, Tensor mask, Scalar value) -> Tensor(a!)masked_fill_.Scalar(Tensor(a!) self, Tensor mask, Scalar value) -> Tensor(a!)
- masked_scatter()
masked_scatter(Tensor self, Tensor mask, Tensor source) -> Tensor
- masked_scatter_()
masked_scatter_(Tensor(a!) self, Tensor mask, Tensor source) -> Tensor(a!)
- masked_select()
masked_select(Tensor self, Tensor mask) -> Tensor
- matmul()
matmul(Tensor self, Tensor other) -> Tensor
- matrix_H()
matrix_H(Tensor(a) self) -> Tensor(a)
- matrix_exp()
matrix_exp(Tensor self) -> Tensor
- matrix_power()
matrix_power(Tensor self, int n) -> Tensor
- maximum()
maximum(Tensor self, Tensor other) -> Tensor
- mean()
mean(Tensor self, *, ScalarType dtype=Undefined) -> Tensormean.dim(Tensor self, int[] dim, bool keepdim=false, *, ScalarType dtype=Undefined) -> Tensor
- median()
median(Tensor self) -> Tensormedian.dim(Tensor self, int dim, bool keepdim=False) -> (Tensor values, Tensor indices)
- memory_format(self: tensorplay._C.TensorBase) int
- minimum()
minimum(Tensor self, Tensor other) -> Tensor
- mish()
mish(Tensor self) -> Tensor
- mish_()
mish_(Tensor(a!) self) -> Tensor(a!)
- mm()
mm(Tensor self, Tensor mat2) -> Tensor
- mode()
mode(Tensor self, int dim=-1, bool keepdim=False) -> (Tensor values, Tensor indices)
- modified_bessel_i0()
modified_bessel_i0(Tensor self) -> Tensor
- modified_bessel_i1()
modified_bessel_i1(Tensor self) -> Tensor
- modified_bessel_k0()
modified_bessel_k0(Tensor self) -> Tensor
- modified_bessel_k1()
modified_bessel_k1(Tensor self) -> Tensor
- module_load(other, assign=False)
Defines how
otheris remapped before being swapped withselfwhen a state dictionary is loaded into the owning module.Returns a new object that is neither
selfnorother: the default isself.copy_(other).detach()unlessassignselects the detached source directly.
- moveaxis()
moveaxis.int(Tensor(a) self, int source, int destination) -> Tensor(a)moveaxis.intlist(Tensor(a) self, int[] source, int[] destination) -> Tensor(a)
- movedim()
movedim.int(Tensor(a) self, int source, int destination) -> Tensor(a)movedim(Tensor(a) self, int[] source, int[] destination) -> Tensor(a)movedim.intlist(Tensor(a) self, int[] source, int[] destination) -> Tensor(a)
- msort()
msort(Tensor self) -> Tensor
- mul()
mul.Tensor(Tensor self, Tensor other) -> Tensormul.Scalar(Tensor self, Scalar other) -> Tensor
- mul_()
mul_.Tensor(Tensor(a!) self, Tensor other) -> Tensor(a!)mul_.Scalar(Tensor(a!) self, Scalar other) -> Tensor(a!)
- multinomial()
multinomial(Tensor self, SymInt num_samples, bool replacement=false, *, Generator? generator=None) -> Tensor
- multiply()
multiply.Tensor(Tensor self, Tensor other) -> Tensormultiply.Scalar(Tensor self, Scalar other) -> Tensor
- multiply_()
multiply_.Tensor(Tensor(a!) self, Tensor other) -> Tensor(a!)multiply_.Scalar(Tensor(a!) self, Scalar other) -> Tensor(a!)
- mv()
mv(Tensor self, Tensor vec) -> Tensor
- mvlgamma()
mvlgamma(Tensor self, int p) -> Tensor
- mvlgamma_()
mvlgamma_(Tensor(a!) self, int p) -> Tensor(a!)
- nan_to_num()
nan_to_num(Tensor self, Scalar nan=0.0, Scalar? posinf=None, Scalar? neginf=None) -> Tensor
- nan_to_num_()
nan_to_num_(Tensor(a!) self, Scalar nan=0.0, Scalar? posinf=None, Scalar? neginf=None) -> Tensor(a!)
- nanmean()
nanmean(Tensor self, int? dim=None, bool keepdim=False, *, ScalarType? dtype=None) -> Tensor
- nanmedian()
nanmedian(Tensor self) -> Tensornanmedian.dim(Tensor self, int dim, bool keepdim=False) -> (Tensor values, Tensor indices)
- nanquantile()
nanquantile.scalar(Tensor self, float q, int? dim=None, bool keepdim=False, *, str interpolation='linear') -> Tensor
- nansum()
nansum(Tensor self, int[] dim=[], bool keepdim=False) -> Tensor
- narrow()
narrow.Tensor(Tensor(a) self, int dim, Tensor start, SymInt length) -> Tensor(a)narrow(Tensor(a) self, int dim, SymInt start, SymInt length) -> Tensor(a)
- narrow_copy()
narrow_copy(Tensor self, int dim, SymInt start, SymInt length) -> Tensor
- native_channel_shuffle()
native_channel_shuffle(Tensor self, SymInt groups) -> Tensor
- nbytes(self: tensorplay._C.TensorBase) int
- ndimension() int
Alias for dim()
- ndtr()
ndtr(Tensor self) -> Tensor
- ndtri()
ndtri(Tensor self) -> Tensor
- ne()
ne.Tensor(Tensor self, Tensor other) -> Tensorne.Scalar(Tensor self, Scalar other) -> Tensor
- ne_()
ne_.Tensor(Tensor(a!) self, Tensor other) -> Tensor(a!)ne_.Scalar(Tensor(a!) self, Scalar other) -> Tensor(a!)
- neg()
neg(Tensor self) -> Tensor
- neg_()
neg_(Tensor(a!) self) -> Tensor(a!)
- negative()
negative(Tensor self) -> Tensor
- negative_()
negative_(Tensor(a!) self) -> Tensor(a!)
- nelement() int
Alias of numel().
- new(self: tensorplay._C.TensorBase, *args, **kwargs) tensorplay._C.TensorBase
- new_empty_strided()
new_empty_strided(Tensor self, SymInt[] size, SymInt[] stride, *, ScalarType? dtype=None, Layout? layout=None, Device? device=None, bool? pin_memory=None) -> Tensor
- nextafter()
nextafter(Tensor self, Tensor other) -> Tensor
- nextafter_()
nextafter_(Tensor(a!) self, Tensor other) -> Tensor(a!)
- nonzero_numpy()
nonzero_numpy(Tensor self) -> Tensor[]
- nonzero_static()
nonzero_static(Tensor self, *, SymInt size, int fill_value=-1) -> Tensor
- norm()
norm(Tensor self, float p=2.0) -> Tensornorm.dim(Tensor self, int[] dim, float p=2.0, bool keepdim=false) -> Tensornorm.ScalarOpt_dtype(Tensor self, Scalar? p, *, ScalarType dtype) -> Tensornorm.Scalar(Tensor self, Scalar p=2) -> Tensornorm.ScalarOpt_dim_dtype(Tensor self, Scalar? p, int[1] dim, bool keepdim, *, ScalarType dtype) -> Tensornorm.ScalarOpt_dim(Tensor self, Scalar? p, int[1] dim, bool keepdim=False) -> Tensor
- normal_()
normal_(Tensor(a!) self, float mean=0.0, float std=1.0, *, Generator? generator=None) -> Tensor(a!)
- not_equal()
not_equal(Tensor self, Tensor other) -> Tensornot_equal.Tensor(Tensor self, Tensor other) -> Tensornot_equal.Scalar(Tensor self, Scalar other) -> Tensor
- not_equal_()
not_equal_.Tensor(Tensor(a!) self, Tensor other) -> Tensor(a!)not_equal_.Scalar(Tensor(a!) self, Scalar other) -> Tensor(a!)
- numel() int
- numpy(self: object) numpy.ndarray
- numpy_T()
numpy_T(Tensor(a) self) -> Tensor(a)
- orgqr()
orgqr(Tensor self, Tensor input2) -> Tensor
- ormqr()
ormqr(Tensor self, Tensor input2, Tensor input3, bool left=True, bool transpose=False) -> Tensor
- outer()
outer(Tensor self, Tensor vec2) -> Tensor
- output_nr()
output_nr(Tensor self) -> int
- pdist()
pdist(Tensor self, float p=2.0) -> Tensor
- permute()
permute(Tensor(a) self, int[] dims) -> Tensor(a)
- pinverse()
pinverse(Tensor self, float rcond=1e-15) -> Tensor
- poisson()
poisson(Tensor self, Generator? generator=None) -> Tensor
- polygamma()
polygamma(int n, Tensor self) -> Tensor
- polygamma_()
polygamma_(Tensor(a!) self, int n) -> Tensor(a!)
- positive()
positive(Tensor(a) self) -> Tensor(a)
- pow()
pow.Tensor_Tensor(Tensor self, Tensor exponent) -> Tensorpow.Tensor_Scalar(Tensor self, Scalar exponent) -> Tensor
- pow_()
pow_.Tensor(Tensor(a!) self, Tensor exponent) -> Tensor(a!)pow_.Scalar(Tensor(a!) self, Scalar exponent) -> Tensor(a!)
- prelu()
prelu(Tensor self, Tensor weight) -> Tensor
- prod()
prod(Tensor self, *, ScalarType dtype=Undefined) -> Tensorprod.dim_IntList(Tensor self, int[] dim, bool keepdim=false, *, ScalarType dtype=Undefined) -> Tensorprod.dim_int(Tensor self, int dim, bool keepdim=False, *, ScalarType? dtype=None) -> Tensor
- put()
put(Tensor self, Tensor index, Tensor source, bool accumulate=False) -> Tensor
- put_()
put_(Tensor(a!) self, Tensor index, Tensor source, bool accumulate=False) -> Tensor(a!)
- q_per_channel_axis()
q_per_channel_axis(Tensor self) -> int
- q_per_channel_scales()
q_per_channel_scales(Tensor self) -> Tensor
- q_per_channel_zero_points()
q_per_channel_zero_points(Tensor self) -> Tensor
- q_scale()
q_scale(Tensor self) -> float
- q_zero_point()
q_zero_point(Tensor self) -> int
- qscheme()
qscheme(Tensor self) -> int
- quantile()
quantile.scalar(Tensor self, float q, int? dim=None, bool keepdim=False, *, str interpolation='linear') -> Tensor
- rad2deg()
rad2deg(Tensor self) -> Tensor
- rad2deg_()
rad2deg_(Tensor(a!) self) -> Tensor(a!)
- random_()
random_(Tensor(a!) self, *, Generator? generator=None) -> Tensor(a!)random_.from(Tensor(a!) self, int from, int? to, *, Generator? generator=None) -> Tensor(a!)random_.to(Tensor(a!) self, int to, *, Generator? generator=None) -> Tensor(a!)
- ravel()
ravel(Tensor(a) self) -> Tensor(a)
- reciprocal()
reciprocal(Tensor self) -> Tensor
- reciprocal_()
reciprocal_(Tensor(a!) self) -> Tensor(a!)
- register_hook(hook)
The hook is called every time a gradient with respect to this tensor is computed. It may modify the gradient by returning a replacement Tensor; returning
Noneleaves the gradient unchanged. Hooks compose in registration order.Returns a
RemovableHandlewhoseremove()method (or context-manager form) unregisters the hook.
- register_post_accumulate_grad_hook(hook)
The hook runs after the gradient has been accumulated into
self.grad. It receives the tensor (the parameter) and its return value is ignored; unlikeregister_hook()it cannot replace the gradient, but it may modifyself.gradin place. Only leaf tensors that require grad and are used in the autograd graph support this hook.Returns a
RemovableHandle.
- relu()
relu(Tensor self) -> Tensor
- relu6()
relu6(Tensor self) -> Tensor
- relu6_()
relu6_(Tensor(a!) self) -> Tensor(a!)
- relu_()
relu_(Tensor(a!) self) -> Tensor(a!)
- remainder()
remainder.Tensor(Tensor self, Tensor other) -> Tensorremainder.Scalar(Tensor self, Scalar other) -> Tensor
- remainder_()
remainder_.Tensor(Tensor(a!) self, Tensor other) -> Tensor(a!)remainder_.Scalar(Tensor(a!) self, Scalar other) -> Tensor(a!)
- renorm()
renorm(Tensor self, Scalar p, int dim, Scalar maxnorm) -> Tensor
- renorm_()
renorm_(Tensor(a!) self, Scalar p, int dim, Scalar maxnorm) -> Tensor(a!)
- repeat()
repeat(Tensor self, SymInt[] repeats) -> Tensor
- reshape()
reshape(Tensor(a) self, SymInt[] shape) -> Tensor(a)
- resize_()
resize_(Tensor(a!) self, SymInt[] size) -> Tensor(a!)
- resize_as_()
resize_as_(Tensor(a!) self, Tensor other, *, MemoryFormat? memory_format=None) -> Tensor(a!)
- resize_as_sparse_()
resize_as_sparse_(Tensor(a!) self, Tensor the_template) -> Tensor(a!)
- resolve_conj()
resolve_conj(Tensor(a) self) -> Tensor(a)
- resolve_neg()
resolve_neg(Tensor(a) self) -> Tensor(a)
- roll()
roll(Tensor self, SymInt[1] shifts, int[] dims=[]) -> Tensor
- rot90()
rot90(Tensor self, int k=1, int[] dims=[0,1]) -> Tensor
- round()
round(Tensor self) -> Tensorround.decimals(Tensor self, *, int decimals) -> Tensor
- round_()
round_(Tensor(a!) self) -> Tensor(a!)round_.decimals(Tensor(a!) self, *, int decimals) -> Tensor(a!)
- row_indices()
row_indices(Tensor(a) self) -> Tensor(a)
- rrelu()
rrelu(Tensor self, Scalar lower=0.125, Scalar upper=0.3333333333333333, bool training=False, Generator? generator=None) -> Tensor
- rrelu_()
rrelu_(Tensor(a!) self, Scalar lower=0.125, Scalar upper=0.3333333333333333, bool training=False, Generator? generator=None) -> Tensor(a!)
- rsqrt()
rsqrt(Tensor self) -> Tensor
- rsqrt_()
rsqrt_(Tensor(a!) self) -> Tensor(a!)
- scaled_modified_bessel_k0()
scaled_modified_bessel_k0(Tensor self) -> Tensor
- scaled_modified_bessel_k1()
scaled_modified_bessel_k1(Tensor self) -> Tensor
- scatter()
scatter.src(Tensor self, int dim, Tensor index, Tensor src) -> Tensorscatter.reduce(Tensor self, int dim, Tensor index, Tensor src, *, str reduce) -> Tensorscatter.value(Tensor self, int dim, Tensor index, Scalar value) -> Tensorscatter.value_reduce(Tensor self, int dim, Tensor index, Scalar value, *, str reduce) -> Tensor
- scatter_(dim, index, src=None, *, value=None, reduce=None) Tensor
Writes values from
src(or the scalarvalue) into this tensor at the positions picked byindexalongdim; the remaining coordinates of each written element come from its position insideindex. Withreduceset to"add"or"multiply"(Noneby default), a destination that receives several values accumulates them instead of keeping the last one. Returnsself.
- scatter_add()
scatter_add(Tensor self, int dim, Tensor index, Tensor src) -> Tensor
- scatter_add_()
scatter_add_(Tensor(a!) self, int dim, Tensor index, Tensor src) -> Tensor(a!)
- scatter_reduce()
scatter_reduce(Tensor self, int dim, Tensor index, Tensor src, str reduce, *, bool include_self=True) -> Tensorscatter_reduce.two(Tensor self, int dim, Tensor index, Tensor src, str reduce, *, bool include_self=True) -> Tensor
- scatter_reduce_(dim, index, src, reduce, *, include_self=True) Tensor
Reduces the values of
srcinto this tensor at the positions picked byindexalongdim, applying the reduction named byreduce:"sum","prod","mean","amax"or"amin". Wheninclude_selfis False, the original value of each destination element takes no part in the reduction. Returnsself.
- searchsorted(sorted_sequence, *, out_int32=False, right=False, side=None, sorter=None, out=None)
Insertion positions of self values in sorted_sequence.
- sec()
sec(Tensor self) -> Tensor
- select()
select.int(Tensor(a) self, int dim, SymInt index) -> Tensor(a)
- select_scatter()
select_scatter(Tensor self, Tensor src, int dim, SymInt index) -> Tensor
- selu()
selu(Tensor self) -> Tensor
- selu_()
selu_(Tensor(a!) self) -> Tensor(a!)
- set_()
set_.source_Storage(Tensor(a!) self, Storage source) -> Tensor(a!)set_.source_Storage_storage_offset(Tensor(a!) self, Storage source, SymInt storage_offset, SymInt[] size, SymInt[] stride=[]) -> Tensor(a!)set_.source_Tensor_storage_offset(Tensor(a!) self, Tensor source, SymInt storage_offset, SymInt[] size, SymInt[] stride=[]) -> Tensor(a!)set_.source_Tensor(Tensor(a!) self, Tensor source) -> Tensor(a!)set_(Tensor(a!) self) -> Tensor(a!)
- set_data()
set_data(Tensor(a!) self, Tensor new_data) -> ()
- sgn()
sgn(Tensor self) -> Tensor
- sgn_()
sgn_(Tensor(a!) self) -> Tensor(a!)
- shallow_copy_data()
shallow_copy_data(Tensor(a!) self, Tensor new_data) -> ()
- sigmoid()
sigmoid(Tensor self) -> Tensor
- sigmoid_()
sigmoid_(Tensor(a!) self) -> Tensor(a!)
- sigmoid_backward()
sigmoid_backward(Tensor grad_output, Tensor output) -> Tensor
- sign()
sign(Tensor self) -> Tensor
- sign_()
sign_(Tensor(a!) self) -> Tensor(a!)
- signbit()
signbit(Tensor self) -> Tensor
- silu()
silu(Tensor self) -> Tensor
- silu_()
silu_(Tensor(a!) self) -> Tensor(a!)
- sin()
sin(Tensor self) -> Tensor
- sin_()
sin_(Tensor(a!) self) -> Tensor(a!)
- sinc()
sinc(Tensor self) -> Tensor
- sinc_()
sinc_(Tensor(a!) self) -> Tensor(a!)
- sinh()
sinh(Tensor self) -> Tensor
- sinh_()
sinh_(Tensor(a!) self) -> Tensor(a!)
- size() int[]
- size(dim) int
- slice()
slice.Tensor(Tensor(a) self, int dim=0, SymInt? start=None, SymInt? end=None, SymInt step=1) -> Tensor(a)
- slice_inverse()
slice_inverse(Tensor(a) self, Tensor src, int dim=0, SymInt? start=None, SymInt? end=None, SymInt step=1) -> Tensor(a)
- slice_scatter()
slice_scatter(Tensor self, Tensor src, int dim=0, SymInt? start=None, SymInt? end=None, SymInt step=1) -> Tensor
- slogdet()
slogdet(Tensor self) -> (Tensor sign, Tensor logabsdet)
- smm()
smm(Tensor self, Tensor mat2) -> Tensor
- softmax()
softmax(Tensor self, int dim, ScalarType dtype=Undefined) -> Tensorsoftmax.int(Tensor self, int dim, ScalarType? dtype=None) -> Tensor
- softplus()
softplus(Tensor self, Scalar beta=1, Scalar threshold=20) -> Tensor
- softshrink()
softshrink(Tensor self, Scalar lambd=0.5) -> Tensor
- softshrink_backward()
softshrink_backward(Tensor grad_output, Tensor self, Scalar lambd) -> Tensor
- sort()
sort(Tensor self, int dim=-1, bool descending=False) -> (Tensor values, Tensor indices)sort.stable(Tensor self, *, bool? stable, int dim=-1, bool descending=False) -> (Tensor values, Tensor indices)
- sparse_mask(self: tensorplay._C.TensorBase, mask: tensorplay._C.TensorBase) tensorplay._C.TensorBase
- sparse_resize_()
sparse_resize_(Tensor(a!) self, int[] size, int sparse_dim, int dense_dim) -> Tensor(a!)
- sparse_resize_and_clear_()
sparse_resize_and_clear_(Tensor(a!) self, int[] size, int sparse_dim, int dense_dim) -> Tensor(a!)
- sparse_sum()
sparse_sum(Tensor self, int[]? dim=None, ScalarType? dtype=None) -> Tensor
- spherical_bessel_j0()
spherical_bessel_j0(Tensor self) -> Tensor
- split()
split(Tensor(a) self, int split_size, int dim=0) -> Tensor(a)[]split.Tensor(Tensor(a -> *) self, SymInt split_size, int dim=0) -> Tensor(a)[]split.sizes(Tensor(a) self, int[] split_sizes, int dim=0) -> Tensor(a)[]
- split_with_sizes()
split_with_sizes(Tensor(a) self, SymInt[] split_sizes, int dim=0) -> Tensor(a)[]
- sqrt()
sqrt(Tensor self) -> Tensor
- sqrt_()
sqrt_(Tensor(a!) self) -> Tensor(a!)
- square()
square(Tensor self) -> Tensor
- square_()
square_(Tensor(a!) self) -> Tensor(a!)
- squared_difference()
squared_difference(Tensor self, Tensor other) -> Tensor
- squeeze()
squeeze(Tensor(a) self) -> Tensor(a)squeeze.dim(Tensor(a) self, int dim) -> Tensor(a)squeeze.dims(Tensor(a) self, int[] dim) -> Tensor(a)
- squeeze_()
squeeze_(Tensor(a!) self) -> Tensor(a!)squeeze_.dim(Tensor(a!) self, int dim) -> Tensor(a!)squeeze_.dims(Tensor(a!) self, int[] dim) -> Tensor(a!)
- sspaddmm()
sspaddmm(Tensor self, Tensor mat1, Tensor mat2, *, Scalar beta=1, Scalar alpha=1) -> Tensor
- std()
std(Tensor self, int correction=1) -> Tensorstd.dim(Tensor self, int[] dim, int correction=1, bool keepdim=false) -> Tensorstd.correction(Tensor self, int[1]? dim=None, *, Scalar? correction=None, bool keepdim=False) -> Tensor
- stft()
stft.center(Tensor self, int n_fft, int? hop_length=None, int? win_length=None, Tensor? window=None, bool center=True, str pad_mode="reflect", bool normalized=False, bool? onesided=None, bool? return_complex=None, bool? align_to_window=None) -> Tensor
- storage_offset() int
- stride() int[]
- stride(dim) int
- sub()
sub.Tensor(Tensor self, Tensor other, *, Scalar alpha=1) -> Tensorsub.Scalar(Tensor self, Scalar other, Scalar alpha=1) -> Tensor
- sub_(other, *, alpha=1) Tensor
In-place version of
tensorplay.Tensor.sub()
- subtract()
subtract.Tensor(Tensor self, Tensor other, *, Scalar alpha=1) -> Tensorsubtract.Scalar(Tensor self, Scalar other, Scalar alpha=1) -> Tensor
- subtract_(other, *, alpha=1) Tensor
In-place version of
tensorplay.Tensor.subtract()
- sum()
sum(Tensor self, *, ScalarType dtype=Undefined) -> Tensorsum.dim_IntList(Tensor self, int[] dim, bool keepdim=false, *, ScalarType dtype=Undefined) -> Tensor
- sum_to_size()
sum_to_size(Tensor self, SymInt[] size) -> Tensor
- svd()
svd(Tensor self, bool some=True, bool compute_uv=True) -> (Tensor U, Tensor S, Tensor V)
- swapaxes()
swapaxes(Tensor(a) self, int axis0, int axis1) -> Tensor(a)
- swapaxes_()
swapaxes_(Tensor(a!) self, int axis0, int axis1) -> Tensor(a!)
- swapdims()
swapdims(Tensor(a) self, int dim0, int dim1) -> Tensor(a)
- swapdims_()
swapdims_(Tensor(a!) self, int dim0, int dim1) -> Tensor(a!)
- swish()
swish(Tensor self) -> Tensor
- t()
t(Tensor(a) self) -> Tensor(a)
- t_()
t_(Tensor(a!) self) -> Tensor(a!)
- take()
take(Tensor self, Tensor index) -> Tensor
- take_along_dim()
take_along_dim(Tensor self, Tensor indices, int? dim=None) -> Tensor
- tan()
tan(Tensor self) -> Tensor
- tan_()
tan_(Tensor(a!) self) -> Tensor(a!)
- tanh()
tanh(Tensor self) -> Tensor
- tanh_()
tanh_(Tensor(a!) self) -> Tensor(a!)
- tanh_backward()
tanh_backward(Tensor grad_output, Tensor output) -> Tensor
- tanhshrink()
tanhshrink(Tensor self) -> Tensor
- tensor_split(indices_or_sections, dim=0) List of Tensors
Splits this tensor into several views along
dim.indices_or_sectionsis either the number of equal sections, the list of boundary indices at which the split happens, or a 0-dimensional integer tensor holding those boundaries.See
tensorplay.tensor_split()
- threshold_()
threshold_(Tensor(a!) self, Scalar threshold, Scalar value) -> Tensor(a!)
- tile()
tile(Tensor self, SymInt[] dims) -> Tensor
- to_dense()
to_dense(Tensor self) -> Tensor
- to_mkldnn()
to_mkldnn(Tensor self, ScalarType? dtype=None) -> Tensor
- to_padded_tensor()
to_padded_tensor(Tensor self, float padding, SymInt[]? output_size=None) -> Tensor
- to_sparse()
to_sparse(Tensor self) -> Tensorto_sparse.sparse_dim(Tensor self, int sparse_dim) -> Tensor
- to_sparse_bsc()
to_sparse_bsc(Tensor self, int[2] blocksize, int? dense_dim=None) -> Tensor
- to_sparse_bsr()
to_sparse_bsr(Tensor self, int[2] blocksize, int? dense_dim=None) -> Tensor
- to_sparse_coo()
Convert a tensor to coordinate format.
- to_sparse_csc()
to_sparse_csc(Tensor self, int? dense_dim=None) -> Tensor
- to_sparse_csr()
to_sparse_csr(Tensor self) -> Tensor
- tolist(self: tensorplay._C.TensorBase) object
- trace()
trace(Tensor self) -> Tensor
- transpose()
transpose(Tensor(a) self, int dim0, int dim1) -> Tensor(a)transpose.int(Tensor(a) self, int dim0, int dim1) -> Tensor(a)
- transpose_()
transpose_(Tensor(a!) self, int dim0, int dim1) -> Tensor(a!)
- triangular_solve()
triangular_solve(Tensor self, Tensor A, bool upper=True, bool transpose=False, bool unitriangular=False) -> (Tensor solution, Tensor cloned_coefficient)
- tril()
tril(Tensor self, SymInt diagonal=0) -> Tensor
- tril_()
tril_(Tensor(a!) self, SymInt diagonal=0) -> Tensor(a!)
- triu()
triu(Tensor self, SymInt diagonal=0) -> Tensor
- triu_()
triu_(Tensor(a!) self, SymInt diagonal=0) -> Tensor(a!)
- true_divide()
true_divide.Tensor(Tensor self, Tensor other) -> Tensortrue_divide.Scalar(Tensor self, Scalar other) -> Tensor
- true_divide_()
true_divide_.Tensor(Tensor(a!) self, Tensor other) -> Tensor(a!)true_divide_.Scalar(Tensor(a!) self, Scalar other) -> Tensor(a!)
- trunc()
trunc(Tensor self) -> Tensor
- trunc_()
trunc_(Tensor(a!) self) -> Tensor(a!)
- type(dtype=None, non_blocking=False, **kwargs)
Returns the type if dtype is not provided, else casts this object to the specified type.
- unbind()
unbind(Tensor(a) self, int dim=0) -> Tensor(a)[]unbind.int(Tensor(a -> *) self, int dim=0) -> Tensor(a)[]
- unflatten()
unflatten.int(Tensor self, int dim, SymInt[] sizes) -> Tensor
- unfold()
unfold(Tensor(a) self, int dimension, int size, int step) -> Tensor(a)
- uniform_()
uniform_(Tensor(a!) self, float from=0.0, float to=1.0, *, Generator? generator=None) -> Tensor(a!)
- unsafe_chunk()
unsafe_chunk(Tensor self, int chunks, int dim=0) -> Tensor[]
- unsafe_split()
unsafe_split.Tensor(Tensor self, SymInt split_size, int dim=0) -> Tensor[]
- unsafe_split_with_sizes()
unsafe_split_with_sizes(Tensor self, SymInt[] split_sizes, int dim=0) -> Tensor[]
- unsqueeze()
unsqueeze(Tensor(a) self, int dim) -> Tensor(a)
- unsqueeze_()
unsqueeze_(Tensor(a!) self, int dim) -> Tensor(a!)
- untyped_storage(self: tensorplay._C.TensorBase) tensorplay._C.UntypedStorage
- var()
var(Tensor self, int correction=1) -> Tensorvar.dim(Tensor self, int[] dim, int correction=1, bool keepdim=false) -> Tensorvar.correction(Tensor self, int[1]? dim=None, *, Scalar? correction=None, bool keepdim=False) -> Tensor
- vdot()
vdot(Tensor self, Tensor other) -> Tensor
- view_as()
view_as(Tensor(a) self, Tensor other) -> Tensor(a)
- view_as_complex()
view_as_complex(Tensor(a) self) -> Tensor(a)
- view_as_real()
view_as_real(Tensor(a) self) -> Tensor(a)
- vsplit(split_size_or_sections) List of Tensors
Splits a tensor of at least two dimensions into views along the first axis.
split_size_or_sectionsis either the number of equal sections or the list of sizes of each section.See
tensorplay.vsplit()
- where()
where.self(Tensor condition, Tensor self, Tensor other) -> Tensorwhere.ScalarOther(Tensor condition, Tensor self, Scalar other) -> Tensor
- xlog1py()
xlog1py(Tensor self, Tensor other) -> Tensor
- xlog1py_()
xlog1py_(Tensor(a!) self, Tensor other) -> Tensor(a!)
- xlogy()
xlogy(Tensor self, Tensor other) -> Tensorxlogy.Tensor(Tensor self, Tensor other) -> Tensorxlogy.Scalar_Other(Tensor self, Scalar other) -> Tensor
- xlogy_()
xlogy_(Tensor(a!) self, Tensor other) -> Tensor(a!)xlogy_.Tensor(Tensor(a!) self, Tensor other) -> Tensor(a!)xlogy_.Scalar_Other(Tensor(a!) self, Scalar other) -> Tensor(a!)
- zero_()
zero_(Tensor(a!) self) -> Tensor(a!)
- zeta()
zeta(Tensor self, Tensor other) -> Tensor
CausalVariant
classFull reference ↗- class tensorplay.nn.attention.bias.CausalVariant(*values)[source]
Enum for causal variants used in attention mechanisms.
Defines two types of causal biases:
UPPER_LEFT: Represents upper-left triangular bias for standard causal attention. The equivalent code for constructing this bias is:tensorplay.tril(tensorplay.ones(size, dtype=tensorplay.bool))For instance, with
shape=(3,4), the materialized bias tensor will be:[[1, 0, 0, 0], [1, 1, 0, 0], [1, 1, 1, 0]]LOWER_RIGHT: Represents lower-right triangular bias, the include values are aligned to the lower right corner of the matrix.The equivalent code for constructing this bias is:
diagonal_offset = size[1] - size[0] tensorplay.tril( tensorplay.ones(size, dtype=tensorplay.bool), diagonal=diagonal_offset, )For instance, with
shape=(3,4), the materialized bias tensor will be:[[1, 1, 0, 0], [1, 1, 1, 0], [1, 1, 1, 1]]Note that these variants are equivalent to each other when the sequence lengths of the query and key/value tensors are equal since the triangular matrix is square.
Warning
This enum is a prototype and subject to change.
- 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)
Help improve this page
Found an error, an unclear step, or a missing example?

