| 177 | } |
| 178 | |
| 179 | void 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 | |
| 200 | void testWGSL() { |
| 201 | static const char *kGelu = R"( |
no test coverage detected