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 : #ifndef HCOMM_CCU_REPRESENTATION_LOOP_H
12 : #define HCOMM_CCU_REPRESENTATION_LOOP_H
13 :
14 : #include <memory>
15 :
16 : #include "ccu_datatype_v1.h"
17 : #include "ccu_rep_base_v1.h"
18 : #include "ccu_rep_loopblock_v1.h"
19 :
20 : namespace hcomm {
21 : namespace CcuRep {
22 :
23 : class CcuRepLoop : public CcuRepBase {
24 : public:
25 : explicit CcuRepLoop(CcuInsGeneratorBase* insGeneratorPtr, const std::string& label, const Variable& loopParam);
26 : explicit CcuRepLoop(
27 : CcuInsGeneratorBase* insGeneratorPtr, const std::string& label, const Variable& loopParam,
28 : const Variable& loopIterNum, const Variable& loopGsaOffset);
29 : bool Translate(CcuKernel* ccuKernel, CcuInstr*& instr, uint16_t& instrId, const TransDep& dep) override;
30 : std::string Describe() override;
31 : const std::string& GetLabel() const;
32 :
33 : void Reference(std::shared_ptr<CcuRepLoopBlock> refRep);
34 : std::shared_ptr<CcuRepBase> SetLoopParam(Executor executor, Variable var);
35 1 : CcuRepLoopBlock* GetLoopBlock() { return loopBlock.get(); }
36 :
37 1 : Variable* GetLoopParam() { return &loopParam; }
38 0 : Variable GetLoopIterNum() { return loopIterNum; }
39 0 : Variable GetLoopGsaOffset() { return loopGsaOffset; }
40 :
41 : private:
42 : void ValidateInsGeneratorForLoop();
43 :
44 : CcuInsGeneratorBase* insGeneratorPtr_;
45 : std::string label;
46 : std::shared_ptr<CcuRepLoopBlock> loopBlock{nullptr};
47 :
48 : Variable loopParam;
49 : Variable loopIterNum;
50 : Variable loopGsaOffset;
51 : CcuInstr* instr{nullptr};
52 :
53 : bool supportCcuV1{false};
54 : bool supportCcuV2{false};
55 : };
56 :
57 : }; // namespace CcuRep
58 : }; // namespace hcomm
59 : #endif // HCCL_CCU_REPRESENTATION_LOOP_H
|