Skip to content

Commit

Permalink
Initialize a structure in operator ReduceSum (#6005)
Browse files Browse the repository at this point in the history
* fix initialisation issue
  • Loading branch information
xadupre authored and Du Li committed Dec 8, 2020
1 parent 317826b commit 3e39b38
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
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

0 comments on commit 3e39b38

Please sign in to comment.