You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This came up in the context of the DynamicQuantizeLinear operator, which uses ReduceMin / ReduceMax in its definition. I noticed that there was no explicit handling of the case where the input is empty.
The spec-mandated behavior here of returning the minimum or maximum value for the type does have an issue that it can mask errors, less so with floats where the min/max values are +inf/-inf.
For ReduceMean the issue is worse because the handling of empty tenors is specified as undefined:
Reduction over an empty set of values yields undefined.
For RTen I think some general principles are needed for handling of situations that are allowed according to the spec, but highly likely to be errors, and behavior which is undefined according to the spec.
Some possible approaches for undefined behavior include:
Making the behavior deterministic, as eg. Rust does with float -> int casts using as. This may have a performance cost though.
Triggering an error (eg. as ReduceMean currently does with empty inputs)
Allowing the behavior to vary by platform, but specifying that it must have one of a fixed set outcomes. This is how WebAssembly relaxed SIMD handles cross-platform variation
The rten implementation of ReduceMin and ReduceMax returns an error if the tensor is empty. However the spec for eg. ReduceMax says:
The text was updated successfully, but these errors were encountered: