1 | #include "taichi/ir/scratch_pad.h" |
---|---|
2 | |
3 | #include "taichi/ir/statements.h" |
4 | |
5 | namespace taichi::lang { |
6 | |
7 | std::string ScratchPad::global_to_linearized_local( |
8 | const std::vector<Stmt *> &loop_vars, |
9 | const std::vector<Stmt *> &indices) { |
10 | std::string ret = ""; |
11 | TI_ASSERT((int)indices.size() == dim); |
12 | int step_size = pad_size_linear(); |
13 | for (int i = 0; i < (int)indices.size(); i++) { |
14 | TI_ASSERT(step_size % pad_size[i] == 0); |
15 | step_size /= pad_size[i]; |
16 | ret += fmt::format(" + ({} - {}_base - {}) * {}", indices[i]->raw_name(), |
17 | loop_vars[i]->raw_name(), bounds[i].low, step_size); |
18 | } |
19 | return ret; |
20 | } |
21 | |
22 | } // namespace taichi::lang |
23 |