Skip to content

Commit 74eb5e3

Browse files
committed
API Change iota to range
1 parent 4062a12 commit 74eb5e3

File tree

15 files changed

+80
-80
lines changed

15 files changed

+80
-80
lines changed

include/af/data.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ namespace af
7474
const dim_type d1, const dim_type d2,
7575
const dim_type d3, dtype ty=f32);
7676

77-
AFAPI array iota(const dim4 &dims, const int rep = -1, dtype ty=f32);
78-
AFAPI array iota(const dim_type d0, const dim_type d1 = 1, const dim_type d2 = 1,
77+
AFAPI array range(const dim4 &dims, const int rep = -1, dtype ty=f32);
78+
AFAPI array range(const dim_type d0, const dim_type d1 = 1, const dim_type d2 = 1,
7979
const dim_type d3 = 1, const int rep = -1, dtype ty=f32);
8080

8181
AFAPI array diag(const array &in, const int num = 0, const bool extract = true);
@@ -97,7 +97,7 @@ extern "C" {
9797
AFAPI af_err af_constant_ulong(af_array *arr, const uintl val, const unsigned ndims, const dim_type * const dims);
9898

9999
// Create sequence array
100-
AFAPI af_err af_iota(af_array *arr, const unsigned ndims, const dim_type * const dims,
100+
AFAPI af_err af_range(af_array *arr, const unsigned ndims, const dim_type * const dims,
101101
const int rep, const af_dtype type);
102102

103103
// Generate Random Numbers using uniform distribution

src/api/c/data.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include <handle.hpp>
2020
#include <random.hpp>
2121
#include <math.hpp>
22-
#include <iota.hpp>
22+
#include <range.hpp>
2323
#include <identity.hpp>
2424
#include <diagonal.hpp>
2525

@@ -403,13 +403,13 @@ af_err af_weak_copy(af_array *out, const af_array in)
403403
}
404404

405405
template<typename T>
406-
static inline af_array iota_(const dim4& d, const int rep)
406+
static inline af_array range_(const dim4& d, const int rep)
407407
{
408-
return getHandle(iota<T>(d, rep));
408+
return getHandle(range<T>(d, rep));
409409
}
410410

411411
//Strong Exception Guarantee
412-
af_err af_iota(af_array *result, const unsigned ndims, const dim_type * const dims,
412+
af_err af_range(af_array *result, const unsigned ndims, const dim_type * const dims,
413413
const int rep, const af_dtype type)
414414
{
415415
af_array out;
@@ -423,11 +423,11 @@ af_err af_iota(af_array *result, const unsigned ndims, const dim_type * const di
423423
}
424424

425425
switch(type) {
426-
case f32: out = iota_<float >(d, rep); break;
427-
case f64: out = iota_<double >(d, rep); break;
428-
case s32: out = iota_<int >(d, rep); break;
429-
case u32: out = iota_<uint >(d, rep); break;
430-
case u8: out = iota_<uchar >(d, rep); break;
426+
case f32: out = range_<float >(d, rep); break;
427+
case f64: out = range_<double >(d, rep); break;
428+
case s32: out = range_<int >(d, rep); break;
429+
case u32: out = range_<uint >(d, rep); break;
430+
case u8: out = range_<uchar >(d, rep); break;
431431
default: TYPE_ERROR(4, type);
432432
}
433433
std::swap(*result, out);

src/api/c/gaussian_kernel.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <arith.hpp>
1818
#include <math.hpp>
1919
#include <unary.hpp>
20-
#include <iota.hpp>
20+
#include <range.hpp>
2121
#include <reduce.hpp>
2222
#include <transpose.hpp>
2323

@@ -34,7 +34,7 @@ Array<T> gaussianKernel(const int rows, const int cols, const double sigma_r, co
3434
Array<T> zero = createValueArray<T>(odims, scalar<T>(0));
3535

3636
if (cols > 1) {
37-
Array<T> wt = iota<T>(dim4(cols, rows), 0);
37+
Array<T> wt = range<T>(dim4(cols, rows), 0);
3838
Array<T> w = transpose<T>(wt, false);
3939

4040
Array<T> c = createValueArray<T>(odims, scalar<T>((double)(cols - 1) / 2.0));
@@ -49,7 +49,7 @@ Array<T> gaussianKernel(const int rows, const int cols, const double sigma_r, co
4949
}
5050

5151
if (rows > 1) {
52-
Array<T> w = iota<T>(dim4(rows, cols), 0);
52+
Array<T> w = range<T>(dim4(rows, cols), 0);
5353

5454
Array<T> r = createValueArray<T>(odims, scalar<T>((double)(rows - 1) / 2.0));
5555
w = arithOp<T, af_sub_t>(w, r, odims);

src/api/cpp/data.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,17 +175,17 @@ namespace af
175175
return randn(dim4(d0, d1, d2, d3), ty);
176176
}
177177

178-
array iota(const dim4 &dims, const int rep, af::dtype ty)
178+
array range(const dim4 &dims, const int rep, af::dtype ty)
179179
{
180180
af_array out;
181-
AF_THROW(af_iota(&out, dims.ndims(), dims.get(), rep, ty));
181+
AF_THROW(af_range(&out, dims.ndims(), dims.get(), rep, ty));
182182
return array(out);
183183
}
184184

185-
array iota(const dim_type d0, const dim_type d1, const dim_type d2,
185+
array range(const dim_type d0, const dim_type d1, const dim_type d2,
186186
const dim_type d3, const int rep, af::dtype ty)
187187
{
188-
return iota(dim4(d0, d1, d2, d3), rep, ty);
188+
return range(dim4(d0, d1, d2, d3), rep, ty);
189189
}
190190

191191
array identity(const dim4 &dims, af::dtype type)

src/api/cpp/seq.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ seq::operator array() const
8080
{
8181
dim_type diff = s.end - s.begin;
8282
dim_type len = (int)((diff + abs(s.step) * (signbit(diff) == 0 ? 1 : -1)) / s.step);
83-
array tmp = (m_gfor) ? iota(1, 1, 1, len) : iota(len);
83+
array tmp = (m_gfor) ? range(1, 1, 1, len) : range(len);
8484
array res = s.begin + s.step * tmp;
8585
return res;
8686
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
********************************************************/
99

1010
#include <Array.hpp>
11-
#include <iota.hpp>
11+
#include <range.hpp>
1212
#include <math.hpp>
1313
#include <stdexcept>
1414
#include <err_cpu.hpp>
@@ -21,7 +21,7 @@ namespace cpu
2121
// Kernel Functions
2222
///////////////////////////////////////////////////////////////////////////
2323
template<typename T, unsigned rep>
24-
void iota(T *out, const dim4 &dim, const dim4 &strides)
24+
void range(T *out, const dim4 &dim, const dim4 &strides)
2525
{
2626
unsigned mul1 = rep > 0;
2727
unsigned mul2 = rep > 1;
@@ -48,7 +48,7 @@ namespace cpu
4848
// Wrapper Functions
4949
///////////////////////////////////////////////////////////////////////////
5050
template<typename T>
51-
Array<T> iota(const dim4& dim, const int rep)
51+
Array<T> range(const dim4& dim, const int rep)
5252
{
5353
// Repeat highest dimension, ie. creates a single sequence from
5454
// 0...elements - 1
@@ -59,18 +59,18 @@ namespace cpu
5959

6060
Array<T> out = createEmptyArray<T>(dim);
6161
switch(rep_) {
62-
case 0: iota<T, 0>(out.get(), out.dims(), out.strides()); break;
63-
case 1: iota<T, 1>(out.get(), out.dims(), out.strides()); break;
64-
case 2: iota<T, 2>(out.get(), out.dims(), out.strides()); break;
65-
case 3: iota<T, 3>(out.get(), out.dims(), out.strides()); break;
62+
case 0: range<T, 0>(out.get(), out.dims(), out.strides()); break;
63+
case 1: range<T, 1>(out.get(), out.dims(), out.strides()); break;
64+
case 2: range<T, 2>(out.get(), out.dims(), out.strides()); break;
65+
case 3: range<T, 3>(out.get(), out.dims(), out.strides()); break;
6666
default: AF_ERROR("Invalid rep selection", AF_ERR_INVALID_ARG);
6767
}
6868

6969
return out;
7070
}
7171

7272
#define INSTANTIATE(T) \
73-
template Array<T> iota<T>(const af::dim4 &dims, const int rep); \
73+
template Array<T> range<T>(const af::dim4 &dims, const int rep); \
7474

7575
INSTANTIATE(float)
7676
INSTANTIATE(double)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
namespace cpu
1515
{
1616
template<typename T>
17-
Array<T> iota(const dim4& dim, const int rep = -1);
17+
Array<T> range(const dim4& dim, const int rep = -1);
1818
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace cuda
2525

2626
template<typename T, unsigned rep>
2727
__global__
28-
void iota_kernel(Param<T> out, const dim_type blocksPerMatX, const dim_type blocksPerMatY)
28+
void range_kernel(Param<T> out, const dim_type blocksPerMatX, const dim_type blocksPerMatY)
2929
{
3030
const bool mul1 = rep > 0;
3131
const bool mul2 = rep > 1;
@@ -70,7 +70,7 @@ namespace cuda
7070
// Wrapper functions
7171
///////////////////////////////////////////////////////////////////////////
7272
template<typename T, unsigned rep>
73-
void iota(Param<T> out)
73+
void range(Param<T> out)
7474
{
7575
dim3 threads(TX, TY, 1);
7676

@@ -80,7 +80,7 @@ namespace cuda
8080
blocksPerMatY * out.dims[3],
8181
1);
8282

83-
iota_kernel<T, rep><<<blocks, threads>>>(out, blocksPerMatX, blocksPerMatY);
83+
range_kernel<T, rep><<<blocks, threads>>>(out, blocksPerMatX, blocksPerMatY);
8484
POST_LAUNCH_CHECK();
8585
}
8686
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
********************************************************/
99

1010
#include <Array.hpp>
11-
#include <iota.hpp>
12-
#include <kernel/iota.hpp>
11+
#include <range.hpp>
12+
#include <kernel/range.hpp>
1313
#include <math.hpp>
1414
#include <stdexcept>
1515
#include <err_cuda.hpp>
1616

1717
namespace cuda
1818
{
1919
template<typename T>
20-
Array<T> iota(const dim4& dim, const int rep)
20+
Array<T> range(const dim4& dim, const int rep)
2121
{
2222
// Repeat highest dimension, ie. creates a single sequence from
2323
// 0...elements - 1
@@ -28,17 +28,17 @@ namespace cuda
2828

2929
Array<T> out = createEmptyArray<T>(dim);
3030
switch(rep_) {
31-
case 0: kernel::iota<T, 0>(out); break;
32-
case 1: kernel::iota<T, 1>(out); break;
33-
case 2: kernel::iota<T, 2>(out); break;
34-
case 3: kernel::iota<T, 3>(out); break;
31+
case 0: kernel::range<T, 0>(out); break;
32+
case 1: kernel::range<T, 1>(out); break;
33+
case 2: kernel::range<T, 2>(out); break;
34+
case 3: kernel::range<T, 3>(out); break;
3535
default: AF_ERROR("Invalid rep selection", AF_ERR_INVALID_ARG);
3636
}
3737
return out;
3838
}
3939

4040
#define INSTANTIATE(T) \
41-
template Array<T> iota<T>(const af::dim4 &dims, const int rep); \
41+
template Array<T> range<T>(const af::dim4 &dims, const int rep); \
4242

4343
INSTANTIATE(float)
4444
INSTANTIATE(double)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
namespace cuda
1515
{
1616
template<typename T>
17-
Array<T> iota(const dim4& dim, const int rep = -1);
17+
Array<T> range(const dim4& dim, const int rep = -1);
1818
}

0 commit comments

Comments
 (0)