Merged
fix(function): Preserve normalized reshape copy valid shape #6683
fix(function): Preserve normalized reshape copy valid shape #6683
Merged
赵俊涵Add on Sep 23
Total: 1 files changed+8-6
@@ -3188,10 +3188,12 @@ static std::vector<SymbolicScalar> MaybeNormalizeValue(std::vector<OpImmediate>&
3188 bool valueToIndex)3188 bool valueToIndex)
3189{3189{
3190 std::vector<SymbolicScalar> coaList;3190 std::vector<SymbolicScalar> coaList;
3191- for (auto valueCoa : OpImmediate::ToSpecified(opImmList)) {3191+ auto values = OpImmediate::ToSpecified(opImmList);
3192- MaybeNormalizeValue(coaList, valueCoa, coaIndex, valueToIndex);3192+ for (auto& value : values) {
3193+ MaybeNormalizeValue(coaList, value, coaIndex, valueToIndex);
3193 coaIndex += 1;3194 coaIndex += 1;
3194 }3195 }
3196+ opImmList = OpImmediate::Specified(values);
3195 return coaList;3197 return coaList;
3196}3198}
3197 3199 
@@ -3227,7 +3229,7 @@ static std::vector<SymbolicScalar> NormalizeCopyIn(Operation* op, int coaIndexBa
3227 3229 
3228 opImmList = copyAttr->GetToDynValidShape();3230 opImmList = copyAttr->GetToDynValidShape();
3229 if (op->GetOpcode() == Opcode::OP_L1_COPY_IN_CONV) {3231 if (op->GetOpcode() == Opcode::OP_L1_COPY_IN_CONV) {
3230- auto valueCoaList = MaybeNormalizeValue(opImmList, coaIndex, valueToIndex);3232+ auto valueCoaList = MaybeNormalizeValue(opImmList, coaIndex, false);
3231 coaIndex += valueCoaList.size();3233 coaIndex += valueCoaList.size();
3232 operandCoaList.erase(operandCoaList.end() - valueCoaList.size(), operandCoaList.end());3234 operandCoaList.erase(operandCoaList.end() - valueCoaList.size(), operandCoaList.end());
3233 operandCoaList.insert(operandCoaList.end(), valueCoaList.begin(), valueCoaList.end());3235 operandCoaList.insert(operandCoaList.end(), valueCoaList.begin(), valueCoaList.end());
@@ -3272,7 +3274,7 @@ static std::vector<SymbolicScalar> NormalizeCopyOut(Operation* op, int coaIndexB
3272 3274 
3273 opImmList = copyAttr->GetFromDynValidShape();3275 opImmList = copyAttr->GetFromDynValidShape();
3274 if (op->GetOpcode() == Opcode::OP_L0C_COPY_OUT_CONV) {3276 if (op->GetOpcode() == Opcode::OP_L0C_COPY_OUT_CONV) {
3275- auto valueCoaList = MaybeNormalizeValue(opImmList, coaIndex, valueToIndex);3277+ auto valueCoaList = MaybeNormalizeValue(opImmList, coaIndex, false);
3276 coaIndex += valueCoaList.size();3278 coaIndex += valueCoaList.size();
3277 operandCoaList.erase(operandCoaList.end() - valueCoaList.size(), operandCoaList.end());3279 operandCoaList.erase(operandCoaList.end() - valueCoaList.size(), operandCoaList.end());
3278 operandCoaList.insert(operandCoaList.end(), valueCoaList.begin(), valueCoaList.end());3280 operandCoaList.insert(operandCoaList.end(), valueCoaList.begin(), valueCoaList.end());
@@ -3658,7 +3660,7 @@ void Function::NormalizeCoaForSpecialInfo(std::vector<std::vector<SymbolicScalar
3658 auto copyAttr = std::static_pointer_cast<CopyOpAttribute>(op->GetOpAttribute());3660 auto copyAttr = std::static_pointer_cast<CopyOpAttribute>(op->GetOpAttribute());
3659 auto validshape = copyAttr->GetFromDynValidShape();3661 auto validshape = copyAttr->GetFromDynValidShape();
3660 auto coaList = MaybeNormalizeValue(validshape, coaIndex, valueToIndex);3662 auto coaList = MaybeNormalizeValue(validshape, coaIndex, valueToIndex);
3661- copyAttr->SetFromDynValidShape(OpImmediate::Specified(coaList));3663+ copyAttr->SetFromDynValidShape(validshape);
3662 coaIndex += coaList.size();3664 coaIndex += coaList.size();
3663 coaLists.emplace_back(std::move(coaList));3665 coaLists.emplace_back(std::move(coaList));
3664 } else if (OpcodeManager::Inst().IsReshapeCopyOut(op->GetOpcode())) {3666 } else if (OpcodeManager::Inst().IsReshapeCopyOut(op->GetOpcode())) {
@@ -3666,7 +3668,7 @@ void Function::NormalizeCoaForSpecialInfo(std::vector<std::vector<SymbolicScalar
3666 auto copyAttr = std::static_pointer_cast<CopyOpAttribute>(op->GetOpAttribute());3668 auto copyAttr = std::static_pointer_cast<CopyOpAttribute>(op->GetOpAttribute());
3667 auto validshape = copyAttr->GetToDynValidShape();3669 auto validshape = copyAttr->GetToDynValidShape();
3668 auto coaList = MaybeNormalizeValue(validshape, coaIndex, valueToIndex);3670 auto coaList = MaybeNormalizeValue(validshape, coaIndex, valueToIndex);
3669- copyAttr->SetToDynValidShape(OpImmediate::Specified(coaList));3671+ copyAttr->SetToDynValidShape(validshape);
3670 coaIndex += coaList.size();3672 coaIndex += coaList.size();
3671 coaLists.emplace_back(std::move(coaList));3673 coaLists.emplace_back(std::move(coaList));
3672 }3674 }