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

Method KernelCode

gpu.hpp:308–318  ·  view source on GitHub ↗

* @brief Constructor to create a code object from a template * string and optional workgroup size and precision. * * @param[in] pData Shader template string with placeholders * @param[in] workgroupSize Shape of the workgroup. Unlike tensor shapes which * can be of arbitrary rank, workgroup size is always of rank 3 corresponding * to x y and z. workgroupSize is stored as a field i

Source from the content-addressed store, hash-verified

306 * @endcode
307 */
308 inline KernelCode(const std::string &pData = "", size_t workgroupSize = 256,
309 NumType precision = kf32)
310 : data(pData), workgroupSize({workgroupSize, 1, 1}),
311 precision(precision) {
312 if (precision == kf16) {
313 data = "enable f16;\n" + data;
314 }
315 replaceAll(data, "{{workgroupSize}}", toString({workgroupSize, 1, 1}));
316 replaceAll(data, "{{precision}}", toString(precision));
317 LOG(kDefLog, kTrace, "Shader code:\n%s", data.c_str());
318 }
319
320 /**
321 * @brief Overload of the constructor to create a code object from a template

Callers

nothing calls this directly

Calls 3

replaceAllFunction · 0.85
LOGFunction · 0.85
toStringFunction · 0.70

Tested by

no test coverage detected