Merged
fear(ir): Keep every assemble version of one slot as outcast output #6386
lidongshengAdd on Sep 16
fear(ir): Keep every assemble version of one slot as outcast output #6386
Merged
Merged fromtsungl4/pypto-openass_9.2intocann/pypto9.2.0
Total: 12 files changed+277-85
| @@ -2439,17 +2439,27 @@ LogicalTensors Function::MakeIncasts(const std::shared_ptr<TensorSlotScope>& sco | |||
| 2439 | return inArgumentList; | 2439 | return inArgumentList; |
| 2440 | } | 2440 | } |
| 2441 | 2441 | ||
| 2442 | -std::shared_ptr<LogicalTensor> Function::CreateOutcastTensor(const std::shared_ptr<LogicalTensor>& outArgument) | 2442 | +std::shared_ptr<LogicalTensor> Function::CreateOutcastTensor(const std::shared_ptr<LogicalTensor>& outArgument, |
| 2443 | + const std::shared_ptr<RawTensor>& shareRaw, | ||
| 2444 | + const std::string& name) | ||
| 2443 | { | 2445 | { |
| 2444 | auto idx = outCasts_.size(); | 2446 | auto idx = outCasts_.size(); |
| 2445 | - auto newSymbol = outArgument->tensor->GetSymbol(); | 2447 | + auto newSymbol = name.empty() ? outArgument->tensor->GetSymbol() : name; |
| 2446 | if (newSymbol == "") { | 2448 | if (newSymbol == "") { |
| 2447 | newSymbol = "OUTCAST_SYMBOL" + std::to_string(idx); | 2449 | newSymbol = "OUTCAST_SYMBOL" + std::to_string(idx); |
| 2448 | } | 2450 | } |
| 2449 | auto outSymbol = std::make_shared<LogicalTensor>(*this, outArgument->tensor->datatype, outArgument->shape, | 2451 | auto outSymbol = std::make_shared<LogicalTensor>(*this, outArgument->tensor->datatype, outArgument->shape, |
| 2450 | outArgument->tensor->GetDynRawShape(), outArgument->Format(), | 2452 | outArgument->tensor->GetDynRawShape(), outArgument->Format(), |
| 2451 | newSymbol); | 2453 | newSymbol); |
| 2452 | - outSymbol->tensor->UpdateDynRawShape(outArgument->tensor->GetDynRawShape()); | 2454 | + if (!name.empty()) { |
| 2455 | + outSymbol->name_ = name; | ||
| 2456 | + } | ||
| 2457 | + if (shareRaw != nullptr) { | ||
| 2458 | + /* Later versions of one raw tensor reuse the first version's outcast buffer. */ | ||
| 2459 | + outSymbol->tensor = shareRaw; | ||
| 2460 | + } else { | ||
| 2461 | + outSymbol->tensor->UpdateDynRawShape(outArgument->tensor->GetDynRawShape()); | ||
| 2462 | + } | ||
| 2453 | 2463 | ||
| 2454 | outCasts_.push_back(outSymbol); | 2464 | outCasts_.push_back(outSymbol); |
| 2455 | 2465 | ||
| @@ -2536,17 +2546,46 @@ LogicalTensors Function::MakeOutcasts(const std::shared_ptr<TensorSlotScope>& sc | |||
| 2536 | { | 2546 | { |
| 2537 | LogicalTensors outArgumentList; | 2547 | LogicalTensors outArgumentList; |
| 2538 | 2548 | ||
| 2549 | + /* Multiple assemble versions of one raw tensor all write the same slot. | ||
| 2550 | + * Snapshot the raw tensors first (the assemble-outcast rewrite below | ||
| 2551 | + * rebinds them), so the versions can be grouped: every version of a group | ||
| 2552 | + * shares the first version's outcast buffer and keeps its own version | ||
| 2553 | + * name, i.e. one runtime slot with one outcast entry per assemble write. */ | ||
| 2554 | + std::vector<std::shared_ptr<RawTensor>> originRaws; | ||
| 2555 | + std::unordered_map<int, std::vector<size_t>> rawMagicToIndices; | ||
| 2556 | + originRaws.reserve(originOutCasts_.size()); | ||
| 2557 | + for (size_t idx = 0; idx < originOutCasts_.size(); idx++) { | ||
| 2558 | + originRaws.push_back(originOutCasts_[idx]->tensor); | ||
| 2559 | + rawMagicToIndices[originRaws[idx]->rawmagic].push_back(idx); | ||
| 2560 | + } | ||
| 2561 | + std::unordered_map<int, std::shared_ptr<RawTensor>> rawMagicToOutSymbolRaw; | ||
| 2562 | + | ||
| 2539 | for (size_t idx = 0; idx < originOutCasts_.size(); idx++) { | 2563 | for (size_t idx = 0; idx < originOutCasts_.size(); idx++) { |
| 2540 | auto origin = originOutCasts_[idx]; | 2564 | auto origin = originOutCasts_[idx]; |
| 2541 | int rank = origin->shape.size(); | 2565 | int rank = origin->shape.size(); |
| 2542 | std::vector<int64_t> zeroOffset(rank, 0); | 2566 | std::vector<int64_t> zeroOffset(rank, 0); |
| 2543 | - auto outArgument = std::make_shared<LogicalTensor>(Parent(), origin->tensor, zeroOffset, origin->shape, | 2567 | + auto outArgument = std::make_shared<LogicalTensor>(Parent(), originRaws[idx], zeroOffset, origin->shape, |
| 2544 | - origin->tensor->GetDynRawShape()); | 2568 | + originRaws[idx]->GetDynRawShape()); |
| 2569 | + bool versionedGroup = rawMagicToIndices[originRaws[idx]->rawmagic].size() > 1; | ||
| 2570 | + if (versionedGroup) { | ||
| 2571 | + outArgument->name_ = origin->name_; | ||
| 2572 | + } | ||
| 2545 | Parent().tensorMap_.Insert(outArgument); | 2573 | Parent().tensorMap_.Insert(outArgument); |
| 2546 | outArgumentList.push_back(outArgument); | 2574 | outArgumentList.push_back(outArgument); |
| 2547 | 2575 | ||
| 2548 | bool isLinkedInplaceOutcast = outIncastLinkMap.count(origin->GetRawTensor()) != 0; | 2576 | bool isLinkedInplaceOutcast = outIncastLinkMap.count(origin->GetRawTensor()) != 0; |
| 2549 | - auto outSymbol = CreateOutcastTensor(outArgument); | 2577 | + std::shared_ptr<RawTensor> shareRaw; |
| 2578 | + auto [groupIter, firstInGroup] = rawMagicToOutSymbolRaw.emplace(originRaws[idx]->rawmagic, nullptr); | ||
| 2579 | + if (!firstInGroup) { | ||
| 2580 | + shareRaw = groupIter->second; | ||
| 2581 | + } | ||
| 2582 | + auto outSymbol = CreateOutcastTensor(outArgument, shareRaw, versionedGroup ? origin->name_ : ""); | ||
| 2583 | + if (firstInGroup) { | ||
| 2584 | + groupIter->second = outSymbol->tensor; | ||
| 2585 | + } | ||
| 2586 | + /* The outcast param is the same runtime buffer as the version it | ||
| 2587 | + * exports: share the slot so it resolves to the version's slot id. */ | ||
| 2588 | + Program::GetInstance().GetTensorSlotManager()->SetSameSlot(origin, outSymbol); | ||
| 2550 | if (scope) { | 2589 | if (scope) { |
| 2551 | scope->outcastToOutArgumentDict[outSymbol] = outArgument; | 2590 | scope->outcastToOutArgumentDict[outSymbol] = outArgument; |
| 2552 | } | 2591 | } |
| @@ -1072,7 +1072,9 @@ private: | |||
| 1072 | // 将 operationCountBefore 之后新插入的 op 移到 operations_ 最前面。 | 1072 | // 将 operationCountBefore 之后新插入的 op 移到 operations_ 最前面。 |
| 1073 | // MakeIncasts 中 CreateFromIncast 会在尾部追加 VIEW op,提前到程序开头后前端无需再排序。 | 1073 | // MakeIncasts 中 CreateFromIncast 会在尾部追加 VIEW op,提前到程序开头后前端无需再排序。 |
| 1074 | void MoveNewlyInsertedOpsToFront(size_t operationCountBefore); | 1074 | void MoveNewlyInsertedOpsToFront(size_t operationCountBefore); |
| 1075 | - std::shared_ptr<LogicalTensor> CreateOutcastTensor(const std::shared_ptr<LogicalTensor>& outArgument); | 1075 | + std::shared_ptr<LogicalTensor> CreateOutcastTensor(const std::shared_ptr<LogicalTensor>& outArgument, |
| 1076 | + const std::shared_ptr<RawTensor>& shareRaw = nullptr, | ||
| 1077 | + const std::string& name = ""); | ||
| 1076 | void CreateFromOutcast(const LogicalTensorPtr& symbol, const LogicalTensorPtr& newOutcast, | 1078 | void CreateFromOutcast(const LogicalTensorPtr& symbol, const LogicalTensorPtr& newOutcast, |
| 1077 | const LogicalTensorPtr& originOutcast); | 1079 | const LogicalTensorPtr& originOutcast); |
| 1078 | void RebindAssembleVersionsToOutcast(const LogicalTensorPtr& originOutcast, const LogicalTensorPtr& newOutcast); | 1080 | void RebindAssembleVersionsToOutcast(const LogicalTensorPtr& originOutcast, const LogicalTensorPtr& newOutcast); |
| @@ -369,27 +369,26 @@ void RootFunctionBuilder::ComputeIncast(Function& pathFunc, | |||
| 369 | 369 | ||
| 370 | void RootFunctionBuilder::ComputeOutcast(Function& pathFunc) | 370 | void RootFunctionBuilder::ComputeOutcast(Function& pathFunc) |
| 371 | { | 371 | { |
| 372 | - LogicalTensors outcasts; | 372 | + auto isQualified = [this](const LogicalTensorPtr& tensor) { |
| 373 | - std::unordered_map<int, size_t> rawMagicToOutcastIndex; | 373 | + return consumedTensors_.count(tensor) > 0 || paramTensors_.count(tensor) > 0 || |
| 374 | + tensor->IsGetTensorDataOutcast(); | ||
| 375 | + }; | ||
| 376 | + | ||
| 377 | + std::unordered_set<int> rawMagics; | ||
| 374 | for (auto& op : pathFunc.Operations(false)) { | 378 | for (auto& op : pathFunc.Operations(false)) { |
| 375 | for (auto& oOperand : op.GetOOperands()) { | 379 | for (auto& oOperand : op.GetOOperands()) { |
| 376 | - bool neededByConsumer = consumedTensors_.count(oOperand) > 0; | 380 | + if (isQualified(oOperand)) { |
| 377 | - bool isFuncOutput = paramTensors_.count(oOperand) > 0; | 381 | + rawMagics.insert(oOperand->GetRawMagic()); |
| 378 | - if (!neededByConsumer && !isFuncOutput && !oOperand->IsGetTensorDataOutcast()) { | ||
| 379 | - continue; | ||
| 380 | - } | ||
| 381 | - | ||
| 382 | - int rawMagic = oOperand->GetRawMagic(); | ||
| 383 | - auto [iter, inserted] = rawMagicToOutcastIndex.emplace(rawMagic, outcasts.size()); | ||
| 384 | - if (inserted) { | ||
| 385 | - outcasts.push_back(oOperand); | ||
| 386 | - } else { | ||
| 387 | - outcasts[iter->second] = oOperand; | ||
| 388 | } | 382 | } |
| 389 | } | 383 | } |
| 390 | } | 384 | } |
| 391 | - for (const auto& outcast : outcasts) { | 385 | + |
| 392 | - pathFunc.AddOriginOutcast(outcast); | 386 | + for (auto& op : pathFunc.Operations(false)) { |
| 387 | + for (auto& oOperand : op.GetOOperands()) { | ||
| 388 | + if (rawMagics.count(oOperand->GetRawMagic()) > 0) { | ||
| 389 | + pathFunc.AddOriginOutcast(oOperand); | ||
| 390 | + } | ||
| 391 | + } | ||
| 393 | } | 392 | } |
| 394 | } | 393 | } |
| 395 | 394 | ||
| @@ -652,12 +651,22 @@ ir::StmtPtr RootFunctionBuilder::FinalizePathFunc(const ir::StmtPtr& placeholder | |||
| 652 | // 3. hiddenFunc 处理(MakeIncasts 的 Parent() = pathFunc) | 651 | // 3. hiddenFunc 处理(MakeIncasts 的 Parent() = pathFunc) |
| 653 | 652 | ||
| 654 | ComputeOutcast(*hiddenFunc); | 653 | ComputeOutcast(*hiddenFunc); |
| 654 | + | ||
| 655 | + /* if two outcasts share the same raw tensor, link them onto one slot. */ | ||
| 656 | + auto slotManager = program_.GetTensorSlotManager(); | ||
| 657 | + std::unordered_map<int, LogicalTensorPtr> outcastByRaw; | ||
| 658 | + for (auto& outcast : hiddenFunc->GetOriginOutcast()) { | ||
| 659 | + auto [iter, inserted] = outcastByRaw.emplace(outcast->GetRawMagic(), outcast); | ||
| 660 | + if (!inserted) { | ||
| 661 | + slotManager->SetSameSlot(iter->second, outcast); | ||
| 662 | + } | ||
| 663 | + } | ||
| 664 | + | ||
| 655 | auto originalIncasts = hiddenFunc->GetOriginIncast(); | 665 | auto originalIncasts = hiddenFunc->GetOriginIncast(); |
| 656 | auto originalOutcasts = hiddenFunc->GetOriginOutcast(); | 666 | auto originalOutcasts = hiddenFunc->GetOriginOutcast(); |
| 657 | auto hiddenFuncArgs = FinalizeHiddenFunc(hiddenFunc, placeholder); | 667 | auto hiddenFuncArgs = FinalizeHiddenFunc(hiddenFunc, placeholder); |
| 658 | 668 | ||
| 659 | // 4. pathFunc 处理(独立函数) | 669 | // 4. pathFunc 处理(独立函数) |
| 660 | - auto slotManager = program_.GetTensorSlotManager(); | ||
| 661 | for (size_t i = 0; i < originalIncasts.size(); i++) { | 670 | for (size_t i = 0; i < originalIncasts.size(); i++) { |
| 662 | slotManager->SetSameSlot(originalIncasts[i], hiddenFuncArgs.first[i]); | 671 | slotManager->SetSameSlot(originalIncasts[i], hiddenFuncArgs.first[i]); |
| 663 | } | 672 | } |
| @@ -467,8 +467,12 @@ void TensorSlotManager::SetSameSlot(const LogicalTensorPtr& src, const LogicalTe | |||
| 467 | return; | 467 | return; |
| 468 | } | 468 | } |
| 469 | 469 | ||
| 470 | - // Migrate all tensors pointing to dst's old slot to src's slot, so no prior | 470 | + // The older slot survives, so the merge outcome is order-independent: the |
| 471 | - // links are lost regardless of link order or direction. | 471 | + // slot tensor created first (params are slotted first in InitDynFunc) stays |
| 472 | + // canonical, and ids already captured into ioslot lists remain valid. | ||
| 473 | + if (srcTensor->Id() > dstTensor->Id()) { | ||
| 474 | + std::swap(srcTensor, dstTensor); | ||
| 475 | + } | ||
| 472 | for (auto& [lt, tensor] : slotTensorDict) { | 476 | for (auto& [lt, tensor] : slotTensorDict) { |
| 473 | (void)lt; | 477 | (void)lt; |
| 474 | if (tensor->Id() == dstTensor->Id()) { | 478 | if (tensor->Id() == dstTensor->Id()) { |
| @@ -630,37 +634,41 @@ void TensorSlotManager::Restore() | |||
| 630 | 634 | ||
| 631 | std::string TensorSlotManager::Dump() const | 635 | std::string TensorSlotManager::Dump() const |
| 632 | { | 636 | { |
| 633 | - std::vector<TensorSlot> slotList(slotIndexDict.size()); | 637 | + // Slot indices are tensor ids (see InsertLiveSlot) and may exceed slotIndexDict.size(), |
| 638 | + // so sort (index, slot) pairs instead of writing into a vector sized by the entry count. | ||
| 639 | + std::vector<std::pair<int, TensorSlot>> slotList; | ||
| 640 | + slotList.reserve(slotIndexDict.size()); | ||
| 634 | for (auto& [slot, index] : slotIndexDict) { | 641 | for (auto& [slot, index] : slotIndexDict) { |
| 635 | - slotList[index] = slot; | 642 | + slotList.emplace_back(index, slot); |
| 636 | } | 643 | } |
| 644 | + std::sort(slotList.begin(), slotList.end(), [](auto& lhs, auto& rhs) { return lhs.first < rhs.first; }); | ||
| 637 | constexpr int width2 = 2; | 645 | constexpr int width2 = 2; |
| 638 | constexpr int width6 = 6; | 646 | constexpr int width6 = 6; |
| 639 | constexpr int width7 = 7; | 647 | constexpr int width7 = 7; |
| 640 | 648 | ||
| 641 | std::ostringstream oss; | 649 | std::ostringstream oss; |
| 642 | - for (size_t i = 0; i < slotList.size(); i++) { | 650 | + for (auto& [index, slot] : slotList) { |
| 643 | - bool live = liveSlotSet.count(slotList[i]); | 651 | + bool live = liveSlotSet.count(slot); |
| 644 | - bool assemble = assembleSlotSet.count(slotList[i]); | 652 | + bool assemble = assembleSlotSet.count(slot); |
| 645 | - bool shmemTensor = shmemTensorSlotSet.count(slotList[i]); | 653 | + bool shmemTensor = shmemTensorSlotSet.count(slot); |
| 646 | - bool input = inputSlotDict.count(slotList[i]); | 654 | + bool input = inputSlotDict.count(slot); |
| 647 | - bool output = outputSlotDict.count(slotList[i]); | 655 | + bool output = outputSlotDict.count(slot); |
| 648 | - bool named = slotNameDict.count(slotList[i]); | 656 | + bool named = slotNameDict.count(slot); |
| 649 | - bool parial = partialUpdateSlotIndexSet.count(i); | 657 | + bool parial = partialUpdateSlotIndexSet.count(index); |
| 650 | if (live || input || output || named) { | 658 | if (live || input || output || named) { |
| 651 | - oss << "slot[" << std::setw(width2) << i << "]: "; | 659 | + oss << "slot[" << std::setw(width2) << index << "]: "; |
| 652 | oss << std::setw(width2) << (live ? 'L' : ' '); | 660 | oss << std::setw(width2) << (live ? 'L' : ' '); |
| 653 | oss << std::setw(width2) << (assemble ? 'A' : ' '); | 661 | oss << std::setw(width2) << (assemble ? 'A' : ' '); |
| 654 | oss << std::setw(width2) << (shmemTensor ? 'S' : ' '); | 662 | oss << std::setw(width2) << (shmemTensor ? 'S' : ' '); |
| 655 | oss << std::setw(width2) << (parial ? 'P' : ' '); | 663 | oss << std::setw(width2) << (parial ? 'P' : ' '); |
| 656 | oss << std::setw(width6) | 664 | oss << std::setw(width6) |
| 657 | - << (input ? "in:" + std::to_string(inputSlotDict.find(slotList[i])->second) : std::string(" ")); | 665 | + << (input ? "in:" + std::to_string(inputSlotDict.find(slot)->second) : std::string(" ")); |
| 658 | oss << std::setw(width7) | 666 | oss << std::setw(width7) |
| 659 | - << (output ? "out:" + std::to_string(outputSlotDict.find(slotList[i])->second) : std::string(" ")); | 667 | + << (output ? "out:" + std::to_string(outputSlotDict.find(slot)->second) : std::string(" ")); |
| 660 | if (live) { | 668 | if (live) { |
| 661 | - oss << " " << slotList[i].Dump() << "\n"; | 669 | + oss << " " << slot.Dump() << "\n"; |
| 662 | } else { | 670 | } else { |
| 663 | - oss << " " << slotList[i].DumpHead(slotNameDict.find(slotList[i])->second) << "\n"; | 671 | + oss << " " << slot.DumpHead(slotNameDict.find(slot)->second) << "\n"; |
| 664 | } | 672 | } |
| 665 | } | 673 | } |
| 666 | } | 674 | } |
| @@ -532,6 +532,9 @@ def DeviceInit(): ... | |||
| 532 | def DeviceFini(): ... | 532 | def DeviceFini(): ... |
| 533 | 533 | ||
| 534 | 534 | ||
| 535 | +def GetSlotInfo() -> dict[str, int]: | ||
| 536 | + ... | ||
| 537 | + | ||
| 535 | 538 | ||
| 536 | def CopyToHost(devTensor: DeviceTensorData, hostTensor: DeviceTensorData): ... | 539 | def CopyToHost(devTensor: DeviceTensorData, hostTensor: DeviceTensorData): ... |
| 537 | 540 | ||
| @@ -1689,9 +1689,6 @@ class Program(IRNode): | |||
| 1689 | name: Final[str] | 1689 | name: Final[str] |
| 1690 | """Program name.""" | 1690 | """Program name.""" |
| 1691 | 1691 | ||
| 1692 | - functions: Final[list[Function]] | ||
| 1693 | - """List of functions, sorted by GlobalVar name.""" | ||
| 1694 | - | ||
| 1695 | def __init__( | 1692 | def __init__( |
| 1696 | self, | 1693 | self, |
| 1697 | functions: list[Function], | 1694 | functions: list[Function], |
| @@ -1723,6 +1720,10 @@ class Program(IRNode): | |||
| 1723 | Function if found, None otherwise | 1720 | Function if found, None otherwise |
| 1724 | """ | 1721 | """ |
| 1725 | 1722 | ||
| 1723 | + @property | ||
| 1724 | + def functions(self) -> dict[str, Function]: | ||
| 1725 | + """List of functions, sorted by GlobalVar name.""" | ||
| 1726 | + | ||
| 1726 | 1727 | ||
| 1727 | # ========== IR Builder ========== | 1728 | # ========== IR Builder ========== |
| 1728 | 1729 | ||
| @@ -102,6 +102,19 @@ void BindFunction(py::module_& m) | |||
| 102 | m.def( | 102 | m.def( |
| 103 | "GetCurrentFunction", []() -> Function* { return Program::GetInstance().GetCurrentFunction(); }, | 103 | "GetCurrentFunction", []() -> Function* { return Program::GetInstance().GetCurrentFunction(); }, |
| 104 | py::return_value_policy::reference, "Get the current function being built in the Program"); | 104 | py::return_value_policy::reference, "Get the current function being built in the Program"); |
| 105 | + | ||
| 106 | + // All slot info (logical tensor -> slot id) | ||
| 107 | + m.def( | ||
| 108 | + "GetSlotInfo", | ||
| 109 | + []() -> py::dict { | ||
| 110 | + py::dict slots; | ||
| 111 | + auto slotManager = Program::GetInstance().GetTensorSlotManager(); | ||
| 112 | + for (auto& [lt, tensor] : slotManager->slotTensorDict) { | ||
| 113 | + slots[lt->name_.c_str()] = tensor->Id(); | ||
| 114 | + } | ||
| 115 | + return slots; | ||
| 116 | + }, | ||
| 117 | + "Every slot entry as {tensor name: slot id}; tensors sharing a slot id share one runtime buffer"); | ||
| 105 | } | 118 | } |
| 106 | 119 | ||
| 107 | } // namespace pypto | 120 | } // namespace pypto |
| @@ -62,27 +62,65 @@ def ssa_verify(func, desc: str = ""): | |||
| 62 | _ssa_verify(verifier, prog, desc) | 62 | _ssa_verify(verifier, prog, desc) |
| 63 | 63 | ||
| 64 | 64 | ||
| 65 | +def _run_pass_pipeline(func, *args, passes, verify_skip=(), create_new_logical_tensor=True): | ||
| 66 | + ir_func = pil.compile(func, *args, create_new_logical_tensor=create_new_logical_tensor) | ||
| 67 | + prog = ir.IRBuilder().create_program([ir_func], "main", ir.Span.unknown()) | ||
| 68 | + verifier = ir.IRVerifier.create_default() | ||
| 69 | + _ssa_verify(verifier, prog, "original") | ||
| 70 | + for name, transform in passes: | ||
| 71 | + prog = transform(prog) | ||
| 72 | + if name not in verify_skip: | ||
| 73 | + _ssa_verify(verifier, prog, name) | ||
| 74 | + return prog.functions[ir_func.name], prog | ||
| 75 | + | ||
| 76 | + | ||
| 65 | def run_merge_pass(func, *args, create_new_logical_tensor=True): | 77 | def run_merge_pass(func, *args, create_new_logical_tensor=True): |
| 66 | - """Compile a kernel and run canonicalize + dce + merge_stmts_into_if + symbolic_scalar_simplify_pass, stopping | ||
| 67 | - before lowering so the resulting if-tree (func.body) is inspectable. Mirrors compile_new_ir's first half. | ||
| 68 | - """ | ||
| 69 | - b = ir.IRBuilder() | ||
| 70 | - func = pil.compile(func, *args, create_new_logical_tensor=create_new_logical_tensor) | ||
| 71 | - prog = b.create_program([func], "main", ir.Span.unknown()) | ||
| 72 | dce = ir.Pass.aggressive_dce() | 78 | dce = ir.Pass.aggressive_dce() |
| 73 | canonical = ir.Pass.canonicalize() | 79 | canonical = ir.Pass.canonicalize() |
| 74 | merge = ir.Pass.merge_stmts_into_if() | 80 | merge = ir.Pass.merge_stmts_into_if() |
| 75 | - simplify_symbolic_scalar = ir.Pass.simplify_symbolic_scalar() | 81 | + passes = [ |
| 76 | - verifier = ir.IRVerifier.create_default() | 82 | + ("canonicalize_dce", lambda p:dce(canonical(p))), |
| 77 | - _ssa_verify(verifier, prog, "original") | 83 | + ("canonicalize(merge_stmts)", lambda p:canonical(merge(p))), |
| 78 | - prog = canonical(prog) | 84 | + # only symbolic scalar are simplified, skip ssa_verify |
| 79 | - _ssa_verify(verifier, prog, "canonical") | 85 | + ("simplify_symbolic_scalar", ir.Pass.simplify_symbolic_scalar()), |
| 80 | - prog = dce(prog) | 86 | + ] |
| 81 | - _ssa_verify(verifier, prog, "dce") | 87 | + func, _ = _run_pass_pipeline( |
| 82 | - prog = canonical(merge(prog)) | 88 | + func, |
| 83 | - _ssa_verify(verifier, prog, "merged") | 89 | + *args, |
| 84 | - # only symbolic scalar are simplified, skip ssa_verify | 90 | + passes=passes, |
| 85 | - prog = simplify_symbolic_scalar(prog) | 91 | + verify_skip={"simplify_symbolic_scalar"}, |
| 86 | - func = prog.functions[func.name] | 92 | + create_new_logical_tensor=create_new_logical_tensor, |
| 93 | + ) | ||
| 87 | logging.info("\nmerged:\n%s" % func.body) | 94 | logging.info("\nmerged:\n%s" % func.body) |
| 88 | return func | 95 | return func |
| 96 | + | ||
| 97 | + | ||
| 98 | +def run_root_function(func, *args, create_new_logical_tensor=True): | ||
| 99 | + """Compile a kernel and run the compile_new_ir pass sequence up to and including | ||
| 100 | + create_root_functions, stopping before finalize so the root functions are inspectable. | ||
| 101 | + Returns the final program. | ||
| 102 | + """ | ||
| 103 | + infer_token = ir.Pass.infer_token_pass() | ||
| 104 | + dce = ir.Pass.aggressive_dce() | ||
| 105 | + canonicalize = ir.Pass.canonicalize() | ||
| 106 | + merge_stmts = ir.Pass.merge_stmts_into_if() | ||
| 107 | + remove_redundant_tokens = ir.Pass.remove_redundant_token_pass() | ||
| 108 | + passes = [ | ||
| 109 | + ("infer_token_pass", infer_token), | ||
| 110 | + ("canonicalize_dce", lambda p:dce(canonicalize(p))), | ||
| 111 | + ("canonicalize_dce2", lambda p:dce(canonicalize(p))), | ||
| 112 | + ("canonicalize(merge_stmts)", lambda p:canonicalize(merge_stmts(p))), | ||
| 113 | + # only symbolic scalar are simplified, skip ssa_verify | ||
| 114 | + ("simplify_symbolic_scalar", ir.Pass.simplify_symbolic_scalar()), | ||
| 115 | + ("remove_redundant_token_pass", remove_redundant_tokens), | ||
| 116 | + # create_root_functions does not support ssa_verify yet, skip it | ||
| 117 | + ("create_root_functions", ir.Pass.create_root_functions()), | ||
| 118 | + ] | ||
| 119 | + _, prog = _run_pass_pipeline( | ||
| 120 | + func, | ||
| 121 | + *args, | ||
| 122 | + passes=passes, | ||
| 123 | + verify_skip={"simplify_symbolic_scalar", "create_root_functions"}, | ||
| 124 | + create_new_logical_tensor=create_new_logical_tensor, | ||
| 125 | + ) | ||
| 126 | + return prog | ||
| @@ -0,0 +1,74 @@ | |||
| 1 | +# -*- coding: utf-8 -*- | ||
| 2 | +# Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 3 | +# This program is free software; you can redistribute it and/or modify it under the terms and | ||
| 4 | +# CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 5 | +# Please refer to the License for details. You should not use this file except in compliance with the License. | ||
| 6 | +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 7 | +# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 8 | +import pypto | ||
| 9 | +import pypto.pypto_impl as pypto_impl | ||
| 10 | + | ||
| 11 | +from .test_common import run_root_function | ||
| 12 | + | ||
| 13 | + | ||
| 14 | +def war_conflict_pypto( | ||
| 15 | + a: pypto.Tensor[[pypto.DYNAMIC, pypto.STATIC], pypto.DT_BF16], | ||
| 16 | + w: pypto.Tensor[[pypto.STATIC, pypto.STATIC], pypto.DT_BF16], | ||
| 17 | + out: pypto.Tensor[[pypto.DYNAMIC, pypto.STATIC], pypto.DT_BF16], | ||
| 18 | +): | ||
| 19 | + tile_b = 128 | ||
| 20 | + hidden = 128 | ||
| 21 | + batch_size = a.shape[0] | ||
| 22 | + b_loop = (batch_size + tile_b - 1) // tile_b | ||
| 23 | + dtype = a.dtype | ||
| 24 | + | ||
| 25 | + for b_idx in pypto.loop(b_loop, unroll_list=[1, 2]): | ||
| 26 | + off = b_idx * tile_b | ||
| 27 | + | ||
| 28 | + pypto.set_cube_tile_shapes([128, 128], [128, 128], [128, 128]) | ||
| 29 | + pypto.set_vec_tile_shapes(128, 128) | ||
| 30 | + | ||
| 31 | + a_view = pypto.view(a, [tile_b, hidden], [off, 0]) | ||
| 32 | + | ||
| 33 | + # ---- C1: Cube — matmul ---- | ||
| 34 | + c1 = pypto.matmul(a_view, w, out_dtype=dtype) | ||
| 35 | + | ||
| 36 | + # ---- V1: Vector — add ---- | ||
| 37 | + v1 = pypto.add(c1, a_view) | ||
| 38 | + | ||
| 39 | + # ---- Write output rows [off, off+tile_b) ---- | ||
| 40 | + pypto.assemble(v1, [off, 0], out) | ||
| 41 | + | ||
| 42 | + # Read back the rows just written | ||
| 43 | + o_read = pypto.view(out, [tile_b, hidden], [off, 0]) | ||
| 44 | + | ||
| 45 | + # ---- C2: Cube — matmul on read-back data ---- | ||
| 46 | + c2 = pypto.matmul(o_read, w, out_dtype=dtype) | ||
| 47 | + | ||
| 48 | + # ---- V2: Vector — add ---- | ||
| 49 | + v2 = pypto.add(c2, c1) | ||
| 50 | + | ||
| 51 | + # ---- Write to OVERLAPPING region: rows [off+tile_b//2, off+tile_b//2+tile_b) ---- | ||
| 52 | + # This overlaps with the read region [off, off+tile_b) by tile_b//2 rows. | ||
| 53 | + pypto.assemble(v2, [off + tile_b // 2, 0], out) | ||
| 54 | + | ||
| 55 | + | ||
| 56 | +def test_war_conflict(): | ||
| 57 | + a = pypto.Tensor([-1, 128], pypto.DT_BF16) | ||
| 58 | + w = pypto.Tensor([128, 128], pypto.DT_BF16) | ||
| 59 | + out = pypto.Tensor([-1, 128], pypto.DT_BF16) | ||
| 60 | + | ||
| 61 | + with pypto.options(pass_options={"enable_slice": True}): | ||
| 62 | + prog = run_root_function(war_conflict_pypto, a, w, out, create_new_logical_tensor=True) | ||
| 63 | + | ||
| 64 | + slot_info = pypto_impl.GetSlotInfo() | ||
| 65 | + out_slot = slot_info['out'] | ||
| 66 | + for name, func in prog.functions.items(): | ||
| 67 | + if "_hiddenfunc" in name: | ||
| 68 | + outs = [x.name for x in func.params if x.name.startswith("out")] | ||
| 69 | + if "Unroll1" in name: | ||
| 70 | + assert len(outs) == 2 | ||
| 71 | + assert set(slot_info[x] for x in outs) == {out_slot} | ||
| 72 | + elif "Unroll2" in name: | ||
| 73 | + assert len(outs) == 3 | ||
| 74 | + assert set(slot_info[x] for x in outs) == {out_slot} | ||
Rpython/tests/ut/ir/token/test_assemble_latest_outcast.pypto→python/tests/ut/ir/token/test_assemble_all_versions.pypto+10-8
| @@ -1,20 +1,22 @@ | |||
| 1 | program #entry(foo) { | 1 | program #entry(foo) { |
| 2 | function foo incast(v0_logical_tensor %src@0 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]), v0_logical_tensor %out@1 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16])) outcast() #type(Orchestration) #entry(true) { | 2 | function foo incast(v0_logical_tensor %src@0 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]), v0_logical_tensor %out@1 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16])) outcast() #type(Orchestration) #entry(true) { |
| 3 | - v0_logical_tensor %out_5@1 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]) = !10000 CALL(%src@0) token(); | 3 | + v0_logical_tensor %out_1@1 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]), v0_logical_tensor %out_3@7 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]), v0_logical_tensor %out_5@7 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]) = !10000 CALL(%src@0) token(); |
| 4 | - return %src@0, %out_5@1; | 4 | + return %src@0, %out_5@7; |
| 5 | } | 5 | } |
| 6 | - function foo_PATH0_6 incast(v0_logical_tensor %src_3@8 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]), v0_logical_tensor %out_9@10 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16])) outcast() #type(InCore) #entry(false) { | 6 | + function foo_PATH0_6 incast(v0_logical_tensor %src_3@10 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]), v0_logical_tensor %out_1@12 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]), v0_logical_tensor %out_3@12 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]), v0_logical_tensor %out_5@12 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16])) outcast() #type(InCore) #entry(false) { |
| 7 | - v0_logical_tensor %INCAST_LOCAL_BUF0_0@9 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]) = !10001 VIEW(%src_3@8) token() #fromOffset([0, 0]) #toValidShape([16, 16]); | 7 | + v0_logical_tensor %INCAST_LOCAL_BUF0_0@11 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]) = !10001 VIEW(%src_3@10) token() #fromOffset([0, 0]) #toValidShape([16, 16]); |
| 8 | - v0_logical_tensor %OUTCAST_LOCAL_BUF0@11 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]) = !10000 CALL(%INCAST_LOCAL_BUF0_0@9) token(); | 8 | + v0_logical_tensor %OUTCAST_LOCAL_BUF0@13 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]), v0_logical_tensor %OUTCAST_LOCAL_BUF1@15 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]), v0_logical_tensor %OUTCAST_LOCAL_BUF2@17 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]) = !10000 CALL(%INCAST_LOCAL_BUF0_0@11) token(); |
| 9 | - v0_logical_tensor %out_9@10 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]) = !10002 ASSEMBLE(%OUTCAST_LOCAL_BUF0@11) token() #toOffset([0, 0]); | 9 | + v0_logical_tensor %out_1@12 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]) = !10002 ASSEMBLE(%OUTCAST_LOCAL_BUF0@13) token() #toOffset([0, 0]); |
| 10 | + v0_logical_tensor %out_3@12 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]) = !10003 ASSEMBLE(%OUTCAST_LOCAL_BUF1@15) token() #toOffset([0, 0]); | ||
| 11 | + v0_logical_tensor %out_5@12 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]) = !10004 ASSEMBLE(%OUTCAST_LOCAL_BUF2@17) token() #toOffset([0, 0]); | ||
| 10 | } | 12 | } |
| 11 | - function foo_PATH0_hiddenfunc_4 incast(v0_logical_tensor %src_1@5 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]), v0_logical_tensor %out_7@7 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16])) outcast() #type(InCore) #entry(false) { | 13 | + function foo_PATH0_hiddenfunc_4 incast(v0_logical_tensor %src_1@5 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]), v0_logical_tensor %out_1@7 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]), v0_logical_tensor %out_3@7 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]), v0_logical_tensor %out_5@7 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16])) outcast() #type(InCore) #entry(false) { |
| 12 | v0_logical_tensor %INCAST_LOCAL_BUF0@6 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]) = !10006 VIEW(%src_1@5) token() #fromOffset([0, 0]) #toValidShape([16, 16]); | 14 | v0_logical_tensor %INCAST_LOCAL_BUF0@6 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]) = !10006 VIEW(%src_1@5) token() #fromOffset([0, 0]) #toValidShape([16, 16]); |
| 13 | v0_logical_tensor %$0@2 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]) = !10000 ADDS(%INCAST_LOCAL_BUF0@6) token(); | 15 | v0_logical_tensor %$0@2 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]) = !10000 ADDS(%INCAST_LOCAL_BUF0@6) token(); |
| 14 | v0_logical_tensor %out_1@7 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]) = !10001 ASSEMBLE(%$0@2) token() #toOffset([0, 0]); | 16 | v0_logical_tensor %out_1@7 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]) = !10001 ASSEMBLE(%$0@2) token() #toOffset([0, 0]); |
| 15 | v0_logical_tensor %$1@3 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]) = !10002 ADDS(%INCAST_LOCAL_BUF0@6) token(); | 17 | v0_logical_tensor %$1@3 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]) = !10002 ADDS(%INCAST_LOCAL_BUF0@6) token(); |
| 16 | v0_logical_tensor %out_3@7 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]) = !10003 ASSEMBLE(%$1@3) token() #toOffset([0, 0]); | 18 | v0_logical_tensor %out_3@7 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]) = !10003 ASSEMBLE(%$1@3) token() #toOffset([0, 0]); |
| 17 | v0_logical_tensor %$2@4 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]) = !10004 ADDS(%INCAST_LOCAL_BUF0@6) token(); | 19 | v0_logical_tensor %$2@4 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]) = !10004 ADDS(%INCAST_LOCAL_BUF0@6) token(); |
| 18 | - v0_logical_tensor %out_7@7 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]) = !10005 ASSEMBLE(%$2@4) token() #toOffset([0, 0]); | 20 | + v0_logical_tensor %out_5@7 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]) = !10005 ASSEMBLE(%$2@4) token() #toOffset([0, 0]); |
| 19 | } | 21 | } |
| 20 | } | 22 | } |
| @@ -18,7 +18,7 @@ from ..test_common import _ssa_verify, check_snapshot | |||
| 18 | _GOLDEN_DIR = Path(__file__).parent | 18 | _GOLDEN_DIR = Path(__file__).parent |
| 19 | 19 | ||
| 20 | IR = _GOLDEN_DIR / "test_assemble_outcast_versions.pypto" | 20 | IR = _GOLDEN_DIR / "test_assemble_outcast_versions.pypto" |
| 21 | -LATEST_OUTCAST_IR = _GOLDEN_DIR / "test_assemble_latest_outcast.pypto" | 21 | +LATEST_OUTCAST_IR = _GOLDEN_DIR / "test_assemble_all_versions.pypto" |
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | def _run_root_builder(func, *args): | 24 | def _run_root_builder(func, *args): |
| @@ -37,7 +37,8 @@ def _run_root_builder(func, *args): | |||
| 37 | 37 | ||
| 38 | 38 | ||
| 39 | def test_assemble_outcast_versions_share_raw_tensor(): | 39 | def test_assemble_outcast_versions_share_raw_tensor(): |
| 40 | - """MakeOutcasts preserves distinct Assemble versions on one RawTensor.""" | 40 | + """MakeOutcasts keeps every assemble version of one RawTensor as its own |
| 41 | + outcast entry (aux_1, aux_3), and the entries share one slot.""" | ||
| 41 | 42 | ||
| 42 | def foo(a, aux, out): | 43 | def foo(a, aux, out): |
| 43 | pypto.set_vec_tile_shapes(16, 16) | 44 | pypto.set_vec_tile_shapes(16, 16) |
| @@ -53,8 +54,9 @@ def test_assemble_outcast_versions_share_raw_tensor(): | |||
| 53 | check_snapshot(program, IR) | 54 | check_snapshot(program, IR) |
| 54 | 55 | ||
| 55 | 56 | ||
| 56 | -def test_repeated_assemble_uses_single_latest_outcast(): | 57 | +def test_repeated_assemble_keeps_all_versions_on_slot(): |
| 57 | - """ComputeOutcast deduplicates versions by RawTensor and keeps the latest one.""" | 58 | + """Every assemble version of an outcast slot becomes an outcast entry |
| 59 | + (out_1, out_3, out_5 on one slot); only the latest version is returned.""" | ||
| 58 | 60 | ||
| 59 | def foo(src, out): | 61 | def foo(src, out): |
| 60 | pypto.assemble(src + 1.0, [0, 0], out) | 62 | pypto.assemble(src + 1.0, [0, 0], out) |
| @@ -1,21 +1,22 @@ | |||
| 1 | program #entry(foo) { | 1 | program #entry(foo) { |
| 2 | function foo incast(v0_logical_tensor %a@0 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]), v0_logical_tensor %aux@1 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]), v0_logical_tensor %out@2 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16])) outcast() #type(Orchestration) #entry(true) { | 2 | function foo incast(v0_logical_tensor %a@0 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]), v0_logical_tensor %aux@1 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]), v0_logical_tensor %out@2 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16])) outcast() #type(Orchestration) #entry(true) { |
| 3 | - v0_logical_tensor %aux_3@1 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]), v0_logical_tensor %out_0@5 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]) = !10000 CALL(%a@0) token(); | 3 | + v0_logical_tensor %aux_1@1 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]), v0_logical_tensor %aux_3@8 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]), v0_logical_tensor %out_0@5 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]) = !10000 CALL(%a@0) token(); |
| 4 | - return %a@0, %aux_3@1, %out_0@5; | 4 | + return %a@0, %aux_3@8, %out_0@5; |
| 5 | } | 5 | } |
| 6 | - function foo_PATH0_6 incast(v0_logical_tensor %a_3@11 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]), v0_logical_tensor %aux_7@13 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]), v0_logical_tensor %out_4@15 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16])) outcast() #type(InCore) #entry(false) { | 6 | + function foo_PATH0_6 incast(v0_logical_tensor %a_3@12 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]), v0_logical_tensor %aux_1@14 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]), v0_logical_tensor %aux_3@14 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]), v0_logical_tensor %out_4@18 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16])) outcast() #type(InCore) #entry(false) { |
| 7 | - v0_logical_tensor %INCAST_LOCAL_BUF0_0@12 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]) = !10001 VIEW(%a_3@11) token() #fromOffset([0, 0]) #toValidShape([32, 16]); | 7 | + v0_logical_tensor %INCAST_LOCAL_BUF0_0@13 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]) = !10001 VIEW(%a_3@12) token() #fromOffset([0, 0]) #toValidShape([32, 16]); |
| 8 | - v0_logical_tensor %OUTCAST_LOCAL_BUF0@14 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]), v0_logical_tensor %OUTCAST_LOCAL_BUF1_0@16 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]) = !10000 CALL(%INCAST_LOCAL_BUF0_0@12) token(); | 8 | + v0_logical_tensor %OUTCAST_LOCAL_BUF0@15 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]), v0_logical_tensor %OUTCAST_LOCAL_BUF1@17 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]), v0_logical_tensor %OUTCAST_LOCAL_BUF2_0@19 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]) = !10000 CALL(%INCAST_LOCAL_BUF0_0@13) token(); |
| 9 | - v0_logical_tensor %aux_7@13 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]) = !10002 ASSEMBLE(%OUTCAST_LOCAL_BUF0@14) token() #toOffset([0, 0]); | 9 | + v0_logical_tensor %aux_1@14 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]) = !10002 ASSEMBLE(%OUTCAST_LOCAL_BUF0@15) token() #toOffset([0, 0]); |
| 10 | - v0_logical_tensor %out_4@15 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]) = !10003 ASSEMBLE(%OUTCAST_LOCAL_BUF1_0@16) token() #toOffset([0, 0]); | 10 | + v0_logical_tensor %aux_3@14 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]) = !10003 ASSEMBLE(%OUTCAST_LOCAL_BUF1@17) token() #toOffset([0, 0]); |
| 11 | + v0_logical_tensor %out_4@18 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]) = !10004 ASSEMBLE(%OUTCAST_LOCAL_BUF2_0@19) token() #toOffset([0, 0]); | ||
| 11 | } | 12 | } |
| 12 | - function foo_PATH0_hiddenfunc_4 incast(v0_logical_tensor %a_1@6 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]), v0_logical_tensor %aux_5@8 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]), v0_logical_tensor %out_2@9 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16])) outcast() #type(InCore) #entry(false) { | 13 | + function foo_PATH0_hiddenfunc_4 incast(v0_logical_tensor %a_1@6 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]), v0_logical_tensor %aux_1@8 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]), v0_logical_tensor %aux_3@8 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]), v0_logical_tensor %out_2@10 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16])) outcast() #type(InCore) #entry(false) { |
| 13 | v0_logical_tensor %INCAST_LOCAL_BUF0@7 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]) = !10005 VIEW(%a_1@6) token() #fromOffset([0, 0]) #toValidShape([32, 16]); | 14 | v0_logical_tensor %INCAST_LOCAL_BUF0@7 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]) = !10005 VIEW(%a_1@6) token() #fromOffset([0, 0]) #toValidShape([32, 16]); |
| 14 | v0_logical_tensor %$0@3 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]) = !10000 VEC_DUP() token(); | 15 | v0_logical_tensor %$0@3 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]) = !10000 VEC_DUP() token(); |
| 15 | v0_logical_tensor %aux_1@8 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]) = !10001 ASSEMBLE(%$0@3) token() #toOffset([0, 0]); | 16 | v0_logical_tensor %aux_1@8 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]) = !10001 ASSEMBLE(%$0@3) token() #toOffset([0, 0]); |
| 16 | v0_logical_tensor %$1@4 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]) = !10002 VEC_DUP() token(); | 17 | v0_logical_tensor %$1@4 #dtype(float) #shape([16, 16]) #offset([0, 0]) #dynvalidshape([16, 16]) = !10002 VEC_DUP() token(); |
| 17 | - v0_logical_tensor %aux_5@8 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]) = !10003 ASSEMBLE(%$1@4) token() #toOffset([16, 0]); | 18 | + v0_logical_tensor %aux_3@8 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]) = !10003 ASSEMBLE(%$1@4) token() #toOffset([16, 0]); |
| 18 | - v0_logical_tensor %OUTCAST_LOCAL_BUF1@10 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]) = !10004 ADD(%INCAST_LOCAL_BUF0@7, %aux_5@8) token(); | 19 | + v0_logical_tensor %OUTCAST_LOCAL_BUF2@11 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]) = !10004 ADD(%INCAST_LOCAL_BUF0@7, %aux_3@8) token(); |
| 19 | - v0_logical_tensor %out_2@9 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]) = !10006 ASSEMBLE(%OUTCAST_LOCAL_BUF1@10) token() #toOffset([0, 0]); | 20 | + v0_logical_tensor %out_2@10 #dtype(float) #shape([32, 16]) #offset([0, 0]) #dynvalidshape([32, 16]) = !10006 ASSEMBLE(%OUTCAST_LOCAL_BUF2@11) token() #toOffset([0, 0]); |
| 20 | } | 21 | } |
| 21 | } | 22 | } |