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

Function testTensorPool

experimental/legacy/transformer/test_kernels.cpp:109–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107}
108
109void testTensorPool(Context &ctx) {
110 LOG(kDefLog, kInfo, "Starting Tensor Pool Test");
111 // Test using the tensor pool to prepare tensor buffers for kernel invocation
112 TensorPool pool = ctx.pool;
113 std::array<float, 6> inputArr = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
114 Tensor input = createTensor(ctx, {2, 3}, kf32, inputArr.data());
115 Tensor output = createTensor(ctx, {2, 3}, kf32);
116 for (int i = 0; i < 10; i++) {
117 Tensor t = createTensor(ctx, {2, 3}, kf32);
118 }
119 // initializing a gpu buffer w/ value and then copy it back to CPU
120 std::array<float, 6> initValue = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
121 LOG(kDefLog, kInfo, "making tensors with init");
122 Tensor tInit = createTensor(ctx, {2, 3}, kf32, initValue.data());
123 LOG(kDefLog, kInfo, "Done with Tensor Pool Test");
124 std::array<float, 6> targetValue;
125 toCPU(ctx, tInit, targetValue.data(), sizeof(initValue));
126 LOG(kDefLog, kInfo, "%s",
127 show<float, 2, 3>(initValue, "initialized GPU value").c_str());
128 LOG(kDefLog, kInfo, "%s",
129 show<float, 2, 3>(targetValue, "To CPU from GPU").c_str());
130 LOG(kDefLog, kInfo, "Done with Tensor Pool Test");
131}
132
133void testGelu(Context &ctx) {
134 static constexpr size_t N = 3072;

Callers 1

mainFunction · 0.85

Calls 3

LOGFunction · 0.85
createTensorFunction · 0.85
toCPUFunction · 0.85

Tested by

no test coverage detected