forked from microsoft/onnxruntime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[js/webgpu] support Cast operator (microsoft#16489)
### Description support `Cast` operator for webgpu backend. Cast operator for webgpu backend currently only supports f32, u32, i32 and bool.
- Loading branch information
Showing
5 changed files
with
292 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,248 @@ | ||
[ | ||
{ | ||
"name": "Cast float32 to int32", | ||
"operator": "Cast", | ||
"attributes": [{ "name": "to", "type": "int", "data": 6 }], | ||
"cases": [ | ||
{ | ||
"name": "2x3", | ||
"inputs": [ | ||
{ | ||
"data": [0.0, 0.5, 100.0, -234.0, -7.99, 1000000000], | ||
"dims": [2, 3], | ||
"type": "float32" | ||
} | ||
], | ||
"outputs": [ | ||
{ | ||
"data": [0, 0, 100, -234, -7, 1000000000], | ||
"dims": [2, 3], | ||
"type": "int32" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "Scalar", | ||
"inputs": [ | ||
{ | ||
"data": [1], | ||
"dims": [], | ||
"type": "float32" | ||
} | ||
], | ||
"outputs": [ | ||
{ | ||
"data": [1], | ||
"dims": [], | ||
"type": "int32" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "Cast int32 to float32", | ||
"operator": "Cast", | ||
"attributes": [{ "name": "to", "type": "int", "data": 1 }], | ||
"cases": [ | ||
{ | ||
"name": "2x3", | ||
"inputs": [ | ||
{ | ||
"data": [0, 0, 100, -234, -7, 1000000000], | ||
"dims": [2, 3], | ||
"type": "int32" | ||
} | ||
], | ||
"outputs": [ | ||
{ | ||
"data": [0, 0, 100, -234, -7, 1000000000], | ||
"dims": [2, 3], | ||
"type": "float32" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "Scalar", | ||
"inputs": [ | ||
{ | ||
"data": [1], | ||
"dims": [], | ||
"type": "int32" | ||
} | ||
], | ||
"outputs": [ | ||
{ | ||
"data": [1], | ||
"dims": [], | ||
"type": "float32" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "Cast int32 to uint32", | ||
"operator": "Cast", | ||
"attributes": [{ "name": "to", "type": "int", "data": 12 }], | ||
"cases": [ | ||
{ | ||
"name": "2x3", | ||
"inputs": [ | ||
{ | ||
"data": [0, -1, 100, -234, -7, 1000000000], | ||
"dims": [2, 3], | ||
"type": "int32" | ||
} | ||
], | ||
"outputs": [ | ||
{ | ||
"data": [0, 4294967295, 100, 4294967062, 4294967289, 1000000000], | ||
"dims": [2, 3], | ||
"type": "uint32" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "Scalar", | ||
"inputs": [ | ||
{ | ||
"data": [1], | ||
"dims": [], | ||
"type": "int32" | ||
} | ||
], | ||
"outputs": [ | ||
{ | ||
"data": [1], | ||
"dims": [], | ||
"type": "uint32" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "Cast uint32 to int32", | ||
"operator": "Cast", | ||
"attributes": [{ "name": "to", "type": "int", "data": 6 }], | ||
"cases": [ | ||
{ | ||
"name": "2x3", | ||
"inputs": [ | ||
{ | ||
"data": [0, 4294967295, 100, 1000000000], | ||
"dims": [2, 2], | ||
"type": "uint32" | ||
} | ||
], | ||
"outputs": [ | ||
{ | ||
"data": [0, -1, 100, 1000000000], | ||
"dims": [2, 2], | ||
"type": "int32" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "Scalar", | ||
"inputs": [ | ||
{ | ||
"data": [1], | ||
"dims": [], | ||
"type": "uint32" | ||
} | ||
], | ||
"outputs": [ | ||
{ | ||
"data": [1], | ||
"dims": [], | ||
"type": "int32" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "Cast int32 to bool", | ||
"operator": "Cast", | ||
"attributes": [{ "name": "to", "type": "int", "data": 9 }], | ||
"cases": [ | ||
{ | ||
"name": "2x3", | ||
"inputs": [ | ||
{ | ||
"data": [0, 1, 1, 0], | ||
"dims": [2, 2], | ||
"type": "int32" | ||
} | ||
], | ||
"outputs": [ | ||
{ | ||
"data": [false, true, true, false], | ||
"dims": [2, 2], | ||
"type": "bool" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "Scalar", | ||
"inputs": [ | ||
{ | ||
"data": [1], | ||
"dims": [], | ||
"type": "int32" | ||
} | ||
], | ||
"outputs": [ | ||
{ | ||
"data": [true], | ||
"dims": [], | ||
"type": "bool" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "Cast bool to int32", | ||
"operator": "Cast", | ||
"attributes": [{ "name": "to", "type": "int", "data": 6 }], | ||
"cases": [ | ||
{ | ||
"name": "2x3", | ||
"inputs": [ | ||
{ | ||
"data": [false, true, true, false], | ||
"dims": [2, 2], | ||
"type": "bool" | ||
} | ||
], | ||
"outputs": [ | ||
{ | ||
"data": [0, 1, 1, 0], | ||
"dims": [2, 2], | ||
"type": "int32" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "Scalar", | ||
"inputs": [ | ||
{ | ||
"data": [true], | ||
"dims": [], | ||
"type": "bool" | ||
} | ||
], | ||
"outputs": [ | ||
{ | ||
"data": [1], | ||
"dims": [], | ||
"type": "int32" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters