Skip to content

Commit

Permalink
[js/webgpu] Fix shader compilation errors in cumsum (microsoft#18779)
Browse files Browse the repository at this point in the history
### Description
This PR fixes below shader compilation errors:
```
Tint WGSL reader failure: :39:31 error: no matching overload for operator + (f32, i32)

5 candidate operators:
  operator + (T, T) -> T  where: T is abstract-float, abstract-int, f32, i32, u32 or f16
  operator + (vecN<T>, T) -> vecN<T>  where: T is abstract-float, abstract-int, f32, i32, u32 or f16
  operator + (T, vecN<T>) -> vecN<T>  where: T is abstract-float, abstract-int, f32, i32, u32 or f16
  operator + (vecN<T>, vecN<T>) -> vecN<T>  where: T is abstract-float, abstract-int, f32, i32, u32 or f16
  operator + (matNxM<T>, matNxM<T>) -> matNxM<T>  where: T is abstract-float, f32 or f16

                    sum = sum + get_inputByIndices(inputIndices);
                              ^


 - While validating [ShaderModuleDescriptor "CumSum"]
 - While calling [Device].CreateShaderModule([ShaderModuleDescriptor "CumSum"]).
  • Loading branch information
qjia7 authored Dec 12, 2023
1 parent a85ef65 commit b4be9e1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion js/web/lib/wasm/jsep/webgpu/ops/cumsum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const createCumsumProgramInfo =
${shaderHelper.mainStart()}
${shaderHelper.guardAgainstOutOfBoundsWorkgroupSizes('uniforms.outputSize')}
var inputIndices = ${output.offsetToIndices('global_idx')};
var sum = 0.0;
var sum = ${output.type.value}(0);
let first : i32 = ${lowerLimit};
let last : i32 = ${upperLimit};
for (var i : i32 = first; i < last; i++) {
Expand Down
36 changes: 36 additions & 0 deletions js/web/test/data/ops/cumsum.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -1322,5 +1322,41 @@
]
}
]
},
{
"name": "CumSum",
"operator": "CumSum",
"attributes": [
{ "name": "exclusive", "data": 0, "type": "int" },
{ "name": "reverse", "data": 0, "type": "int" }
],
"opset": {
"domain": "",
"version": 11
},
"cases": [
{
"name": "CumSum int32; axis = 0; exclusive = 0, reverse = 0",
"inputs": [
{
"data": [1, 2, 3, 4, 5],
"dims": [1, 1, 1, 1, 5],
"type": "int32"
},
{
"data": [4],
"dims": [],
"type": "int32"
}
],
"outputs": [
{
"data": [1, 3, 6, 10, 15],
"dims": [1, 1, 1, 1, 5],
"type": "int32"
}
]
}
]
}
]

0 comments on commit b4be9e1

Please sign in to comment.