Skip to content

Commit

Permalink
Added DequantizeLinear JSONC op test.
Browse files Browse the repository at this point in the history
  • Loading branch information
satyajandhyala committed Aug 5, 2024
1 parent 1e6c46f commit 3e8dbe5
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 1 deletion.
4 changes: 3 additions & 1 deletion js/web/lib/wasm/jsep/webgpu/ops/quantize_linear.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ const validateInputs = (inputs: readonly TensorView[], attributes: DequantizeLin
if (inputs[1].dims.length === 0 || (inputs[1].dims.length === 1 && inputs[1].dims[0] === 1)) {
throw new Error('blockSize must be set only for block quantization.');
}
if (!inputs[1].dims.map((d, i) => i === attributes.axis || d === inputs[0].dims[i]).reduce((a, b) => a && b, true)) {
if (!inputs[1]
.dims.map((d, i) => i === attributes.axis || d === inputs[0].dims[i])
.reduce((a, b) => a && b, true)) {
throw new Error('For block qunatization, scale input shape to match the input shape except for the axis')
}
// Scale input rank should be same as the input rank
Expand Down
156 changes: 156 additions & 0 deletions js/web/test/data/ops/dequantizelinear.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
[
{
"name": "dequantizelinear",
"operator": "DequantizeLinear",
"attributes": [],
"cases": [
{
"name": "T[4]",
"inputs": [
{
"data": [1, 2, 3, 4],
"dims": [4],
"type": "uint8"
},
{
"data": [0.1],
"dims": [1],
"type": "float32"
},
{
"data": [0.0],
"dims": [1],
"type": "uint8"
}
],
"outputs": [
{
"data": [0.1, 0.2, 0.3, 0.4],
"dims": [4],
"type": "float32"
}
]
}
]
},
{
"name": "dequantizelinear",
"operator": "DequantizeLinear",
"attributes": [
{
"name": "axis",
"data": 1,
"type": "int"
}
],
"cases": [
{
"name": "T[2,2]",
"inputs": [
{
"data": [1, 2, 3, 4],
"dims": [2, 2],
"type": "uint8"
},
{
"data": [0.1],
"dims": [1],
"type": "float32"
},
{
"data": [0.0],
"dims": [1],
"type": "uint8"
}
],
"outputs": [
{
"data": [0.1, 0.2, 0.3, 0.4],
"dims": [2, 2],
"type": "float32"
}
]
}
]
},
{
"name": "dequantizelinear",
"operator": "DequantizeLinear",
"attributes": [
{
"name": "axis",
"data": 1,
"type": "int"
}
],
"cases": [
{
"name": "T[2, 2, 2]",
"inputs": [
{
"data": [1, 2, 3, 4, 5, 6, 7, 8],
"dims": [2, 2, 2],
"type": "uint8"
},
{
"data": [0.1, 0.1],
"dims": [2],
"type": "float32"
},
{
"data": [0.0, 0.0],
"dims": [2],
"type": "uint8"
}
],
"outputs": [
{
"data": [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8],
"dims": [2, 2, 2],
"type": "float32"
}
]
}
]
},
{
"name": "dequantizelinear",
"operator": "DequantizeLinear",
"attributes": [
{
"name": "axis",
"data": 1,
"type": "int"
}
],
"cases": [
{
"name": "T[2, 2, 2]",
"inputs": [
{
"data": [1, 2, 3, 4, 5, 6, 7, 8],
"dims": [2, 2, 2],
"type": "uint8"
},
{
"data": [0.1],
"dims": [1],
"type": "float32"
},
{
"data": [0.0],
"dims": [1],
"type": "uint8"
}
],
"outputs": [
{
"data": [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8],
"dims": [2, 2, 2],
"type": "float32"
}
]
}
]
}
]
1 change: 1 addition & 0 deletions js/web/test/suite-test-list.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,7 @@
"div.jsonc",
"div_int32.jsonc",
"depth-to-space.jsonc",
"dequantizelinear.jsonc",
"equal.jsonc",
"exp.jsonc",
"expand.jsonc",
Expand Down

0 comments on commit 3e8dbe5

Please sign in to comment.