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 :
16 : #include "ccu_ins_generator_base.h"
17 : #include "ccu_kernel.h"
18 :
19 : namespace hcomm {
20 : namespace CcuRep {
21 :
22 : using namespace Hccl;
23 :
24 5 : CcuRepLoadVar::CcuRepLoadVar(CcuInsGeneratorBase* insGenPtr, const Variable& src, const Variable& var, uint32_t num)
25 5 : : insGeneratorPtr_(insGenPtr),
26 5 : src(src),
27 5 : var(var),
28 5 : num(num)
29 : {
30 5 : type = CcuRepType::LOAD_VAR;
31 5 : instrCount = insGeneratorPtr_->GetInstrCount(type);
32 5 : }
33 :
34 3 : bool CcuRepLoadVar::Translate(CcuKernel* ccuKernel, CcuInstr*& instr, uint16_t& instrId, const TransDep& dep)
35 : {
36 3 : Hccl::CHECK_NULLPTR(instr, "[CcuRepLoadVar::Translate] instr is nullptr!");
37 3 : this->instrId = instrId;
38 3 : translated = true;
39 3 : CHK_PRT_THROW(
40 : insGeneratorPtr_->CcuRepLoadVarTranslate(ccuKernel, instr, instrId, this, dep) != HcclResult::HCCL_SUCCESS,
41 : HCCL_ERROR("[CcuRepLoadVar][Translate] failed to translate for instrId[%u]", instrId),
42 : Hccl::CcuApiException, "CcuRepLoadVar translate failed");
43 3 : CHK_PRT_THROW(
44 : (instrId > UINT16_MAX - instrCount),
45 : HCCL_ERROR(
46 : "[CcuRepLoadVar::Translate]uint16 integer overflow occurs, instrId = [%hu], instrCount = [%hu]",
47 : instrId, instrCount),
48 : Hccl::InternalException, "integer overflow");
49 3 : instrId += instrCount;
50 :
51 3 : return translated;
52 : }
53 :
54 3 : std::string CcuRepLoadVar::Describe()
55 : {
56 3 : return Hccl::StringFormat("Load Var([%llu], [%u], [%u])", src.Id(), var.Id(), num);
57 : }
58 :
59 : }; // namespace CcuRep
60 : }; // namespace hcomm
|