Generates the code to calculate the offsets for a buffer
| 49 | |
| 50 | /// Generates the code to calculate the offsets for a buffer |
| 51 | inline void generateBufferOffsets(std::stringstream& kerStream, int id, |
| 52 | bool is_linear, const std::string& type_str) { |
| 53 | UNUSED(type_str); |
| 54 | const std::string idx_str = std::string("idx") + std::to_string(id); |
| 55 | const std::string info_str = std::string("iInfo") + std::to_string(id); |
| 56 | const std::string in_str = std::string("in") + std::to_string(id); |
| 57 | |
| 58 | if (is_linear) { |
| 59 | kerStream << in_str << " += " << info_str << "_offset;\n" |
| 60 | << "#define " << idx_str << " idx\n"; |
| 61 | } else { |
| 62 | kerStream << "int " << idx_str << " = id0*(id0<" << info_str |
| 63 | << ".dims[0])*" << info_str << ".strides[0] + id1*(id1<" |
| 64 | << info_str << ".dims[1])*" << info_str |
| 65 | << ".strides[1] + id2*(id2<" << info_str << ".dims[2])*" |
| 66 | << info_str << ".strides[2] + id3*(id3<" << info_str |
| 67 | << ".dims[3])*" << info_str << ".strides[3] + " << 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