forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lerp.cpp
45 lines (36 loc) · 1.42 KB
/
Lerp.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <ATen/native/Lerp.h>
#include <ATen/NativeFunctions.h>
namespace at {
namespace meta {
TORCH_META_FUNC(lerp_Tensor)(
const Tensor& self, const Tensor& end, const Tensor& weight) {
TORCH_CHECK(self.dtype() == end.dtype(), "expected dtype ", self.dtype(),
" for `end` but got dtype ", end.dtype());
TORCH_CHECK(self.dtype() == weight.dtype(), "expected dtype ", self.dtype(),
" for `weight` but got dtype ", weight.dtype());
build(at::TensorIteratorConfig()
.add_output(maybe_get_output())
.add_input(self)
.add_input(end)
.add_input(weight));
}
TORCH_META_FUNC(lerp_Scalar)(
const Tensor& self, const Tensor& end, const Scalar& /*weight*/) {
TORCH_CHECK(self.dtype() == end.dtype(), "expected dtype ", self.dtype(),
" for `end` but got dtype ", end.dtype());
build_binary_op(maybe_get_output(), self, end);
}
} // namespace meta
namespace native {
TORCH_IMPL_FUNC(lerp_Tensor)(
const Tensor& /*self*/, const Tensor& /*end*/, const Tensor& weight, const Tensor& /*out*/) {
lerp_kernel_tensor_weight(device_type(), *this);
}
TORCH_IMPL_FUNC(lerp_Scalar)(
const Tensor& /*self*/, const Tensor& /*end*/, const Scalar& weight, const Tensor& /*out*/) {
lerp_kernel_scalar_weight(device_type(), *this, weight);
}
DEFINE_DISPATCH(lerp_kernel_scalar_weight);
DEFINE_DISPATCH(lerp_kernel_tensor_weight);
} // namespace native
} // namespace at