MCPcopy Create free account
hub / github.com/AnswerDotAI/gpu.cpp / testHadamard

Function testHadamard

experimental/legacy/transformer/test_kernels.cpp:47–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47void 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
71void testMatmul(Context &ctx) {
72 static constexpr size_t M = 4;

Callers 1

mainFunction · 0.85

Calls 7

rangeFunction · 0.85
createTensorFunction · 0.85
LOGFunction · 0.85
createKernelFunction · 0.85
cdivFunction · 0.85
dispatchKernelFunction · 0.85
waitFunction · 0.85

Tested by

no test coverage detected