mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-06-27 03:11:28 +00:00
Update DML EP to accept broadcasted tensor of size 1 to match CPU (#19081)
### Description With QDQ enabled for Dml EP we are seeing some models not optimize constant nodes with incorrect tensor size of scale[1] and zeropoint[1] that does not match the input size. CPU accepts this parameter type so updating Dml EP to match CPU behavior. ### Motivation and Context Want to match CPU EP behavior. --------- Co-authored-by: Christian Larson <28911437+chrilaMSFT@users.noreply.github.com> Co-authored-by: Dwayne Robinson <dwayner@microsoft.com>
This commit is contained in:
parent
daa22f919f
commit
8a0a972f39
3 changed files with 25 additions and 1 deletions
|
|
@ -558,7 +558,11 @@ public:
|
|||
{
|
||||
ML_CHECK_VALID_ARGUMENT(axis < outputShapeDimCount);
|
||||
uint32_t broadcastAxisLength = outputShape[axis];
|
||||
ML_CHECK_VALID_ARGUMENT(inputTensorShape[0] == broadcastAxisLength);
|
||||
ML_CHECK_VALID_ARGUMENT(
|
||||
(inputTensorShape[0] == broadcastAxisLength) ||
|
||||
// Treat as broadcast dimension to match CPU behavior.
|
||||
(inputTensorShape[0] == 1)
|
||||
);
|
||||
inputTensorShape.insert(inputTensorShape.begin(), axis, 1);
|
||||
inputTensorShape.insert(inputTensorShape.end(), outputShapeDimCount - 1 - axis, 1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,6 +76,16 @@ TEST(DequantizeLinearOpTest, DequantizeLinear_per_tensor_float_int32_cpu) {
|
|||
test.Run();
|
||||
}
|
||||
|
||||
TEST(DequantizeLinearOpTest, DequantizeLinearOpTest_BroadcastTensorOfOne) {
|
||||
OpTester test("DequantizeLinear", 1, onnxruntime::kMSDomain);
|
||||
|
||||
test.AddInput<int32_t>("x", {4}, {-30, -3, 100, 127});
|
||||
test.AddInput<float>("x_scale", {1}, {2.0f}, true);
|
||||
test.AddInput<int32_t>("zero_point", {1}, {0}, true);
|
||||
test.AddOutput<float>("y", {4}, {-60.f, -6.f, 200.f, 254.f});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
#ifdef USE_CUDA
|
||||
TEST(DequantizeLinearOpTest, DequantizeLinear_per_tensor_half_uint8) {
|
||||
OpTester test("DequantizeLinear", 1, onnxruntime::kMSDomain);
|
||||
|
|
|
|||
|
|
@ -47,6 +47,16 @@ TEST(DequantizeLinearOpTest, Int32) {
|
|||
test.Run();
|
||||
}
|
||||
|
||||
TEST(DequantizeLinearOpTest_BroadcastTensor, Int32) {
|
||||
OpTester test("DequantizeLinear", 13);
|
||||
test.AddInput<int32_t>("x", {4}, {-30, -3, 100, 127});
|
||||
test.AddAttribute<int64_t>("axis", 0);
|
||||
test.AddInput<float>("x_scale", {1}, {2.0f});
|
||||
test.AddInput<int32_t>("x_zero_point", {1}, {0});
|
||||
test.AddOutput<float>("y", {4}, {-60.f, -6.f, 200.f, 254.f});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
// 2d inputs
|
||||
TEST(DequantizeLinearOpTest, 2D) {
|
||||
OpTester test("DequantizeLinear", 10);
|
||||
|
|
|
|||
Loading…
Reference in a new issue