Skip to content
This repository was archived by the owner on Jan 26, 2026. It is now read-only.

Commit eafba26

Browse files
fschlimbtkarna
andauthored
reducing pass pipeline (now smaller and faster) (#21)
* reducing pass pipeline (now smaller and faster) * add tests for elementwise power and bitwise and --------- Co-authored-by: Tuomas Karna <tuomas.karna@intel.com>
1 parent 96d6adc commit eafba26

File tree

5 files changed

+32
-10
lines changed

5 files changed

+32
-10
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,5 +131,9 @@ jobs:
131131
export DDPT_CRUNNER_SO="$GITHUB_WORKSPACE"/third_party/install/llvm-mlir/lib/libmlir_c_runner_utils.so
132132
pytest test
133133
DDPT_FORCE_DIST=1 pytest test
134+
- name: Cleanup
135+
run: |
136+
pip list
137+
pip uninstall -y ddptensor
134138
- run: |
135139
echo "This job's status is ${{ job.status }}."

src/idtr.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,12 +280,9 @@ using MRIdx1d = Unranked1DMemRefType<int64_t>;
280280
template <typename T>
281281
void _idtr_reduce_all(int64_t dataRank, void *dataDescr, int op) {
282282
UnrankedMemRefType<T> data(dataRank, dataDescr);
283-
auto inout = data.data();
284-
auto sizes = data.sizes();
285-
auto strides = data.strides();
286-
assert(dataRank == 0 || (dataRank == 1 && strides[0] == 1));
283+
assert(dataRank == 0 || (dataRank == 1 && data.strides()[0] == 1));
287284
getTransceiver()->reduce_all(
288-
inout, DTYPE<T>::value, dataRank ? sizes[0] : 1,
285+
data.data(), DTYPE<T>::value, dataRank ? data.sizes()[0] : 1,
289286
mlir2ddpt(static_cast<imex::ptensor::ReduceOpId>(op)));
290287
}
291288

src/include/ddptensor/MemRefType.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@ template <typename T> class UnrankedMemRefType {
2020
UnrankedMemRefType(int64_t rank, void *p)
2121
: _rank(rank), _descriptor(reinterpret_cast<intptr_t *>(p)){};
2222

23-
T *data() { return reinterpret_cast<T *>(_descriptor[1]); };
23+
T *data() { return &reinterpret_cast<T *>(_descriptor[1])[_descriptor[2]]; };
2424
int64_t rank() const { return _rank; }
25-
int64_t *sizes() { return reinterpret_cast<int64_t *>(&_descriptor[3]); };
25+
int64_t *sizes() {
26+
return _rank ? reinterpret_cast<int64_t *>(&_descriptor[3]) : nullptr;
27+
};
2628
int64_t *strides() {
27-
return reinterpret_cast<int64_t *>(&_descriptor[3 + _rank]);
29+
return _rank ? reinterpret_cast<int64_t *>(&_descriptor[3 + _rank])
30+
: nullptr;
2831
};
2932
};
3033

src/jit/mlir.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,11 +405,11 @@ static const char *pass_pipeline =
405405
"func.func(tosa-to-tensor),"
406406
"canonicalize,"
407407
"linalg-fuse-elementwise-ops,"
408-
"convert-shape-to-std,"
408+
// "convert-shape-to-std,"
409409
"arith-expand,"
410410
"memref-expand,"
411411
"arith-bufferize,"
412-
"func-bufferize,"
412+
// "func-bufferize,"
413413
"func.func(empty-tensor-to-alloc-tensor),"
414414
"func.func(scf-bufferize),"
415415
"func.func(tensor-bufferize),"

test/test_ewb.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,21 @@ def test_prod_het(self):
6868
r = dt.sum(c, [0, 1])
6969
v = 16 * 16 * 2 * 2
7070
assert float(r) == v
71+
72+
def test_pow(self):
73+
for dtyp in [dt.int64, dt.float64]:
74+
a = dt.full((6, 6), 3, dtype=dtyp)
75+
b = dt.full((6, 6), 2, dtype=dtyp)
76+
c = a**b
77+
r1 = dt.sum(c, [0, 1])
78+
v = 6 * 6 * 9
79+
assert float(r1) == v
80+
81+
def test_bitwise_and(self):
82+
for dtyp in mpi_idtypes:
83+
a = dt.full((6, 6), 3, dtype=dtyp)
84+
b = dt.full((6, 6), 2, dtype=dtyp)
85+
c = a & b
86+
r1 = dt.sum(c, [0, 1])
87+
v = 6 * 6 * 2
88+
assert float(r1) == v

0 commit comments

Comments
 (0)