Permalink
Switch branches/tags
{{ refName }}
default
Cannot retrieve contributors at this time
master
Could not load branches
Nothing to show
Could not load tags
Nothing to show
{{ refName }}
default
CoreML-Custom-Layers/2 - App (GPU)/CustomLayers/Swish.metal
Go to file- Go to file T
-
Copy path -
Copy permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
| #include <metal_stdlib> | |
| using namespace metal; | |
| kernel void swish( | |
| texture2d_array<half, access::read> inTexture [[texture(0)]], | |
| texture2d_array<half, access::write> outTexture [[texture(1)]], | |
| ushort3 gid [[thread_position_in_grid]]) | |
| { | |
| if (gid.x >= outTexture.get_width() || gid.y >= outTexture.get_height()) { | |
| return; | |
| } | |
| const float4 x = float4(inTexture.read(gid.xy, gid.z)); | |
| const float4 y = x / (1.0f + exp(-x)); | |
| outTexture.write(half4(y), gid.xy, gid.z); | |
| } |
-
Copy lines -
Copy permalink - View git blame
- Reference in new issue