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_generator_v1.h"
16 : #include "ccu_kernel.h"
17 : namespace hcomm {
18 : namespace CcuRep {
19 :
20 1 : CcuRepNot::CcuRepNot(CcuInsGeneratorBase* insGenPtr, const Variable& varC, const Variable& varB)
21 1 : : subType(NotSubType::VAR_EQUALS_NOT_VAR),
22 1 : varB(varB),
23 1 : varC(varC),
24 1 : insGenPtr(insGenPtr)
25 : {
26 1 : type = CcuRepType::NOT;
27 1 : instrCount = insGenPtr->GetInstrCount(type);
28 1 : }
29 :
30 1 : bool CcuRepNot::Translate(CcuKernel* ccuKernel, CcuInstr*& instr, uint16_t& curInstrId, const TransDep& dep)
31 : {
32 1 : Hccl::CHECK_NULLPTR(instr, "[CcuRepNot::Translate] instr is nullptr!");
33 1 : this->instrId = curInstrId;
34 1 : translated = true;
35 1 : instrCount = insGenPtr->GetInstrCount(type);
36 1 : CHK_PRT_THROW(
37 : insGenPtr->CcuRepNotTranslate(ccuKernel, instr, this, dep) != HcclResult::HCCL_SUCCESS,
38 : HCCL_ERROR("[CcuRepNot][Translate] failed to translate for instrId[%u]", instrId), Hccl::CcuApiException,
39 : "CcuRepNot translate failed");
40 1 : CHK_PRT_THROW(
41 : (curInstrId > UINT16_MAX - instrCount),
42 : HCCL_ERROR(
43 : "[CcuRepNot::Translate]uint16 integer overflow occurs, curInstrId = [%hu], instrCount = [%hu]",
44 : curInstrId, instrCount),
45 : Hccl::InternalException, "integer overflow");
46 1 : curInstrId += instrCount;
47 1 : return translated;
48 : }
49 :
50 1 : std::string CcuRepNot::Describe()
51 : {
52 1 : switch (subType) {
53 1 : case NotSubType::VAR_EQUALS_NOT_VAR: {
54 1 : return Hccl::StringFormat("Variable[%u] = ~Variable[%u]", varC.Id(), varB.Id());
55 : }
56 0 : default: {
57 0 : return Hccl::StringFormat("Invalid Not");
58 : }
59 : }
60 : }
61 :
62 : }; // namespace CcuRep
63 : }; // namespace hcomm
|