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

Function testContainers

numeric_types/half.cpp:179–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179void testContainers() {
180 {
181 std::array<half, 4> h = {0.0f, -0.0f, INFINITY, NAN};
182 testRoundTrip(h[0]);
183 testRoundTrip(h[1]);
184 testRoundTrip(h[2]);
185 testRoundTrip(h[3]);
186 }
187 {
188 Context ctx = createContext();
189 std::array<half, 8> h = {1.0f, 0.5f, 2.0f, 3.14f, 1.0, 2.0, 3.0, 4.0};
190 Tensor devH = createTensor(ctx, {h.size()}, kf16, h.data());
191 std::array<half, 8> h2;
192 toCPU(ctx, devH, h2.data(), sizeof(h2));
193 for (int i = 0; i < 8; ++i) {
194 printResult(h[i].data == h2[i].data, "Container round trip",
195 static_cast<float>(h[i]), static_cast<float>(h2[i]));
196 }
197 }
198}
199
200void testWGSL() {
201 static const char *kGelu = R"(

Callers 1

mainFunction · 0.85

Calls 5

testRoundTripFunction · 0.85
createContextFunction · 0.85
createTensorFunction · 0.85
toCPUFunction · 0.85
printResultFunction · 0.85

Tested by

no test coverage detected