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_FUNC_BLOCK_H
12 : #define HCCL_CCU_FUNC_BLOCK_H
13 :
14 : #include "ccu_rep_block.h"
15 : #include "ccu_rep_funcblock.h"
16 : #include "ccu_rep_context.h"
17 :
18 : namespace Hccl {
19 : namespace CcuRep {
20 :
21 : class FuncBlock {
22 : public:
23 : FuncBlock(CcuRepContext *context, std::string label, uint16_t callLayer = FUNC_CALL_LAYER_INVALID);
24 : ~FuncBlock();
25 :
26 : template <typename... Arguments> FuncBlock &operator()(const Arguments &...args)
27 : {
28 : DefineInArgHelper(args...);
29 : return *this;
30 : }
31 :
32 4 : template <typename T> void DefineInArg(T &&arg)
33 : {
34 4 : repFuncBlock->DefineInArg(std::forward<T>(arg));
35 4 : }
36 :
37 4 : template <typename T> void DefineOutArg(T &&arg)
38 : {
39 4 : repFuncBlock->DefineOutArg(std::forward<T>(arg));
40 4 : }
41 :
42 : private:
43 : template <typename First> void DefineInArgHelper(const First &first)
44 : {
45 : repFuncBlock->DefineInArg(first);
46 : }
47 :
48 : template <typename First, typename... Rest> void DefineInArgHelper(const First &first, const Rest &...rest)
49 : {
50 : repFuncBlock->DefineInArg(first);
51 : DefineInArgHelper(rest...);
52 : }
53 :
54 : CcuRepContext *context{nullptr};
55 : std::string label;
56 :
57 : std::shared_ptr<CcuRepFuncBlock> repFuncBlock{nullptr};
58 : std::shared_ptr<CcuRepBlock> curActiveBlock{nullptr};
59 :
60 : uint16_t callLayer{FUNC_CALL_LAYER_INVALID};
61 : };
62 :
63 : }; // namespace CcuRep
64 : }; // namespace Hccl
65 : #endif // HCCL_CCU_FUNC_BLOCK_H
|