Line data Source code
1 : /**
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 conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may 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 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 :
11 : #include "ccu_rep_v1.h"
12 : #include "string_util.h"
13 : #include "exception_util.h"
14 : #include "ccu_api_exception.h"
15 : #include "ccu_ins_generater_v1.h"
16 : #include "ccu_kernel.h"
17 : namespace hcomm {
18 : namespace CcuRep {
19 :
20 0 : CcuRepNot::CcuRepNot(CcuInsGeneraterBase* insGenPtr, const Variable &varC, const Variable &varB)
21 0 : : subType(NotSubType::VAR_EQUALS_NOT_VAR), varB(varB), varC(varC), insGenPtr(insGenPtr)
22 : {
23 0 : type = CcuRepType::NOT;
24 0 : instrCount = insGenPtr->GetInstrCount(type);
25 0 : }
26 :
27 0 : bool CcuRepNot::Translate(CcuKernel* ccuKernel, CcuInstr *&instr, uint16_t &curInstrId, const TransDep &dep)
28 : {
29 0 : Hccl::CHECK_NULLPTR(instr, "[CcuRepNot::Translate] instr is nullptr!");
30 0 : this->instrId = curInstrId;
31 0 : translated = true;
32 0 : instrCount = insGenPtr->GetInstrCount(type);
33 0 : insGenPtr->CcuRepNotTranslate(ccuKernel, instr, this, dep);
34 0 : CHK_PRT_THROW((curInstrId > UINT16_MAX - instrCount),
35 : HCCL_ERROR("[CcuRepNot::Translate]uint16 integer overflow occurs, curInstrId = [%hu], instrCount = [%hu]", curInstrId, instrCount),
36 : Hccl::InternalException, "integer overflow");
37 0 : curInstrId += instrCount;
38 0 : return translated;
39 : }
40 :
41 0 : std::string CcuRepNot::Describe()
42 : {
43 0 : switch (subType) {
44 0 : case NotSubType::VAR_EQUALS_NOT_VAR: {
45 0 : return Hccl::StringFormat("Variable[%u] = ~Variable[%u]", varC.Id(), varB.Id());
46 : }
47 0 : default: {
48 0 : return Hccl::StringFormat("Invalid Not");
49 : }
50 : }
51 : }
52 :
53 : }; // namespace CcuRep
54 : }; // namespace hcomm
|