-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* WIP: hopefully better const impl * with GPU * More tests on * Reverting primitive for * Incorporating review changes - added check elem count check in kerner, using for call strategy * rustfmt ran
- Loading branch information
Showing
5 changed files
with
194 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include <metal_stdlib> | ||
|
||
using namespace metal; | ||
|
||
template<typename T> METAL_FUNC void fill_with( | ||
device T *out, | ||
constant float &value, | ||
constant size_t &numel, | ||
uint tid [[thread_position_in_grid]] | ||
) { | ||
if (tid >= numel) { | ||
return; | ||
} | ||
out[tid] = static_cast<T>(value); | ||
} | ||
|
||
#define FILL_OP(NAME, T) \ | ||
kernel void fill_##NAME( \ | ||
device T *out, \ | ||
constant float &value, \ | ||
constant size_t &numel, \ | ||
uint tid [[thread_position_in_grid]] \ | ||
) { \ | ||
fill_with<T>(out, value, numel, tid); \ | ||
} \ | ||
|
||
|
||
#define FILL_OPS(NAME, T) \ | ||
FILL_OP(NAME, T) \ | ||
|
||
FILL_OPS(u8, uchar) | ||
FILL_OPS(u32, uint) | ||
FILL_OPS(i64, long) | ||
FILL_OPS(f16, half) | ||
FILL_OPS(f32, float) | ||
|
||
#if __METAL_VERSION__ >= 310 | ||
FILL_OPS(bf16, bfloat) | ||
#endif |
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