26 int64_t num_elements = 0;
27 bool is_arange_valid =
true;
31 scalar_t sstart = start.
Item<scalar_t>();
32 scalar_t sstop = stop.
Item<scalar_t>();
33 scalar_t sstep = step.
Item<scalar_t>();
38 if (sstart == sstop) {
39 is_arange_valid =
false;
42 num_elements =
static_cast<int64_t
>(
43 std::ceil(
static_cast<double>(sstop - sstart) /
44 static_cast<double>(sstep)));
45 if (num_elements <= 0) {
46 is_arange_valid =
false;
51 if (!is_arange_valid) {
52 return Tensor({0}, dtype, device);
56 std::unordered_map<std::string, core::Tensor> srcs = {
66 }
else if (device.IsSYCL()) {
67 #ifdef BUILD_SYCL_MODULE
72 }
else if (device.IsCUDA()) {
73 #ifdef BUILD_CUDA_MODULE
74 ArangeCUDA(start, stop, step, dst);
#define DISPATCH_DTYPE_TO_TEMPLATE(DTYPE,...)
#define AssertTensorDevice(tensor,...)
#define AssertTensorShape(tensor,...)
Device GetDevice() const override
void ArangeCPU(const Tensor &start, const Tensor &stop, const Tensor &step, Tensor &dst)
void ArangeSYCL(const Tensor &start, const Tensor &stop, const Tensor &step, Tensor &dst)
Tensor Arange(const Tensor &start, const Tensor &stop, const Tensor &step)
MiniVec< float, N > ceil(const MiniVec< float, N > &a)
Generic file read and write utility for python interface.