Skip to content

Commit

Permalink
fix(fronted): 修复reduce算子对reducesum的opset特判bug
Browse files Browse the repository at this point in the history
  • Loading branch information
bitzyz committed Jan 31, 2024
1 parent eea2249 commit 3f5b0ee
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/07onnx/src/operators/reduce.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,23 @@ namespace refactor::onnx {

auto noopWithEmptyAxes = false;
decltype(Op::axes) axes = std::nullopt;
if (opsetVer >= 18) {
noopWithEmptyAxes = attributes.getOrInsert( "noop_with_empty_axes", {0}).int_() != 0;

// 针对ReduceSum做特判
if (opType == "onnx::ReduceSum") {
if (opsetVer >= 13) {
noopWithEmptyAxes = attributes.getOrInsert("noop_with_empty_axes", {0}).int_() != 0;
} else {
axes.emplace(attributes.getOrInsert("axes", {{}}).ints());
}
} else {
axes.emplace(attributes.getOrInsert( "axes", {{}}).ints());
if (opsetVer >= 18) {
noopWithEmptyAxes = attributes.getOrInsert("noop_with_empty_axes", {0}).int_() != 0;
} else {
axes.emplace(attributes.getOrInsert("axes", {{}}).ints());
}
}

auto keepDims = attributes.getOrInsert( "keepdims", {1}).int_();
auto keepDims = attributes.getOrInsert("keepdims", {1}).int_();
Ty ty;
if (opType == "onnx::ReduceMean") {
ty = Ty::Mean;
Expand Down

0 comments on commit 3f5b0ee

Please sign in to comment.