mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-29 20:14:01 +00:00
[DML EP] Fix Clip clamping (#22251)
### Description <!-- Describe your changes. --> ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. -->
This commit is contained in:
parent
1e3cd86d80
commit
ebda23be16
1 changed files with 13 additions and 2 deletions
|
|
@ -451,8 +451,19 @@ public:
|
|||
// logic for some corner test case
|
||||
// Same applies to min and max value.
|
||||
opDesc.MinMaxDataType = this->m_inputTensorDescs[0].GetDmlDataType();
|
||||
CastToClampedScalarUnion<double>(opDesc.MinMaxDataType, -DBL_MAX, /*out*/&opDesc.Min);
|
||||
CastToClampedScalarUnion<double>(opDesc.MinMaxDataType, DBL_MAX, /*out*/&opDesc.Max);
|
||||
|
||||
if (opDesc.MinMaxDataType == DML_TENSOR_DATA_TYPE_FLOAT16 || opDesc.MinMaxDataType == DML_TENSOR_DATA_TYPE_FLOAT32 || opDesc.MinMaxDataType == DML_TENSOR_DATA_TYPE_FLOAT64)
|
||||
{
|
||||
CastToClampedScalarUnion<double>(opDesc.MinMaxDataType, -DBL_MAX, /*out*/&opDesc.Min);
|
||||
CastToClampedScalarUnion<double>(opDesc.MinMaxDataType, DBL_MAX, /*out*/&opDesc.Max);
|
||||
}
|
||||
else
|
||||
{
|
||||
// It's not safe to use DBL_MAX for non-float datatypes because not all integer can be represented in the range.
|
||||
// For example, static_cast<int64_t>(static_cast<double>(INT64_MAX)) will yield a negative number.
|
||||
CastToClampedScalarUnion<int64_t>(opDesc.MinMaxDataType, -INT64_MAX, /*out*/&opDesc.Min);
|
||||
CastToClampedScalarUnion<uint64_t>(opDesc.MinMaxDataType, UINT64_MAX, /*out*/&opDesc.Max);
|
||||
}
|
||||
|
||||
if (kernelInfo.IsInputValid(1))
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue