-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Description reducemax/min have been updated in onnx(20). implement it in ort ### Motivation and Context this is for ort1.17.0 release --------- Signed-off-by: Liqun Fu <[email protected]>
- Loading branch information
Showing
9 changed files
with
737 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
onnxruntime/core/providers/cpu/reduction/reduction_kernel_base.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#ifndef CORE_PROVIDERS_CPU_REDUCTION_KERNEL_BASE_H | ||
#define CORE_PROVIDERS_CPU_REDUCTION_KERNEL_BASE_H | ||
|
||
#ifndef SHARED_PROVIDER | ||
#include "core/common/optional.h" | ||
#include "core/framework/op_kernel.h" | ||
#endif | ||
|
||
namespace onnxruntime { | ||
|
||
template <bool allow_multi_axes> | ||
class ReduceKernelBase { | ||
protected: | ||
ReduceKernelBase(const OpKernelInfo& info, optional<int64_t> keepdims_override = {}) { | ||
if (allow_multi_axes) { | ||
axes_ = ToShapeVector(info.GetAttrsOrDefault<int64_t>("axes")); | ||
} else { | ||
auto v = info.GetAttrOrDefault<int64_t>("axis", 0); | ||
axes_.push_back(v); | ||
} | ||
int64_t keepdims = 1; | ||
if (keepdims_override.has_value()) { | ||
keepdims = *keepdims_override; | ||
} else { | ||
ORT_ENFORCE(info.GetAttr("keepdims", &keepdims).IsOK()); | ||
} | ||
keepdims_ = (keepdims == 1); | ||
int64_t noop_with_empty_axes = info.GetAttrOrDefault<int64_t>("noop_with_empty_axes", 0); | ||
noop_with_empty_axes_ = (noop_with_empty_axes == 1); | ||
int64_t select_last_index = info.GetAttrOrDefault<int64_t>("select_last_index", 0); | ||
select_last_index_ = (select_last_index != 0); | ||
} | ||
|
||
TensorShapeVector axes_; | ||
bool keepdims_; | ||
bool noop_with_empty_axes_; | ||
bool select_last_index_; | ||
}; | ||
} // namespace onnxruntime | ||
#endif // !CORE_PROVIDERS_CPU_REDUCTION_KERNEL_BASE_H |
Oops, something went wrong.