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 53 : CcuRepLoadArg::CcuRepLoadArg(
25 53 : CcuInsGeneratorBase* insGenPtr, const Variable& var, uint16_t argId, uint16_t fullArgId)
26 53 : : insGeneratorPtr_(insGenPtr),
27 53 : var(var),
28 53 : argId(argId),
29 53 : fullArgId(fullArgId)
30 : {
31 53 : type = CcuRepType::LOAD_ARG;
32 53 : instrCount = insGeneratorPtr_->GetInstrCount(type);
33 53 : }
34 :
35 49 : bool CcuRepLoadArg::Translate(CcuKernel* ccuKernel, CcuInstr*& instr, uint16_t& instrId, const TransDep& dep)
36 : {
37 49 : this->instrId = instrId;
38 49 : translated = true;
39 :
40 49 : CHK_PRT_THROW(
41 : insGeneratorPtr_->CcuRepLoadArgTranslate(ccuKernel, instr, instrId, this, dep) != HcclResult::HCCL_SUCCESS,
42 : HCCL_ERROR("[CcuRepLoadArg][Translate] failed to translate for instrId[%u]", instrId),
43 : Hccl::CcuApiException, "CcuRepLoadArg translate failed");
44 :
45 49 : instrId += instrCount;
46 :
47 49 : return translated;
48 : }
49 :
50 48 : std::string CcuRepLoadArg::Describe()
51 : {
52 48 : return Hccl::StringFormat("Variable[%u] = Arg[%u] (slot=%u)", var.Id(), fullArgId, argId);
53 : }
54 :
55 : }; // namespace CcuRep
56 : }; // namespace hcomm
|