[FRONTEND] Added xor_sum
This commit is contained in:
@@ -1890,6 +1890,7 @@ void generator::visit_reduce_inst(ir::reduce_inst* x) {
|
||||
case ir::reduce_inst::FSUB: return fsub(x, y);
|
||||
case ir::reduce_inst::FMAX: return max_num(x, y);
|
||||
case ir::reduce_inst::FMIN: return min_num(x, y);
|
||||
case ir::reduce_inst::XOR: return xor_(x, y);
|
||||
default: throw std::runtime_error("unreachable");
|
||||
}
|
||||
};
|
||||
@@ -1904,6 +1905,7 @@ void generator::visit_reduce_inst(ir::reduce_inst* x) {
|
||||
case ir::reduce_inst::FSUB: neutral = ConstantFP::get(ty, 0); break;
|
||||
case ir::reduce_inst::FMAX: neutral = ConstantFP::get(ty, -INFINITY); break;
|
||||
case ir::reduce_inst::FMIN: neutral = ConstantFP::get(ty, INFINITY); break;
|
||||
case ir::reduce_inst::XOR: neutral = neutral = ConstantInt::get(ty, 0); break;
|
||||
default: throw std::runtime_error("unreachable");
|
||||
}
|
||||
ir::value *arg = x->get_operand(0);
|
||||
|
@@ -714,6 +714,13 @@ ir::value *dispatch::sum(ir::value *input, unsigned int axis, ir::builder *build
|
||||
return reduce_impl(input, axis, builder, "sum", ir::reduce_inst::FADD, ir::reduce_inst::ADD);
|
||||
}
|
||||
|
||||
ir::value *dispatch::xor_sum(ir::value *input, unsigned int axis, ir::builder *builder) {
|
||||
ir::type *scalar_ty = input->get_type()->get_scalar_ty();
|
||||
if (!scalar_ty->is_integer_ty())
|
||||
throw semantic_error("xor_sum only supported for integers");
|
||||
return reduce_impl(input, axis, builder, "sum", ir::reduce_inst::XOR, ir::reduce_inst::XOR);
|
||||
}
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Math
|
||||
|
Reference in New Issue
Block a user