Created
January 24, 2024 20:16
-
-
Save michelp/580d1b663c14a082e7db6e91ccf0ee0b to your computer and use it in GitHub Desktop.
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
gb.binary.ss.register_new( | |
"relu", | |
"""void relu (int64_t *z, int64_t *x, int64_t *y) { | |
int64_t v; | |
v = (*x) + (*y); | |
v = v < 32 ? v : 32; | |
(*z) = v < 0 ? 0 : v; | |
}; """, | |
gb.dtypes.INT64, | |
gb.dtypes.INT64, | |
gb.dtypes.INT64) | |
gb.semiring.register_new( | |
"plus_relu", | |
gb.monoid.plus, | |
gb.binary.ss.relu) | |
def dnn(W, B, Y): | |
for w, b in zip(W, B): | |
Y << Y @ w | |
Y << gb.semiring.plus_relu(Y @ b) | |
Y << Y.select(">", 0) | |
return Y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment