pytorch/aten/src/ATen/ExpandBase.h
Peter Bell 23b98202b5 Remove native_functions.yaml dependency from DistributionBernoulli.cu (#67721)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/67721

This moves the operator calls (`expand_inplace` and `to(kCUDA)`) into
`bernoulli_impl_` which is shared between CPU and CUDA. So that the
cuda code only needs to generates random numbers and nothing else.

The other changes are just rearranging includes to avoid including
`Tensor.h`.

Test Plan: Imported from OSS

Reviewed By: mruberry

Differential Revision: D32500426

Pulled By: malfet

fbshipit-source-id: f855c2055392355e79e3df832fa56d2041ebf24e
(cherry picked from commit 7ab7d17e94)
2022-02-15 15:18:40 +00:00

24 lines
883 B
C++

#include <ATen/core/TensorBase.h>
// Broadcasting utilities for working with TensorBase
namespace at {
namespace internal {
TORCH_API TensorBase expand_slow_path(const TensorBase &self, IntArrayRef size);
} // namespace internal
inline c10::MaybeOwned<TensorBase> expand_size(const TensorBase &self, IntArrayRef size) {
if (size.equals(self.sizes())) {
return c10::MaybeOwned<TensorBase>::borrowed(self);
}
return c10::MaybeOwned<TensorBase>::owned(
at::internal::expand_slow_path(self, size));
}
c10::MaybeOwned<TensorBase> expand_size(TensorBase &&self, IntArrayRef size) = delete;
inline c10::MaybeOwned<TensorBase> expand_inplace(const TensorBase &tensor, const TensorBase &to_expand) {
return expand_size(to_expand, tensor.sizes());
}
c10::MaybeOwned<TensorBase> expand_inplace(const TensorBase &tensor, TensorBase &&to_expand) = delete;
} // namespace at