Line data Source code
1 : /**
2 : * Copyright (c) 2025 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 HCCL_CCU_LOOP_BLOCK_H
12 : #define HCCL_CCU_LOOP_BLOCK_H
13 :
14 : #include "ccu_rep_block.h"
15 : #include "ccu_rep_loopblock.h"
16 : #include "ccu_rep_context.h"
17 :
18 : namespace Hccl {
19 : namespace CcuRep {
20 :
21 : class LoopBlock {
22 : public:
23 : LoopBlock(CcuRepContext *context, std::string label);
24 : ~LoopBlock();
25 :
26 38 : template <typename... Arguments> LoopBlock &operator()(const Arguments &...args)
27 : {
28 38 : DefineInArgHelper(args...);
29 38 : return *this;
30 : }
31 :
32 : private:
33 38 : template <typename First> void DefineInArgHelper(const First &first)
34 : {
35 38 : repLoopBlock->DefineArg(first);
36 38 : }
37 :
38 80 : template <typename First, typename... Rest> void DefineInArgHelper(const First &first, const Rest &...rest)
39 : {
40 80 : repLoopBlock->DefineArg(first);
41 80 : DefineInArgHelper(rest...);
42 80 : }
43 :
44 : CcuRepContext *context{nullptr};
45 : std::string label;
46 :
47 : std::shared_ptr<CcuRepLoopBlock> repLoopBlock{nullptr};
48 : std::shared_ptr<CcuRepBlock> curActiveBlock{nullptr};
49 : };
50 :
51 : }; // namespace CcuRep
52 : }; // namespace Hccl
53 : #endif // HCCL_CCU_LOOP_BLOCK_H
|