Merged
fix(codegen): Bind local buffers before skipping VIEW/RESHAPE ops #6279
anyangleAdd on Sep 14
fix(codegen): Bind local buffers before skipping VIEW/RESHAPE ops #6279
Merged
Merged fromquadrate/pypto_aylcodegen_9.2intocann/pypto9.2.0
Total: 2 files changed+6-2
| @@ -106,12 +106,14 @@ void CodeGenCloudNPU::GenFuncBody(Function& subFunc, Function& topFunc, std::ost | |||
| 106 | for (const auto& op : operationList) { | 106 | for (const auto& op : operationList) { |
| 107 | CODEGEN_LOGI("======================== Op CodeGenNPU Start ========================\nGen OP IS: %s", | 107 | CODEGEN_LOGI("======================== Op CodeGenNPU Start ========================\nGen OP IS: %s", |
| 108 | op.Dump().c_str()); | 108 | op.Dump().c_str()); |
| 109 | + // Skip ops (VIEW/RESHAPE/ALLOC/...) emit no TileOp, but may carry needAlloc on | ||
| 110 | + // in/out tensors; still register symbols before ignoring instruction codegen. | ||
| 111 | + GenAllocForLocalBuffer(op, symbolMgr); | ||
| 109 | if (SKIP_OPCODE_FOR_CODEGEN.find(op.GetOpcode()) != SKIP_OPCODE_FOR_CODEGEN.end()) { | 112 | if (SKIP_OPCODE_FOR_CODEGEN.find(op.GetOpcode()) != SKIP_OPCODE_FOR_CODEGEN.end()) { |
| 110 | CODEGEN_LOGI("ignore this op\n------------------------ Op CodeGenNPU Finish -----------------------"); | 113 | CODEGEN_LOGI("ignore this op\n------------------------ Op CodeGenNPU Finish -----------------------"); |
| 111 | continue; | 114 | continue; |
| 112 | } | 115 | } |
| 113 | 116 | ||
| 114 | - GenAllocForLocalBuffer(op, symbolMgr); | ||
| 115 | floatSpecValMgr.UpdateByOp(op); | 117 | floatSpecValMgr.UpdateByOp(op); |
| 116 | 118 | ||
| 117 | CodeGenOpCloudNPU cop({symbolMgr, topFunc, subFunc, op, ctx.isMainBlock, ctx.isDynamicAligned, forBlkMgr}); | 119 | CodeGenOpCloudNPU cop({symbolMgr, topFunc, subFunc, op, ctx.isMainBlock, ctx.isDynamicAligned, forBlkMgr}); |
| @@ -172,12 +172,14 @@ void CodeGenLiteNPU::GenFuncBody(Function& subFunc, Function& topFunc, std::ostr | |||
| 172 | for (const auto& op : operationList) { | 172 | for (const auto& op : operationList) { |
| 173 | CODEGEN_LOGI("======================== Op CodeGenNPU Start ========================\nGen OP IS: %s", | 173 | CODEGEN_LOGI("======================== Op CodeGenNPU Start ========================\nGen OP IS: %s", |
| 174 | op.Dump().c_str()); | 174 | op.Dump().c_str()); |
| 175 | + // Skip ops (VIEW/RESHAPE/ALLOC/...) emit no TileOp, but may carry needAlloc on | ||
| 176 | + // in/out tensors; still register symbols before ignoring instruction codegen. | ||
| 177 | + GenAllocForLocalBuffer(op, symbolMgr); | ||
| 175 | if (SKIP_OPCODE_FOR_CODEGEN.find(op.GetOpcode()) != SKIP_OPCODE_FOR_CODEGEN.end()) { | 178 | if (SKIP_OPCODE_FOR_CODEGEN.find(op.GetOpcode()) != SKIP_OPCODE_FOR_CODEGEN.end()) { |
| 176 | CODEGEN_LOGI("ignore this op\n------------------------ Op CodeGenNPU Finish -----------------------"); | 179 | CODEGEN_LOGI("ignore this op\n------------------------ Op CodeGenNPU Finish -----------------------"); |
| 177 | continue; | 180 | continue; |
| 178 | } | 181 | } |
| 179 | 182 | ||
| 180 | - GenAllocForLocalBuffer(op, symbolMgr); | ||
| 181 | floatSpecValMgr.UpdateByOp(op); | 183 | floatSpecValMgr.UpdateByOp(op); |
| 182 | 184 | ||
| 183 | // kirin only supports static function | 185 | // kirin only supports static function |