* @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
| 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 |
nothing calls this directly
no test coverage detected