@@ -20,32 +20,15 @@ namespace tensor {
2020using namespace dtype ;
2121using namespace device ;
2222
23- template <typename T, typename D> Tensor<T, D> arange (T start, T end, T step) {
24- auto n_elements = static_cast <size_t >((end - start) / step);
25-
26- TensorStorage<T, D> storage (n_elements);
27-
28- Shape shape{n_elements};
29-
30- Tensor<T, D> out{shape, std::move (storage)};
31-
32- size_t block_size = cuda::get_block_size (n_elements);
33- size_t grid_size = cuda::get_grid_size (n_elements, block_size);
34-
35- // Convert to device-native types for kernel call
36- auto * device_data = reinterpret_cast <Cuda<T>*>(out.data ()); // NOLINT
37- Cuda<T> device_start = to_device_type (start, D{});
38- Cuda<T> device_end = to_device_type (end, D{});
39- Cuda<T> device_step = to_device_type (step, D{});
40-
41- kernels::arange_kernel<<<grid_size, block_size>>> (device_data, device_start, device_end, device_step, n_elements);
42-
43- return out;
23+ template <> Tensor<bfloat16, CUDA > arange (bfloat16 start, bfloat16 end, bfloat16 step) {
24+ return kernels::arange (start, end, step);
25+ }
26+ template <> Tensor<float , CUDA > arange (float start, float end, float step) {
27+ return kernels::arange (start, end, step);
28+ }
29+ template <> Tensor<int , CUDA > arange (int start, int end, int step) {
30+ return kernels::arange (start, end, step);
4431}
45-
46- template Tensor<int , CUDA > arange (int start, int end, int step);
47- template Tensor<float , CUDA > arange (float start, float end, float step);
48- template Tensor<bfloat16, CUDA > arange (bfloat16 start, bfloat16 end, bfloat16 step);
4932
5033template <typename T, typename D>
5134void replace_from_ (Tensor<T, D>& out, const TensorView<T, D>& input) {
0 commit comments