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 : template <typename... Arguments>
27 34 : LoopBlock& operator()(const Arguments&... args)
28 : {
29 34 : DefineInArgHelper(args...);
30 34 : return *this;
31 : }
32 :
33 : private:
34 : template <typename First>
35 34 : void DefineInArgHelper(const First& first)
36 : {
37 34 : repLoopBlock->DefineArg(first);
38 34 : }
39 :
40 : template <typename First, typename... Rest>
41 70 : void DefineInArgHelper(const First& first, const Rest&... rest)
42 : {
43 70 : repLoopBlock->DefineArg(first);
44 70 : DefineInArgHelper(rest...);
45 70 : }
46 :
47 : CcuRepContext* context{nullptr};
48 : std::string label;
49 :
50 : std::shared_ptr<CcuRepLoopBlock> repLoopBlock{nullptr};
51 : std::shared_ptr<CcuRepBlock> curActiveBlock{nullptr};
52 : };
53 :
54 : }; // namespace CcuRep
55 : }; // namespace Hccl
56 : #endif // HCCL_CCU_LOOP_BLOCK_H
|