torchoutil.nn.modules.tensor module

Module versions of tensor functions that do not already exists in PyTorch.

class Abs(
*,
strict_load: bool = False,
config_to_extra_repr: bool = False,
device_detect_mode: Literal['proxy', 'first_param', 'none'] = 'first_param',
)[source]

Bases: EModule

Module version of abs().

forward(
x: Tensor,
) Tensor[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class Angle(
*,
strict_load: bool = False,
config_to_extra_repr: bool = False,
device_detect_mode: Literal['proxy', 'first_param', 'none'] = 'first_param',
)[source]

Bases: EModule

Module version of angle().

forward(
x: Tensor,
) Tensor[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class Exp(
*,
strict_load: bool = False,
config_to_extra_repr: bool = False,
device_detect_mode: Literal['proxy', 'first_param', 'none'] = 'first_param',
)[source]

Bases: EModule

Module version of exp().

forward(
x: Tensor,
) Tensor[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class Exp2(
*,
strict_load: bool = False,
config_to_extra_repr: bool = False,
device_detect_mode: Literal['proxy', 'first_param', 'none'] = 'first_param',
)[source]

Bases: EModule

Module version of exp2().

forward(
x: Tensor,
) Tensor[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class FFT(
*,
strict_load: bool = False,
config_to_extra_repr: bool = False,
device_detect_mode: Literal['proxy', 'first_param', 'none'] = 'first_param',
)[source]

Bases: EModule

Module version of fft().

forward(
x: Tensor,
) Tensor[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class IFFT(
*,
strict_load: bool = False,
config_to_extra_repr: bool = False,
device_detect_mode: Literal['proxy', 'first_param', 'none'] = 'first_param',
)[source]

Bases: EModule

Module version of ifft().

forward(
x: Tensor,
) Tensor[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class Imag(
*,
return_zeros: bool = False,
)[source]

Bases: EModule

Module version of imag().

forward(
x: Tensor,
) Tensor[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class Interpolate(
size: int | Tuple[int, ...] | None = None,
scale_factor: float | Tuple[float, ...] | None = None,
mode: str = 'nearest',
align_corners: bool | None = None,
recompute_scale_factor: bool | None = None,
antialias: bool = False,
)[source]

Bases: EModule

Module version of interpolate().

forward(
x: Tensor,
) Tensor[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class Log(
*,
strict_load: bool = False,
config_to_extra_repr: bool = False,
device_detect_mode: Literal['proxy', 'first_param', 'none'] = 'first_param',
)[source]

Bases: EModule

Module version of log().

forward(
x: Tensor,
) Tensor[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class Log10(
*,
strict_load: bool = False,
config_to_extra_repr: bool = False,
device_detect_mode: Literal['proxy', 'first_param', 'none'] = 'first_param',
)[source]

Bases: EModule

Module version of log10().

forward(
x: Tensor,
) Tensor[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class Log2(
*,
strict_load: bool = False,
config_to_extra_repr: bool = False,
device_detect_mode: Literal['proxy', 'first_param', 'none'] = 'first_param',
)[source]

Bases: EModule

Module version of log2().

forward(
x: Tensor,
) Tensor[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class Max(
dim: int | None = None,
keepdim: bool = False,
*,
return_values: bool = True,
return_indices: bool | None = None,
)[source]

Bases: EModule

Module version of max().

extra_repr() str[source]

Set the extra representation of the module.

To print customized extra information, you should re-implement this method in your own modules. Both single-line and multi-line strings are acceptable.

forward(
x: Tensor,
) Tensor | max[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class Mean(
dim: int | None = None,
keepdim: bool = False,
dtype: dtype | None | Literal['default'] | str | DTypeEnum = None,
)[source]

Bases: EModule

Module version of mean().

extra_repr() str[source]

Set the extra representation of the module.

To print customized extra information, you should re-implement this method in your own modules. Both single-line and multi-line strings are acceptable.

forward(
x: Tensor,
) Tensor[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class Min(
dim: int | None = None,
keepdim: bool = False,
*,
return_values: bool = True,
return_indices: bool | None = None,
)[source]

Bases: EModule

Module version of min().

extra_repr() str[source]

Set the extra representation of the module.

To print customized extra information, you should re-implement this method in your own modules. Both single-line and multi-line strings are acceptable.

forward(
x: Tensor,
) Tensor | min[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class Normalize(
p: float = 2.0,
dim: int = 1,
eps: float = 1e-12,
)[source]

Bases: EModule

Module version of normalize().

extra_repr() str[source]

Set the extra representation of the module.

To print customized extra information, you should re-implement this method in your own modules. Both single-line and multi-line strings are acceptable.

forward(
x: Tensor,
) Tensor[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class Permute(
*args: int,
)[source]

Bases: EModule

Module version of permute().

extra_repr() str[source]

Set the extra representation of the module.

To print customized extra information, you should re-implement this method in your own modules. Both single-line and multi-line strings are acceptable.

forward(
x: Tensor,
) Tensor[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class Pow(
exponent: int | float | bool | Tensor,
)[source]

Bases: EModule

Module version of pow().

extra_repr() str[source]

Set the extra representation of the module.

To print customized extra information, you should re-implement this method in your own modules. Both single-line and multi-line strings are acceptable.

forward(
x: Tensor,
) Tensor[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class Real(
*,
strict_load: bool = False,
config_to_extra_repr: bool = False,
device_detect_mode: Literal['proxy', 'first_param', 'none'] = 'first_param',
)[source]

Bases: EModule

Module version of real().

forward(
x: Tensor,
) Tensor[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class Repeat(
*repeats: int,
)[source]

Bases: EModule

Module version of repeat().

extra_repr() str[source]

Set the extra representation of the module.

To print customized extra information, you should re-implement this method in your own modules. Both single-line and multi-line strings are acceptable.

forward(
x: Tensor,
) Tensor[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class RepeatInterleave(
repeats: int | Tensor,
dim: int,
output_size: int | None = None,
)[source]

Bases: EModule

Module version of repeat_interleave().

extra_repr() str[source]

Set the extra representation of the module.

To print customized extra information, you should re-implement this method in your own modules. Both single-line and multi-line strings are acceptable.

forward(
x: Tensor,
) Tensor[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class Reshape(
*shape: int,
)[source]

Bases: EModule

Module version of reshape().

extra_repr() str[source]

Set the extra representation of the module.

To print customized extra information, you should re-implement this method in your own modules. Both single-line and multi-line strings are acceptable.

forward(
x: Tensor,
) Tensor[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class TensorTo(
**kwargs,
)[source]

Bases: EModule

Module version of to().

extra_repr() str[source]

Set the extra representation of the module.

To print customized extra information, you should re-implement this method in your own modules. Both single-line and multi-line strings are acceptable.

forward(
x: Tensor,
) Tensor[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class ToList(
*,
strict_load: bool = False,
config_to_extra_repr: bool = False,
device_detect_mode: Literal['proxy', 'first_param', 'none'] = 'first_param',
)[source]

Bases: EModule

Module version of tolist().

forward(
x: Tensor,
) List[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class Transpose(
dim0: int,
dim1: int,
copy: bool = False,
)[source]

Bases: EModule

Module version of transpose().

extra_repr() str[source]

Set the extra representation of the module.

To print customized extra information, you should re-implement this method in your own modules. Both single-line and multi-line strings are acceptable.

forward(
x: Tensor,
) Tensor[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class View(
dtype: dtype,
/,
)[source]
class View(
size: Sequence[int],
/,
)
class View(
*size: int,
)

Bases: EModule

forward(
x: Tensor,
) Tensor[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.