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

Function arithOpBroadcast

src/api/c/binary.cpp:69–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67
68template<typename T, af_op_t op>
69static inline af_array arithOpBroadcast(const af_array lhs,
70 const af_array rhs) {
71 const ArrayInfo &linfo = getInfo(lhs);
72 const ArrayInfo &rinfo = getInfo(rhs);
73
74 dim4 odims(1), ltile(1), rtile(1);
75 dim4 lshape = linfo.dims();
76 dim4 rshape = rinfo.dims();
77
78 for (int d = 0; d < AF_MAX_DIMS; ++d) {
79 DIM_ASSERT(
80 1, ((lshape[d] == rshape[d]) || (lshape[d] == 1 && rshape[d] > 1) ||
81 (lshape[d] > 1 && rshape[d] == 1)));
82 odims[d] = std::max(lshape[d], rshape[d]);
83 if (lshape[d] == rshape[d]) {
84 ltile[d] = rtile[d] = 1;
85 } else if (lshape[d] == 1 && rshape[d] > 1) {
86 ltile[d] = odims[d];
87 } else if (lshape[d] > 1 && rshape[d] == 1) {
88 rtile[d] = odims[d];
89 }
90 }
91
92 Array<T> lhst =
93 arrayfire::common::tile<T>(modDims(getArray<T>(lhs), lshape), ltile);
94 Array<T> rhst =
95 arrayfire::common::tile<T>(modDims(getArray<T>(rhs), rshape), rtile);
96
97 return getHandle(arithOp<T, op>(lhst, rhst, odims));
98}
99
100template<typename T, af_op_t op>
101static inline af_array sparseArithOp(const af_array lhs, const af_array rhs) {

Callers

nothing calls this directly

Calls 4

modDimsFunction · 0.70
getHandleFunction · 0.70
maxFunction · 0.50
dimsMethod · 0.45

Tested by

no test coverage detected