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

Commit efad090

Browse files
committed
minor cleanup
1 parent a8e4f91 commit efad090

File tree

6 files changed

+17
-12
lines changed

6 files changed

+17
-12
lines changed

src/Creator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ struct DeferredArange : public Deferred
163163
llvm::SmallVector<int64_t> shape(1, -1); //::mlir::ShapedType::kDynamicSize);
164164
auto artype = ::imex::ptensor::PTensorType::get(builder.getContext(), ::mlir::RankedTensorType::get(shape, dtype), true);
165165
auto ar = builder.create<::imex::ptensor::ARangeOp>(loc, artype, start, end, step, true);
166-
auto setter = [this](uint64_t rank, void *allocated, void *aligned, intptr_t offset, intptr_t * sizes, intptr_t * strides) {
166+
auto setter = [this](uint64_t rank, void *allocated, void *aligned, intptr_t offset, const intptr_t * sizes, const intptr_t * strides) {
167167
// FIXME GC assert(allocated == aligned);
168168
assert(rank == 1);
169169
assert(strides[0] == 1);

src/EWBinOp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ struct DeferredEWBinOp : public Deferred
460460
// FIXME the type of the result is hard-coded to uint64_t
461461
auto rtyp = ivm[_a].first.getType();
462462
auto ewbo = builder.create<::imex::ptensor::EWBinOp>(loc, rtyp, builder.getI32IntegerAttr(ddpt2mlir(_op)), ivm[_a].first, ivm[_b].first);
463-
auto setter = [this](uint64_t rank, void *allocated, void *aligned, intptr_t offset, intptr_t * sizes, intptr_t * strides) {
463+
auto setter = [this](uint64_t rank, void *allocated, void *aligned, intptr_t offset, const intptr_t * sizes, const intptr_t * strides) {
464464
// FIXME GC assert(allocated == aligned);
465465
this->set_value(std::move(x::operatorx<uint64_t>::mk_tx(rank, allocated, aligned, offset, sizes, strides)));
466466
};

src/ReduceOp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ struct DeferredReduceOp : public Deferred
128128
true
129129
);
130130
auto rop = builder.create<::imex::ptensor::ReductionOp>(loc, rtyp, builder.getI32IntegerAttr(ddpt2mlir(_op)), a);
131-
auto setter = [this](uint64_t rank, void *allocated, void *aligned, intptr_t offset, intptr_t * sizes, intptr_t * strides) {
131+
auto setter = [this](uint64_t rank, void *allocated, void *aligned, intptr_t offset, const intptr_t * sizes, const intptr_t * strides) {
132132
// FIXME GC assert(allocated == aligned);
133133
this->set_value(std::move(x::operatorx<uint64_t>::mk_tx(rank, allocated, aligned, offset, sizes, strides)));
134134
};

src/Service.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ struct DeferredService : public Deferred
7474
default:
7575
throw(std::runtime_error("Unkown Service operation requested."));
7676
}
77-
77+
7878
return {};
7979
}
8080

src/include/ddptensor/jit/mlir.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace jit {
1717

1818
// function type for building body for linalg::generic
1919
using SetResFunc = std::function<void(
20-
uint64_t rank, void *allocated, void *aligned, intptr_t offset, intptr_t * sizes, intptr_t * strides)>;
20+
uint64_t rank, void *allocated, void *aligned, intptr_t offset, const intptr_t * sizes, const intptr_t * strides)>;
2121
using IdValueMap = std::unordered_map<id_type, std::pair<::mlir::Value, SetResFunc>>;
2222

2323
// initialize jit

src/include/ddptensor/x.hpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <type_traits>
1313
#include <sstream>
1414
#include <memory>
15+
#include <algorithm>
1516
#include <xtensor/xarray.hpp>
1617
#include <xtensor/xadapt.hpp>
1718
#include <xtensor/xstrided_view.hpp>
@@ -265,17 +266,21 @@ namespace x
265266
return std::make_shared<DPTensorX<T>>(std::forward<Ts>(args)...);
266267
}
267268

268-
static typename DPTensorX<T>::typed_ptr_type mk_tx(uint64_t rank, void *allocated, void *aligned, intptr_t offset, intptr_t * sizes, intptr_t * strides)
269+
static typename DPTensorX<T>::typed_ptr_type mk_tx(
270+
uint64_t rank,
271+
void *allocated,
272+
void *aligned,
273+
intptr_t offset,
274+
const intptr_t * sizes,
275+
const intptr_t * strides)
269276
{
270277
// FIXME strides/slices are not used
278+
T * dptr = reinterpret_cast<T*>(aligned) + offset;
271279
if(rank == 0) {
272-
return std::make_shared<DPTensorX<T>>(static_cast<T>(*reinterpret_cast<T*>(aligned)+offset));
280+
return std::make_shared<DPTensorX<T>>(*dptr);
273281
}
274-
shape_type shp(rank);
275-
for(int i = 0; i < rank; ++i) {
276-
shp[i] = sizes[i];
277-
}
278-
return std::make_shared<DPTensorX<T>>(shp, reinterpret_cast<T*>(aligned) + offset);
282+
shape_type shp(sizes, sizes+rank);
283+
return std::make_shared<DPTensorX<T>>(shp, dptr);
279284
}
280285

281286
template<typename X>

0 commit comments

Comments
 (0)