Describe the bug
HardMax fails with negative axis. It should call HandleNegativeAxis to resolve the value into an absolute positive axis.
HRESULT=0x80004005 message=Exception during initialization: S:\WindowsAI\engine\lotus\onnxruntime\core/providers/cpu/math/hardmax.h:24 onnxruntime::Hardmax<float>::Hardmax axis_ >= 0 was false. Invalid axis provided.
From ONNX spec: "Accepted range in [-r, r-1] where r = rank(input)."
https://github.com/onnx/onnx/blob/master/docs/Operators.md#Hardmax
Urgency
Preferably before Vibranium release.
System information
To Reproduce
Pass negative axis value. e.g.
// 2D array, axis 0 via negative axis.
{
"op_type": "Hardmax",
"axis": -2,
"input": [[0, 1, 2, -2, 2],
[0, 1, 2, -1, 3],
[0, 0, 3, 0, 0]],
"output": [[0, 0, 0, 0, 0],
[0, 0, 0, 0, 1],
[0, 0, 0, 0, 0]],
"T": "float32"
},
Expected behavior
HardMax should call HandleNegativeAxis to resolve the value into an absolute positive axis. Note GPU operator passes this.
๐ ArgMax
๐ ArgMin
๐ Concat
๐ Flatten
๐ Gather
โ Hardmax
๐ LogSoftmax
โ LpNormalization
๐ OneHot
๐ ReduceL1
๐ ReduceL2
๐ ReduceLogSum
๐ ReduceLogSumExp
๐ ReduceMax
๐ ReduceMean
๐ ReduceMin
๐ ReduceProd
๐ ReduceSum
๐ ReduceSumSquare
๐ Scatter
๐ Slice
๐ Softmax
๐ Split
๐ TopK
Additional context
Found while testing WinML ONNX conformance GPU vs CPU.
Hi @fdwr,
Actually the opset-10 HardMax spec is unclear - https://github.com/onnx/onnx/blob/rel-1.5.0/docs/Operators.md#Hardmax. The line you are referring to is from current master which means opset-11 HardMax needs to support it.
Having said that, it does seem reasonable to support negative axis for HardMax-10 as well.
@hariharans29 : True, that clarification was added recently. Though it's always been assumed, even when unstated, that operators with an axis attribute should resolve negative values (and for consistency, Softmax works in ORT, so HardMax would be expected to for consistency).
I tested the following for negative axes and found HardMax was the only one missing the check: ArgMin, ArgMax, Concat, Gather, Hardmax, LogSoftmax, ReduceL1, ReduceL2, ReduceLogSum, ReduceLogSumExp, ReduceMax, ReduceMean, ReduceMin, ReduceProd, ReduceSum, ReduceSumSquare, Scatter, Slice, Softmax, Split, TopK
@fdwr - makes sense to add it then :). Will do it.
@hariharans29 : Found one more (after double checking and sweeping through all of Operators.md for anything with an axis attribute) after adding LpNormalization, OneHot, Flatten.
LpNormalization accepts -1 but rejects -2.
Fixed via #1835