-
-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement AbsKernelOp for WebGPU backend (#896)
* Removed some of the more low level commands in favor of a wrapper struct Also added tests for higher code coverage. * AtomicPtr unsound fix * Partial implementation of `Device<E>` for Webgpu * Remove foolish Mutex * Add Mutex back, since evidently it was causing issues. Hopefully I can figure out a way to remove it again. * Removed `num_traits::Num` requirement from Zeros. Had to figure out a way to store zeros in place * Implement abs kernel, and use broken unary operation for all the compiler errors * cargo fmt * disable f16, since we don't support it yet * no-std * Added test for abs on webgpu. Also added `backward` implementation, though I won't be able to test that until I fix `mean`. * cargo fmt * Managed to get built spirv working as long as we go through the non-passthrough route. Can't get sum_to working until wgpu supports atomic operations. Which is super unfortunate. Maybe I'll work on that soon... * Have the code work correctly, almost got sum_to working, too Weird magic number issue that I can't figure out... * Cargo fmt * Do we need to skip webgpu features?
- Loading branch information
Showing
35 changed files
with
1,098 additions
and
574 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
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,28 @@ | ||
#version 460 core | ||
|
||
#extension GL_ARB_compute_shader: enable | ||
#extension GL_ARB_shader_storage_buffer_object: enable | ||
|
||
layout(local_size_x = 128) in; | ||
|
||
layout(std430, binding = 1) buffer inpBlock { | ||
TYPENAME inp[]; | ||
}; | ||
|
||
layout(std430, binding = 2) buffer outpBlock { | ||
TYPENAME outp[]; | ||
}; | ||
|
||
layout(std430, binding = 3) buffer input_gradBlock { | ||
TYPENAME input_grad[]; | ||
}; | ||
|
||
layout(std430, binding = 4) buffer output_gradBlock { | ||
TYPENAME output_grad[]; | ||
}; | ||
|
||
void main() { | ||
TYPENAME dx = sign(inp[gl_GlobalInvocationID.x]); | ||
|
||
input_grad[gl_GlobalInvocationID.x] = dx * output_grad[gl_GlobalInvocationID.x]; | ||
} |
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,22 @@ | ||
#version 460 core | ||
|
||
#extension GL_ARB_compute_shader: enable | ||
#extension GL_ARB_shader_storage_buffer_object: enable | ||
|
||
layout(local_size_x = 128) in; | ||
|
||
layout(std430, binding = 1) buffer inpBlock { | ||
TYPENAME inp[]; | ||
}; | ||
|
||
layout(std430, binding = 2) buffer outpBlock{ | ||
TYPENAME outp[]; | ||
}; | ||
|
||
void main() { | ||
if (inp.length() == 0) { | ||
outp[gl_GlobalInvocationID.x] = abs(outp[gl_GlobalInvocationID.x]); | ||
} else { | ||
outp[gl_GlobalInvocationID.x] = abs(inp[gl_GlobalInvocationID.x]); | ||
} | ||
} |
Oops, something went wrong.