Skip to content

Commit 709c829

Browse files
committed
Sparse API: createSparseArray() -> sparse()
1 parent 3d6a479 commit 709c829

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

include/af/sparse.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ namespace af
1515
{
1616
class array;
1717

18-
AFAPI array createSparseArray(const dim_t nRows, const dim_t nCols,
19-
const array values, const array rowIdx, const array colIdx,
20-
const af::storage stype = AF_STORAGE_CSR);
18+
AFAPI array sparse(const dim_t nRows, const dim_t nCols,
19+
const array values, const array rowIdx, const array colIdx,
20+
const af::storage stype = AF_STORAGE_CSR);
2121

22-
AFAPI array createSparseArray(const dim_t nRows, const dim_t nCols, const dim_t nNZ,
23-
const void* const values,
24-
const int * const rowIdx, const int * const colIdx,
25-
const dtype type = f32, const af::storage stype = AF_STORAGE_CSR,
26-
const af::source src = afHost);
22+
AFAPI array sparse(const dim_t nRows, const dim_t nCols, const dim_t nNZ,
23+
const void* const values,
24+
const int * const rowIdx, const int * const colIdx,
25+
const dtype type = f32, const af::storage stype = AF_STORAGE_CSR,
26+
const af::source src = afHost);
2727

28-
AFAPI array createSparseArray(const array dense, const af::storage stype = AF_STORAGE_CSR);
28+
AFAPI array sparse(const array dense, const af::storage stype = AF_STORAGE_CSR);
2929

3030
AFAPI array sparseConvertStorage(const array in, const af::storage stype);
3131

src/api/cpp/sparse.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@
1313

1414
namespace af
1515
{
16-
array createSparseArray(const dim_t nRows, const dim_t nCols,
17-
const array values, const array rowIdx, const array colIdx,
18-
const af::storage stype)
16+
array sparse(const dim_t nRows, const dim_t nCols,
17+
const array values, const array rowIdx, const array colIdx,
18+
const af::storage stype)
1919
{
2020
af_array out = 0;
2121
AF_THROW(af_create_sparse_array(&out, nRows, nCols,
2222
values.get(), rowIdx.get(), colIdx.get(), stype));
2323
return array(out);
2424
}
2525

26-
array createSparseArray(const dim_t nRows, const dim_t nCols, const dim_t nNZ,
27-
const void * const values,
28-
const int * const rowIdx, const int * const colIdx,
29-
const dtype type, const af::storage stype,
30-
const af::source src)
26+
array sparse(const dim_t nRows, const dim_t nCols, const dim_t nNZ,
27+
const void * const values,
28+
const int * const rowIdx, const int * const colIdx,
29+
const dtype type, const af::storage stype,
30+
const af::source src)
3131
{
3232
af_array out = 0;
3333
AF_THROW(af_create_sparse_array_from_ptr(&out, nRows, nCols, nNZ,
@@ -36,7 +36,7 @@ namespace af
3636
}
3737

3838

39-
array createSparseArray(const array dense, const af::storage stype)
39+
array sparse(const array dense, const af::storage stype)
4040
{
4141
af_array out = 0;
4242
AF_THROW(af_create_sparse_array_from_dense(&out, dense.get(), stype));

test/sparse.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void sparseTester(const int m, const int n, const int k, int factor, double eps)
8989
af::array dRes1 = matmul(A, B);
9090

9191
// Create Sparse Array From Dense
92-
af::array sA = af::createSparseArray(A, AF_STORAGE_CSR);
92+
af::array sA = af::sparse(A, AF_STORAGE_CSR);
9393

9494
// Sparse Matmul
9595
af::array sRes1 = matmul(sA, B);
@@ -121,7 +121,7 @@ void sparseTransposeTester(const int m, const int n, const int k, int factor, do
121121
af::array dRes3 = matmul(A, B, AF_MAT_CTRANS, AF_MAT_NONE);
122122

123123
// Create Sparse Array From Dense
124-
af::array sA = af::createSparseArray(A, AF_STORAGE_CSR);
124+
af::array sA = af::sparse(A, AF_STORAGE_CSR);
125125

126126
// Sparse Matmul
127127
af::array sRes2 = matmul(sA, B, AF_MAT_TRANS, AF_MAT_NONE);
@@ -146,7 +146,7 @@ void convertCSR(const int M, const int N, const float ratio)
146146
#endif
147147
a = a * (a > ratio);
148148

149-
af::array s = af::createSparseArray(a, AF_STORAGE_CSR);
149+
af::array s = af::sparse(a, AF_STORAGE_CSR);
150150
af::array aa = af::sparseConvertStorage(s, AF_STORAGE_DENSE);
151151

152152
ASSERT_EQ(0, af::max<double>(af::abs(a - aa)));

0 commit comments

Comments
 (0)