| 45 | } |
| 46 | |
| 47 | void testHadamard(Context &ctx) { |
| 48 | constexpr size_t N = 200000; |
| 49 | constexpr size_t workgroupSize = 256; |
| 50 | std::array<float, N> input1Arr; |
| 51 | std::array<float, N> input2Arr; |
| 52 | range(input1Arr); |
| 53 | range(input2Arr); |
| 54 | std::array<float, N> outputArr; |
| 55 | Tensor input1 = createTensor(ctx, {N}, kf32, input1Arr.data()); |
| 56 | Tensor input2 = createTensor(ctx, {N}, kf32, input2Arr.data()); |
| 57 | Tensor output = createTensor(ctx, {N}, kf32, outputArr.data()); |
| 58 | KernelCode shaderCode = {kShaderHadamard, workgroupSize, kf32}; |
| 59 | LOG(kDefLog, kInfo, "Shader Code :\n%s", shaderCode.data.c_str()); |
| 60 | std::promise<void> promise; |
| 61 | std::future<void> future = promise.get_future(); |
| 62 | Kernel op = |
| 63 | createKernel(ctx, {kShaderHadamard, workgroupSize, kf32}, |
| 64 | Bindings{input1, input2, output}, {cdiv(N, workgroupSize), 1, 1}); |
| 65 | dispatchKernel(ctx, op, promise); |
| 66 | wait(ctx, future); |
| 67 | LOG(kDefLog, kInfo, "%s", |
| 68 | show<float, N, 1>(outputArr, "Hadamard Output").c_str()); |
| 69 | } |
| 70 | |
| 71 | void testMatmul(Context &ctx) { |
| 72 | static constexpr size_t M = 4; |
no test coverage detected