mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-29 20:14:01 +00:00
MeanVarianceNormalization CPU EP axes attribute validation (#11925)
Validate axes attribute parameter properly rather than silently returning incorrect results
This commit is contained in:
parent
f54476a42f
commit
f6d2fe8311
1 changed files with 7 additions and 2 deletions
|
|
@ -105,10 +105,15 @@ class MeanVarianceNormalization_1 final : public MeanVarianceNormalization_0<T>
|
|||
if (!info.GetAttrs("axes", axes).IsOK()) {
|
||||
axes = {0, 2, 3};
|
||||
}
|
||||
if (find(axes.begin(), axes.end(), 1) != axes.end()) {
|
||||
constexpr int64_t cross_channel_axes[] = {0, 1, 2, 3};
|
||||
constexpr int64_t batch_spatial_axes[] = {0, 2, 3};
|
||||
|
||||
if (std::equal(std::begin(axes), std::end(axes), std::begin(cross_channel_axes), std::end(cross_channel_axes))) {
|
||||
this->across_channels_ = true;
|
||||
} else {
|
||||
} else if (std::equal(std::begin(axes), std::end(axes), std::begin(batch_spatial_axes), std::end(batch_spatial_axes))) {
|
||||
this->across_channels_ = false;
|
||||
} else {
|
||||
ORT_THROW("MeanVarianceNormalization CPU EP only supports NHW and NCHW reduction for axes attribute.");
|
||||
}
|
||||
this->normalize_variance_ = 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue