DenseSingleReduceFunction only handles stable cell types (for now)
@@ -119,9 +119,9 @@ void my_single_reduce_op(InterpretedFunction::State &state, uint64_t param) {
struct MyGetFun {
template <typename R1, typename R2, typename R3, typename R4> static auto invoke() {
- using CT = CellValueType<R1::value.cell_type>;
- using AggrType = typename R2::template templ<CT>;
- return my_single_reduce_op<CT, AggrType, R3::value, R4::value>;
+ using OCT = CellValueType<R1::value.decay().cell_type>;
+ using AggrType = typename R2::template templ<OCT>;
+ return my_single_reduce_op<OCT, AggrType, R3::value, R4::value>;
}
};
@@ -229,7 +229,7 @@ DenseSingleReduceFunction::~DenseSingleReduceFunction() = default;
InterpretedFunction::Instruction
DenseSingleReduceFunction::compile_self(const ValueBuilderFactory &, Stash &stash) const
{
- auto op = typify_invoke<4,MyTypify,MyGetFun>(result_type().cell_meta().limit().not_scalar(),
+ auto op = typify_invoke<4,MyTypify,MyGetFun>(child().result_type().cell_meta().limit().not_scalar(),
_aggr,
(_reduce_size >= 8), (_inner_size == 1));
auto &params = stash.create<Params>(result_type(), _outer_size, _reduce_size, _inner_size);
@@ -241,6 +241,7 @@ DenseSingleReduceFunction::optimize(const TensorFunction &expr, Stash &stash)
{
if (auto reduce = as<Reduce>(expr)) {
const auto &child = reduce->child();
+ if (reduce->result_type().cell_meta().eq(child.result_type().cell_meta())) {
auto spec_list = make_dense_single_reduce_list(child.result_type(), reduce->aggr(), reduce->dimensions());
if (!spec_list.empty()) {
const auto *prev = &child;
@@ -250,6 +251,7 @@ DenseSingleReduceFunction::optimize(const TensorFunction &expr, Stash &stash)
return *prev;
}
}
+ }
return expr;
}
