1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
8 #include "core/Dispatch.h"
9 #include "core/ParallelFor.h"
10 #include "core/Tensor.h"
11 #include "core/kernel/Arange.h"
13 namespace cloudViewer {
17 void ArangeCUDA(const Tensor& start,
21 Dtype dtype = start.GetDtype();
22 DISPATCH_DTYPE_TO_TEMPLATE(dtype, [&]() {
23 scalar_t sstart = start.Item<scalar_t>();
24 scalar_t sstep = step.Item<scalar_t>();
25 scalar_t* dst_ptr = dst.GetDataPtr<scalar_t>();
26 int64_t n = dst.GetLength();
27 ParallelFor(start.GetDevice(), n,
28 [=] CLOUDVIEWER_HOST_DEVICE(int64_t workload_idx) {
29 dst_ptr[workload_idx] =
31 static_cast<scalar_t>(sstep * workload_idx);
38 } // namespace cloudViewer