Generates the code to calculate the offsets for a buffer
| 51 | |
| 52 | /// Generates the code to calculate the offsets for a buffer |
| 53 | inline void generateBufferOffsets(std::stringstream& kerStream, int id, |
| 54 | bool is_linear, const std::string& type_str) { |
| 55 | UNUSED(type_str); |
| 56 | std::string idx_str = std::string("int idx") + std::to_string(id); |
| 57 | std::string info_str = std::string("iInfo") + std::to_string(id); |
| 58 | |
| 59 | if (is_linear) { |
| 60 | kerStream << idx_str << " = idx + " << info_str << "_offset;\n"; |
| 61 | } else { |
| 62 | kerStream << idx_str << " = (id3 < " << info_str << ".dims[3]) * " |
| 63 | << info_str << ".strides[3] * id3 + (id2 < " << info_str |
| 64 | << ".dims[2]) * " << info_str << ".strides[2] * id2 + (id1 < " |
| 65 | << info_str << ".dims[1]) * " << info_str |
| 66 | << ".strides[1] * id1 + (id0 < " << info_str << ".dims[0]) * " |
| 67 | << info_str << ".strides[0] * id0 + " << info_str |
| 68 | << ".offset;\n"; |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | /// Generates the code to read a buffer and store it in a local variable |
| 73 | inline void generateBufferRead(std::stringstream& kerStream, int id, |
nothing calls this directly
no test coverage detected