MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / arithOpD

Function arithOpD

src/backend/oneapi/sparse_arith.cpp:52–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50
51template<typename T, af_op_t op>
52Array<T> arithOpD(const SparseArray<T> &lhs, const Array<T> &rhs,
53 const bool reverse) {
54 lhs.eval();
55 rhs.eval();
56
57 Array<T> out = createEmptyArray<T>(dim4(0));
58 Array<T> zero = createValueArray<T>(rhs.dims(), scalar<T>(0));
59 switch (op) {
60 case af_add_t: out = copyArray<T>(rhs); break;
61 case af_sub_t:
62 out = reverse ? copyArray<T>(rhs)
63 : arithOp<T, af_sub_t>(zero, rhs, rhs.dims());
64 break;
65 default: out = copyArray<T>(rhs);
66 }
67 out.eval();
68 switch (lhs.getStorage()) {
69 case AF_STORAGE_CSR:
70 kernel::sparseArithOpCSR<T, op>(out, lhs.getValues(),
71 lhs.getRowIdx(), lhs.getColIdx(),
72 rhs, reverse);
73 break;
74 case AF_STORAGE_COO:
75 kernel::sparseArithOpCOO<T, op>(out, lhs.getValues(),
76 lhs.getRowIdx(), lhs.getColIdx(),
77 rhs, reverse);
78 break;
79 default:
80 AF_ERROR("Sparse Arithmetic only supported for CSR or COO",
81 AF_ERR_NOT_SUPPORTED);
82 }
83
84 return out;
85}
86
87template<typename T, af_op_t op>
88SparseArray<T> arithOp(const SparseArray<T> &lhs, const Array<T> &rhs,

Callers

nothing calls this directly

Calls 4

getStorageMethod · 0.80
dim4Class · 0.50
evalMethod · 0.45
dimsMethod · 0.45

Tested by

no test coverage detected