doc_content
stringlengths
1
386k
doc_id
stringlengths
5
188
torch.einsum(equation, *operands) β†’ Tensor [source] Sums the product of the elements of the input operands along dimensions specified using a notation based on the Einstein summation convention. Einsum allows computing many common multi-dimensional linear algebraic array operations by representing them in a short-han...
torch.generated.torch.einsum#torch.einsum
torch.empty(*size, *, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False, pin_memory=False) β†’ Tensor Returns a tensor filled with uninitialized data. The shape of the tensor is defined by the variable argument size. Parameters size (int...) – a sequence of integers defining the shape of th...
torch.generated.torch.empty#torch.empty
torch.empty_like(input, *, dtype=None, layout=None, device=None, requires_grad=False, memory_format=torch.preserve_format) β†’ Tensor Returns an uninitialized tensor with the same size as input. torch.empty_like(input) is equivalent to torch.empty(input.size(), dtype=input.dtype, layout=input.layout, device=input.devic...
torch.generated.torch.empty_like#torch.empty_like
torch.empty_strided(size, stride, *, dtype=None, layout=None, device=None, requires_grad=False, pin_memory=False) β†’ Tensor Returns a tensor filled with uninitialized data. The shape and strides of the tensor is defined by the variable argument size and stride respectively. torch.empty_strided(size, stride) is equival...
torch.generated.torch.empty_strided#torch.empty_strided
class torch.enable_grad [source] Context-manager that enables gradient calculation. Enables gradient calculation, if it has been disabled via no_grad or set_grad_enabled. This context manager is thread local; it will not affect computation in other threads. Also functions as a decorator. (Make sure to instantiate wit...
torch.generated.torch.enable_grad#torch.enable_grad
torch.eq(input, other, *, out=None) β†’ Tensor Computes element-wise equality The second argument can be a number or a tensor whose shape is broadcastable with the first argument. Parameters input (Tensor) – the tensor to compare other (Tensor or float) – the tensor or value to compare Keyword Arguments out (Te...
torch.generated.torch.eq#torch.eq
torch.equal(input, other) β†’ bool True if two tensors have the same size and elements, False otherwise. Example: >>> torch.equal(torch.tensor([1, 2]), torch.tensor([1, 2])) True
torch.generated.torch.equal#torch.equal
torch.erf(input, *, out=None) β†’ Tensor Computes the error function of each element. The error function is defined as follows: erf(x)=2Ο€βˆ«0xeβˆ’t2dt\mathrm{erf}(x) = \frac{2}{\sqrt{\pi}} \int_{0}^{x} e^{-t^2} dt Parameters input (Tensor) – the input tensor. Keyword Arguments out (Tensor, optional) – the output ten...
torch.generated.torch.erf#torch.erf
torch.erfc(input, *, out=None) β†’ Tensor Computes the complementary error function of each element of input. The complementary error function is defined as follows: erfc(x)=1βˆ’2Ο€βˆ«0xeβˆ’t2dt\mathrm{erfc}(x) = 1 - \frac{2}{\sqrt{\pi}} \int_{0}^{x} e^{-t^2} dt Parameters input (Tensor) – the input tensor. Keyword Argu...
torch.generated.torch.erfc#torch.erfc
torch.erfinv(input, *, out=None) β†’ Tensor Computes the inverse error function of each element of input. The inverse error function is defined in the range (βˆ’1,1)(-1, 1) as: erfinv(erf(x))=x\mathrm{erfinv}(\mathrm{erf}(x)) = x Parameters input (Tensor) – the input tensor. Keyword Arguments out (Tensor, optiona...
torch.generated.torch.erfinv#torch.erfinv
torch.exp(input, *, out=None) β†’ Tensor Returns a new tensor with the exponential of the elements of the input tensor input. yi=exiy_{i} = e^{x_{i}} Parameters input (Tensor) – the input tensor. Keyword Arguments out (Tensor, optional) – the output tensor. Example: >>> torch.exp(torch.tensor([0, math.log(2.)]...
torch.generated.torch.exp#torch.exp
torch.exp2(input, *, out=None) β†’ Tensor Computes the base two exponential function of input. yi=2xiy_{i} = 2^{x_{i}} Parameters input (Tensor) – the input tensor. Keyword Arguments out (Tensor, optional) – the output tensor. Example: >>> torch.exp2(torch.tensor([0, math.log2(2.), 3, 4])) tensor([ 1., 2., 8...
torch.generated.torch.exp2#torch.exp2
torch.expm1(input, *, out=None) β†’ Tensor Returns a new tensor with the exponential of the elements minus 1 of input. yi=exiβˆ’1y_{i} = e^{x_{i}} - 1 Parameters input (Tensor) – the input tensor. Keyword Arguments out (Tensor, optional) – the output tensor. Example: >>> torch.expm1(torch.tensor([0, math.log(2.)...
torch.generated.torch.expm1#torch.expm1
torch.eye(n, m=None, *, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) β†’ Tensor Returns a 2-D tensor with ones on the diagonal and zeros elsewhere. Parameters n (int) – the number of rows m (int, optional) – the number of columns with default being n Keyword Arguments out (Te...
torch.generated.torch.eye#torch.eye
torch.fake_quantize_per_channel_affine(input, scale, zero_point, quant_min, quant_max) β†’ Tensor Returns a new tensor with the data in input fake quantized per channel using scale, zero_point, quant_min and quant_max, across the channel specified by axis. output=min(quant_max,max(quant_min,std::nearby_int(input/scale...
torch.generated.torch.fake_quantize_per_channel_affine#torch.fake_quantize_per_channel_affine
torch.fake_quantize_per_tensor_affine(input, scale, zero_point, quant_min, quant_max) β†’ Tensor Returns a new tensor with the data in input fake quantized using scale, zero_point, quant_min and quant_max. output=min(quant_max,max(quant_min,std::nearby_int(input/scale)+zero_point))\text{output} = min( \text{quant\_max...
torch.generated.torch.fake_quantize_per_tensor_affine#torch.fake_quantize_per_tensor_affine
torch.fft Discrete Fourier transforms and related functions. Fast Fourier Transforms torch.fft.fft(input, n=None, dim=-1, norm=None) β†’ Tensor Computes the one dimensional discrete Fourier transform of input. Note The Fourier domain representation of any real signal satisfies the Hermitian property: X[i] = conj(X[-...
torch.fft
torch.fft.fft(input, n=None, dim=-1, norm=None) β†’ Tensor Computes the one dimensional discrete Fourier transform of input. Note The Fourier domain representation of any real signal satisfies the Hermitian property: X[i] = conj(X[-i]). This function always returns both the positive and negative frequency terms even t...
torch.fft#torch.fft.fft
torch.fft.fft2(input, s=None, dim=(-2, -1), norm=None) β†’ Tensor Computes the 2 dimensional discrete Fourier transform of input. Equivalent to fftn() but FFTs only the last two dimensions by default. Note The Fourier domain representation of any real signal satisfies the Hermitian property: X[i, j] = conj(X[-i, -j])....
torch.fft#torch.fft.fft2
torch.fft.fftfreq(n, d=1.0, *, dtype=None, layout=torch.strided, device=None, requires_grad=False) β†’ Tensor Computes the discrete Fourier Transform sample frequencies for a signal of size n. Note By convention, fft() returns positive frequency terms first, followed by the negative frequencies in reverse order, so th...
torch.fft#torch.fft.fftfreq
torch.fft.fftn(input, s=None, dim=None, norm=None) β†’ Tensor Computes the N dimensional discrete Fourier transform of input. Note The Fourier domain representation of any real signal satisfies the Hermitian property: X[i_1, ..., i_n] = conj(X[-i_1, ..., -i_n]). This function always returns all positive and negative f...
torch.fft#torch.fft.fftn
torch.fft.fftshift(input, dim=None) β†’ Tensor Reorders n-dimensional FFT data, as provided by fftn(), to have negative frequency terms first. This performs a periodic shift of n-dimensional data such that the origin (0, ..., 0) is moved to the center of the tensor. Specifically, to input.shape[dim] // 2 in each select...
torch.fft#torch.fft.fftshift
torch.fft.hfft(input, n=None, dim=-1, norm=None) β†’ Tensor Computes the one dimensional discrete Fourier transform of a Hermitian symmetric input signal. Note hfft()/ihfft() are analogous to rfft()/irfft(). The real FFT expects a real signal in the time-domain and gives a Hermitian symmetry in the frequency-domain. T...
torch.fft#torch.fft.hfft
torch.fft.ifft(input, n=None, dim=-1, norm=None) β†’ Tensor Computes the one dimensional inverse discrete Fourier transform of input. Parameters input (Tensor) – the input tensor n (int, optional) – Signal length. If given, the input will either be zero-padded or trimmed to this length before computing the IFFT. ...
torch.fft#torch.fft.ifft
torch.fft.ifft2(input, s=None, dim=(-2, -1), norm=None) β†’ Tensor Computes the 2 dimensional inverse discrete Fourier transform of input. Equivalent to ifftn() but IFFTs only the last two dimensions by default. Parameters input (Tensor) – the input tensor s (Tuple[int], optional) – Signal size in the transformed ...
torch.fft#torch.fft.ifft2
torch.fft.ifftn(input, s=None, dim=None, norm=None) β†’ Tensor Computes the N dimensional inverse discrete Fourier transform of input. Parameters input (Tensor) – the input tensor s (Tuple[int], optional) – Signal size in the transformed dimensions. If given, each dimension dim[i] will either be zero-padded or tri...
torch.fft#torch.fft.ifftn
torch.fft.ifftshift(input, dim=None) β†’ Tensor Inverse of fftshift(). Parameters input (Tensor) – the tensor in FFT order dim (int, Tuple[int], optional) – The dimensions to rearrange. Only dimensions specified here will be rearranged, any other dimensions will be left in their original order. Default: All dimens...
torch.fft#torch.fft.ifftshift
torch.fft.ihfft(input, n=None, dim=-1, norm=None) β†’ Tensor Computes the inverse of hfft(). input must be a real-valued signal, interpreted in the Fourier domain. The IFFT of a real signal is Hermitian-symmetric, X[i] = conj(X[-i]). ihfft() represents this in the one-sided form where only the positive frequencies belo...
torch.fft#torch.fft.ihfft
torch.fft.irfft(input, n=None, dim=-1, norm=None) β†’ Tensor Computes the inverse of rfft(). input is interpreted as a one-sided Hermitian signal in the Fourier domain, as produced by rfft(). By the Hermitian property, the output will be real-valued. Note Some input frequencies must be real-valued to satisfy the Hermi...
torch.fft#torch.fft.irfft
torch.fft.irfft2(input, s=None, dim=(-2, -1), norm=None) β†’ Tensor Computes the inverse of rfft2(). Equivalent to irfftn() but IFFTs only the last two dimensions by default. input is interpreted as a one-sided Hermitian signal in the Fourier domain, as produced by rfft2(). By the Hermitian property, the output will be...
torch.fft#torch.fft.irfft2
torch.fft.irfftn(input, s=None, dim=None, norm=None) β†’ Tensor Computes the inverse of rfftn(). input is interpreted as a one-sided Hermitian signal in the Fourier domain, as produced by rfftn(). By the Hermitian property, the output will be real-valued. Note Some input frequencies must be real-valued to satisfy the ...
torch.fft#torch.fft.irfftn
torch.fft.rfft(input, n=None, dim=-1, norm=None) β†’ Tensor Computes the one dimensional Fourier transform of real-valued input. The FFT of a real signal is Hermitian-symmetric, X[i] = conj(X[-i]) so the output contains only the positive frequencies below the Nyquist frequency. To compute the full output, use fft() Pa...
torch.fft#torch.fft.rfft
torch.fft.rfft2(input, s=None, dim=(-2, -1), norm=None) β†’ Tensor Computes the 2-dimensional discrete Fourier transform of real input. Equivalent to rfftn() but FFTs only the last two dimensions by default. The FFT of a real signal is Hermitian-symmetric, X[i, j] = conj(X[-i, -j]), so the full fft2() output contains r...
torch.fft#torch.fft.rfft2
torch.fft.rfftfreq(n, d=1.0, *, dtype=None, layout=torch.strided, device=None, requires_grad=False) β†’ Tensor Computes the sample frequencies for rfft() with a signal of size n. Note rfft() returns Hermitian one-sided output, so only the positive frequency terms are returned. For a real FFT of length n and with input...
torch.fft#torch.fft.rfftfreq
torch.fft.rfftn(input, s=None, dim=None, norm=None) β†’ Tensor Computes the N-dimensional discrete Fourier transform of real input. The FFT of a real signal is Hermitian-symmetric, X[i_1, ..., i_n] = conj(X[-i_1, ..., -i_n]) so the full fftn() output contains redundant information. rfftn() instead omits the negative fr...
torch.fft#torch.fft.rfftn
torch.fix(input, *, out=None) β†’ Tensor Alias for torch.trunc()
torch.generated.torch.fix#torch.fix
torch.flatten(input, start_dim=0, end_dim=-1) β†’ Tensor Flattens input by reshaping it into a one-dimensional tensor. If start_dim or end_dim are passed, only dimensions starting with start_dim and ending with end_dim are flattened. The order of elements in input is unchanged. Unlike NumPy’s flatten, which always copi...
torch.generated.torch.flatten#torch.flatten
torch.flip(input, dims) β†’ Tensor Reverse the order of a n-D tensor along given axis in dims. Note torch.flip makes a copy of input’s data. This is different from NumPy’s np.flip, which returns a view in constant time. Since copying a tensor’s data is more work than viewing that data, torch.flip is expected to be slo...
torch.generated.torch.flip#torch.flip
torch.fliplr(input) β†’ Tensor Flip tensor in the left/right direction, returning a new tensor. Flip the entries in each row in the left/right direction. Columns are preserved, but appear in a different order than before. Note Requires the tensor to be at least 2-D. Note torch.fliplr makes a copy of input’s data. Th...
torch.generated.torch.fliplr#torch.fliplr
torch.flipud(input) β†’ Tensor Flip tensor in the up/down direction, returning a new tensor. Flip the entries in each column in the up/down direction. Rows are preserved, but appear in a different order than before. Note Requires the tensor to be at least 1-D. Note torch.flipud makes a copy of input’s data. This is ...
torch.generated.torch.flipud#torch.flipud
class torch.FloatStorage(*args, **kwargs) [source] bfloat16() Casts this storage to bfloat16 type bool() Casts this storage to bool type byte() Casts this storage to byte type char() Casts this storage to char type clone() Returns a copy of this storage complex_double() Casts this st...
torch.storage#torch.FloatStorage
bfloat16() Casts this storage to bfloat16 type
torch.storage#torch.FloatStorage.bfloat16
bool() Casts this storage to bool type
torch.storage#torch.FloatStorage.bool
byte() Casts this storage to byte type
torch.storage#torch.FloatStorage.byte
char() Casts this storage to char type
torch.storage#torch.FloatStorage.char
clone() Returns a copy of this storage
torch.storage#torch.FloatStorage.clone
complex_double() Casts this storage to complex double type
torch.storage#torch.FloatStorage.complex_double
complex_float() Casts this storage to complex float type
torch.storage#torch.FloatStorage.complex_float
copy_()
torch.storage#torch.FloatStorage.copy_
cpu() Returns a CPU copy of this storage if it’s not already on the CPU
torch.storage#torch.FloatStorage.cpu
cuda(device=None, non_blocking=False, **kwargs) 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. Parameters device (int) – The destination GPU id. Defaults to the current device. non_bl...
torch.storage#torch.FloatStorage.cuda
data_ptr()
torch.storage#torch.FloatStorage.data_ptr
device
torch.storage#torch.FloatStorage.device
double() Casts this storage to double type
torch.storage#torch.FloatStorage.double
dtype
torch.storage#torch.FloatStorage.dtype
element_size()
torch.storage#torch.FloatStorage.element_size
fill_()
torch.storage#torch.FloatStorage.fill_
float() Casts this storage to float type
torch.storage#torch.FloatStorage.float
static from_buffer()
torch.storage#torch.FloatStorage.from_buffer
static from_file(filename, shared=False, size=0) β†’ Storage If shared is True, then memory is shared between all processes. All changes are written to the file. If shared is False, then the changes on the storage do not affect the file. size is the number of elements in the storage. If shared is False, then the file m...
torch.storage#torch.FloatStorage.from_file
get_device()
torch.storage#torch.FloatStorage.get_device
half() Casts this storage to half type
torch.storage#torch.FloatStorage.half
int() Casts this storage to int type
torch.storage#torch.FloatStorage.int
is_cuda: bool = False
torch.storage#torch.FloatStorage.is_cuda
is_pinned()
torch.storage#torch.FloatStorage.is_pinned
is_shared()
torch.storage#torch.FloatStorage.is_shared
is_sparse: bool = False
torch.storage#torch.FloatStorage.is_sparse
long() Casts this storage to long type
torch.storage#torch.FloatStorage.long
new()
torch.storage#torch.FloatStorage.new
pin_memory() Copies the storage to pinned memory, if it’s not already pinned.
torch.storage#torch.FloatStorage.pin_memory
resize_()
torch.storage#torch.FloatStorage.resize_
share_memory_() Moves the storage to shared memory. This is a no-op for storages already in shared memory and for CUDA storages, which do not need to be moved for sharing across processes. Storages in shared memory cannot be resized. Returns: self
torch.storage#torch.FloatStorage.share_memory_
short() Casts this storage to short type
torch.storage#torch.FloatStorage.short
size()
torch.storage#torch.FloatStorage.size
tolist() Returns a list containing the elements of this storage
torch.storage#torch.FloatStorage.tolist
type(dtype=None, non_blocking=False, **kwargs) Returns the type if dtype is not provided, else casts this object to the specified type. If this is already of the correct type, no copy is performed and the original object is returned. Parameters dtype (type or string) – The desired type non_blocking (bool) – If T...
torch.storage#torch.FloatStorage.type
torch.float_power(input, exponent, *, out=None) β†’ Tensor Raises input to the power of exponent, elementwise, in double precision. If neither input is complex returns a torch.float64 tensor, and if one or more inputs is complex returns a torch.complex128 tensor. Note This function always computes in double precision,...
torch.generated.torch.float_power#torch.float_power
torch.floor(input, *, out=None) β†’ Tensor Returns a new tensor with the floor of the elements of input, the largest integer less than or equal to each element. outi=⌊inputiβŒ‹\text{out}_{i} = \left\lfloor \text{input}_{i} \right\rfloor Parameters input (Tensor) – the input tensor. Keyword Arguments out (Tensor, o...
torch.generated.torch.floor#torch.floor
torch.floor_divide(input, other, *, out=None) β†’ Tensor Warning This function’s name is a misnomer. It actually rounds the quotient towards zero instead of taking its floor. This behavior will be deprecated in a future PyTorch release. Computes input divided by other, elementwise, and rounds each quotient towards ze...
torch.generated.torch.floor_divide#torch.floor_divide
torch.fmax(input, other, *, out=None) β†’ Tensor Computes the element-wise maximum of input and other. This is like torch.maximum() except it handles NaNs differently: if exactly one of the two elements being compared is a NaN then the non-NaN element is taken as the maximum. Only if both elements are NaN is NaN propag...
torch.generated.torch.fmax#torch.fmax
torch.fmin(input, other, *, out=None) β†’ Tensor Computes the element-wise minimum of input and other. This is like torch.minimum() except it handles NaNs differently: if exactly one of the two elements being compared is a NaN then the non-NaN element is taken as the minimum. Only if both elements are NaN is NaN propag...
torch.generated.torch.fmin#torch.fmin
torch.fmod(input, other, *, out=None) β†’ Tensor Computes the element-wise remainder of division. The dividend and divisor may contain both for integer and floating point numbers. The remainder has the same sign as the dividend input. Supports broadcasting to a common shape, type promotion, and integer and float inputs...
torch.generated.torch.fmod#torch.fmod
torch.frac(input, *, out=None) β†’ Tensor Computes the fractional portion of each element in input. outi=inputiβˆ’βŒŠβˆ£inputiβˆ£βŒ‹βˆ—sgn⁑(inputi)\text{out}_{i} = \text{input}_{i} - \left\lfloor |\text{input}_{i}| \right\rfloor * \operatorname{sgn}(\text{input}_{i}) Example: >>> torch.frac(torch.tensor([1, 2.5, -3.2])) tensor(...
torch.generated.torch.frac#torch.frac
torch.from_numpy(ndarray) β†’ Tensor Creates a Tensor from a numpy.ndarray. The returned tensor and ndarray share the same memory. Modifications to the tensor will be reflected in the ndarray and vice versa. The returned tensor is not resizable. It currently accepts ndarray with dtypes of numpy.float64, numpy.float32, ...
torch.generated.torch.from_numpy#torch.from_numpy
torch.full(size, fill_value, *, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) β†’ Tensor Creates a tensor of size size filled with fill_value. The tensor’s dtype is inferred from fill_value. Parameters size (int...) – a list, tuple, or torch.Size of integers defining the shape of the...
torch.generated.torch.full#torch.full
torch.full_like(input, fill_value, *, dtype=None, layout=torch.strided, device=None, requires_grad=False, memory_format=torch.preserve_format) β†’ Tensor Returns a tensor with the same size as input filled with fill_value. torch.full_like(input, fill_value) is equivalent to torch.full(input.size(), fill_value, dtype=in...
torch.generated.torch.full_like#torch.full_like
torch.futures Warning The torch.futures package is experimental and subject to change. This package provides a Future type that encapsulates an asynchronous execution and a set of utility functions to simplify operations on Future objects. Currently, the Future type is primarily used by the Distributed RPC Framework....
torch.futures
torch.futures.collect_all(futures) [source] Collects the provided Future objects into a single combined Future that is completed when all of the sub-futures are completed. Parameters futures (list) – a list of Future objects. Returns Returns a Future object to a list of the passed in Futures. Example:: >>> im...
torch.futures#torch.futures.collect_all
class torch.futures.Future Wrapper around a torch._C.Future which encapsulates an asynchronous execution of a callable, e.g. rpc_async(). It also exposes a set of APIs to add callback functions and set results. add_done_callback(self: torch._C.Future, arg0: function) β†’ None done() [source] Return True if this...
torch.futures#torch.futures.Future
add_done_callback(self: torch._C.Future, arg0: function) β†’ None
torch.futures#torch.futures.Future.add_done_callback
done() [source] Return True if this Future is done. A Future is done if it has a result or an exception.
torch.futures#torch.futures.Future.done
set_exception(result) [source] Set an exception for this Future, which will mark this Future as completed with an error and trigger all attached callbacks. Note that when calling wait()/value() on this Future, the exception set here will be raised inline. Parameters result (BaseException) – the exception for this F...
torch.futures#torch.futures.Future.set_exception
set_result(result) [source] Set the result for this Future, which will mark this Future as completed and trigger all attached callbacks. Note that a Future cannot be marked completed twice. Parameters result (object) – the result object of this Future. Example:: >>> import threading >>> import time >>> import t...
torch.futures#torch.futures.Future.set_result
then(callback) [source] Append the given callback function to this Future, which will be run when the Future is completed. Multiple callbacks can be added to the same Future, and will be invoked in the same order as they were added. The callback must take one argument, which is the reference to this Future. The callb...
torch.futures#torch.futures.Future.then
value(self: torch._C.Future) β†’ object
torch.futures#torch.futures.Future.value
wait() [source] Block until the value of this Future is ready. Returns The value held by this Future. If the function (callback or RPC) creating the value has thrown an error, this wait method will also throw an error.
torch.futures#torch.futures.Future.wait
torch.futures.wait_all(futures) [source] Waits for all provided futures to be complete, and returns the list of completed values. Parameters futures (list) – a list of Future object. Returns A list of the completed Future results. This method will throw an error if wait on any Future throws.
torch.futures#torch.futures.wait_all
torch.fx Overview This feature is under a Beta release and its API may change. FX is a toolkit for developers to use to transform nn.Module instances. FX consists of three main components: a symbolic tracer, an intermediate representation, and Python code generation. A demonstration of these components in action: impor...
torch.fx
class torch.fx.Graph [source] Graph is the main data structure used in the FX Intermediate Representation. It consists of a series of Node s, each representing callsites (or other syntactic constructs). The list of Node s, taken together, constitute a valid Python function. For example, the following code import torc...
torch.fx#torch.fx.Graph
call_function(the_function, args=None, kwargs=None, type_expr=None) [source] Insert a call_function Node into the Graph. A call_function node represents a call to a Python callable, specified by the_function. the_function can be Parameters the_function (Callable[.., Any]) – The function to be called. Can be any P...
torch.fx#torch.fx.Graph.call_function