Shortcuts

torch.ldexp

torch.ldexp(input, other, *, out=None) → Tensor

Multiplies input by 2**:attr:other.

outi=inputi2iother\text{{out}}_i = \text{{input}}_i * 2^\text{{other}}_i

Typically this function is used to construct floating point numbers by multiplying mantissas in input with integral powers of two created from the exponents in :attr:’other’.

Parameters
  • input (Tensor) – the input tensor.

  • other (Tensor) – a tensor of exponents, typically integers.

Keyword Arguments

out (Tensor, optional) – the output tensor.

Example::
>>> torch.ldexp(torch.tensor([1.]), torch.tensor([1]))
tensor([2.])
>>> torch.ldexp(torch.tensor([1.0]), torch.tensor([1, 2, 3, 4]))
tensor([ 2.,  4.,  8., 16.])

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources