Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize a structure in operator ReduceSum #6005

Merged
merged 4 commits into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions onnxruntime/core/providers/cpu/reduction/reduction_ops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ namespace onnxruntime {
x<int64_t>);

#define REGISTER_UNARY_ELEMENTWISE_VERSIONED_KERNEL_INT8_ONLY(x, startVer, endVer) \
ONNX_CPU_OPERATOR_VERSIONED_TYPED_KERNEL( \
x, \
startVer, \
endVer, \
ONNX_CPU_OPERATOR_VERSIONED_TYPED_KERNEL( \
x, \
startVer, \
endVer, \
int8_t, \
KernelDefBuilder().TypeConstraint("T", DataTypeImpl::GetTensorType<int8_t>()), \
x<int8_t>);
Expand Down Expand Up @@ -138,7 +138,6 @@ REGISTER_UNARY_ELEMENTWISE_KERNEL_INT64_ONLY(ReduceMax, 13);
REGISTER_UNARY_ELEMENTWISE_KERNEL_INT8_ONLY(ReduceMax, 13);
REGISTER_UNARY_ELEMENTWISE_KERNEL_UINT8_ONLY(ReduceMax, 13);


REGISTER_UNARY_ELEMENTWISE_VERSIONED_KERNEL(ReduceMean, 1, 10);
REGISTER_UNARY_ELEMENTWISE_VERSIONED_KERNEL(ReduceMean, 11, 12);
REGISTER_UNARY_ELEMENTWISE_KERNEL(ReduceMean, 13);
Expand Down Expand Up @@ -361,6 +360,9 @@ void NoTransposeReduce(Tensor* output, const TensorShape& new_input_shape, const
if (last_results.last_loop_red_size == 0 || last_results.last_loop_size == 0)
return;
}
ORT_ENFORCE(last_results.last_loop_red_size > 0);
ORT_ENFORCE(last_results.last_loop_size > 0);
ORT_ENFORCE(last_results.projected_index.size() > 0);
int64_t denominator = last_results.last_loop_red_size * last_results.projected_index.size();

if (AGG::two_loops()) {
Expand Down
8 changes: 8 additions & 0 deletions onnxruntime/core/providers/cpu/reduction/reduction_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ class ResultsNoTransposePrepareForReduce {
std::vector<int64_t> unprojected_index;
int64_t last_loop_size;
int64_t last_loop_inc;

ResultsNoTransposePrepareForReduce() : input_shape(), reduced_axes(), projected_index(), unprojected_index() {
last_loop_red_size = 0;
last_loop_red_inc = 0;
last_loop_size = 0;
last_loop_inc = 0;
}

bool equal(const std::vector<int64_t>& local_input_shape, const std::vector<int64_t>& local_reduced_axes) {
if (input_shape.size() != local_input_shape.size())
return false;
Expand Down