| 74 | } |
| 75 | |
| 76 | void MergeCLNodes(CLNode* src, CLNode* dst) { |
| 77 | int offset = dst->inputs.size(); |
| 78 | for (int j = 0; j < src->inputs.size(); ++j) { |
| 79 | if (src->inputs[j] != dst->outputs[0]) { |
| 80 | dst->inputs.push_back(src->inputs[j]); |
| 81 | } |
| 82 | } |
| 83 | auto first_range = src->ranges[0]; |
| 84 | dst->ranges.push_back( |
| 85 | int2(first_range.x + offset, first_range.y - 1 + offset)); |
| 86 | for (int i = 1; i < src->ranges.size(); ++i) { |
| 87 | auto range = src->ranges[i]; |
| 88 | dst->ranges.push_back(int2(range.x + offset, range.y + offset)); |
| 89 | } |
| 90 | dst->outputs[0] = src->outputs[0]; |
| 91 | for (int i = 0; i < src->operations.size(); ++i) { |
| 92 | dst->operations.push_back(std::move(src->operations[i])); |
| 93 | } |
| 94 | dst->name += " linked : " + src->name; |
| 95 | } |
| 96 | |
| 97 | void AddUsage(ValueId id, int task_index, |
| 98 | std::map<ValueId, int2>* usage_records) { |