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>
27 : FuncBlock& operator()(const Arguments&... args)
28 : {
29 : DefineInArgHelper(args...);
30 : return *this;
31 : }
32 :
33 : template <typename T>
34 4 : void DefineInArg(T&& arg)
35 : {
36 4 : repFuncBlock->DefineInArg(std::forward<T>(arg));
37 4 : }
38 :
39 : template <typename T>
40 4 : void DefineOutArg(T&& arg)
41 : {
42 4 : repFuncBlock->DefineOutArg(std::forward<T>(arg));
43 3 : }
44 :
45 : private:
46 : template <typename First>
47 : void DefineInArgHelper(const First& first)
48 : {
49 : repFuncBlock->DefineInArg(first);
50 : }
51 :
52 : template <typename First, typename... Rest>
53 : void DefineInArgHelper(const First& first, const Rest&... rest)
54 : {
55 : repFuncBlock->DefineInArg(first);
56 : DefineInArgHelper(rest...);
57 : }
58 :
59 : CcuRepContext* context{nullptr};
60 : std::string label;
61 :
62 : std::shared_ptr<CcuRepFuncBlock> repFuncBlock{nullptr};
63 : std::shared_ptr<CcuRepBlock> curActiveBlock{nullptr};
64 :
65 : uint16_t callLayer{FUNC_CALL_LAYER_INVALID};
66 : };
67 :
68 : }; // namespace CcuRep
69 : }; // namespace Hccl
70 : #endif // HCCL_CCU_FUNC_BLOCK_H
|