2021-06-21 08:49:27 +00:00
|
|
|
#include <metal_stdlib>
|
2021-05-27 16:48:57 +00:00
|
|
|
|
2021-06-21 08:49:27 +00:00
|
|
|
using namespace metal;
|
|
|
|
struct Uniforms {
|
2021-08-23 21:45:23 +00:00
|
|
|
/* 0x0000 */ uint2 aShape;
|
|
|
|
/* 0x0008 */ uint2 bShape;
|
|
|
|
/* 0x0010 */ uint2 outShape;
|
2021-06-21 08:49:27 +00:00
|
|
|
};
|
|
|
|
struct Matrix {
|
|
|
|
/* 0x0000 */ uint numbers[1];
|
|
|
|
};
|
2021-05-20 21:31:37 +00:00
|
|
|
|
2021-10-28 15:00:39 +00:00
|
|
|
void tint_symbol_inner(uint3 global_id, const constant Uniforms* const tint_symbol_1, const device Matrix* const tint_symbol_2, const device Matrix* const tint_symbol_3, device Matrix* const tint_symbol_4) {
|
2021-10-20 16:12:33 +00:00
|
|
|
uint2 const resultCell = uint2(global_id[1], global_id[0]);
|
2021-10-28 15:00:39 +00:00
|
|
|
uint const dimInner = (*(tint_symbol_1)).aShape[1];
|
|
|
|
uint const dimOutter = (*(tint_symbol_1)).outShape[1];
|
2021-06-21 08:49:27 +00:00
|
|
|
uint result = 0u;
|
2021-07-08 21:23:33 +00:00
|
|
|
for(uint i = 0u; (i < dimInner); i = (i + 1u)) {
|
2021-10-20 16:12:33 +00:00
|
|
|
uint const a = (i + (resultCell[0] * dimInner));
|
|
|
|
uint const b = (resultCell[1] + (i * dimOutter));
|
2021-10-28 15:00:39 +00:00
|
|
|
result = (result + ((*(tint_symbol_2)).numbers[a] * (*(tint_symbol_3)).numbers[b]));
|
2021-06-21 08:49:27 +00:00
|
|
|
}
|
2021-10-20 16:12:33 +00:00
|
|
|
uint const index = (resultCell[1] + (resultCell[0] * dimOutter));
|
2021-10-28 15:00:39 +00:00
|
|
|
(*(tint_symbol_4)).numbers[index] = result;
|
2021-08-04 22:15:28 +00:00
|
|
|
}
|
|
|
|
|
2021-10-28 15:00:39 +00:00
|
|
|
kernel void tint_symbol(const constant Uniforms* tint_symbol_5 [[buffer(0)]], const device Matrix* tint_symbol_6 [[buffer(2)]], const device Matrix* tint_symbol_7 [[buffer(3)]], device Matrix* tint_symbol_8 [[buffer(1)]], uint3 global_id [[thread_position_in_grid]]) {
|
|
|
|
tint_symbol_inner(global_id, tint_symbol_5, tint_symbol_6, tint_symbol_7, tint_symbol_8);
|
2021-06-21 08:49:27 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-05-20 21:31:37 +00:00
|
|
|
|