Move lerp to ATen, add functionality for tensor weights (#17348)

Summary:
Changelog:
- Remove TH/THC bindings
- Add tensor weights for `lerp`
- Modify derivatives appropriately
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17348

Differential Revision: D14355845

Pulled By: soumith

fbshipit-source-id: eaede4c09ee589d77ba6cf52583510ea8e3a2fcf
This commit is contained in:
vishwakftw
2019-03-07 14:01:47 -08:00
committed by Facebook Github Bot
parent 6227afb305
commit 9d70e199f4
21 changed files with 320 additions and 113 deletions

View File

@ -2309,18 +2309,19 @@ add_docstr(torch.lerp,
lerp(start, end, weight, out=None)
Does a linear interpolation of two tensors :attr:`start` and :attr:`end` based
on a scalar :attr:`weight` and returns the resulting :attr:`out` tensor.
on a scalar or tensor :attr:`weight` and returns the resulting :attr:`out` tensor.
.. math::
\text{out}_i = \text{start}_i + \text{weight} \times (\text{end}_i - \text{start}_i)
\text{out}_i = \text{start}_i + \text{weight}_i \times (\text{end}_i - \text{start}_i)
The shapes of :attr:`start` and :attr:`end` must be
:ref:`broadcastable <broadcasting-semantics>`.
:ref:`broadcastable <broadcasting-semantics>`. If :attr:`weight` is a tensor, then
the shapes of :attr:`start`, :attr:`end` must be :ref:`broadcastable <broadcasting-semantics>`.
Args:
start (Tensor): the tensor with the starting points
end (Tensor): the tensor with the ending points
weight (float): the weight for the interpolation formula
weight (float or tensor): the weight for the interpolation formula
out (Tensor, optional): the output tensor
Example::
@ -2333,6 +2334,8 @@ Example::
tensor([ 10., 10., 10., 10.])
>>> torch.lerp(start, end, 0.5)
tensor([ 5.5000, 6.0000, 6.5000, 7.0000])
>>> torch.lerp(start, end, torch.full_like(start, 0.5))
tensor([ 5.5000, 6.0000, 6.5000, 7.0000])
""")
add_docstr(torch.linspace,