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_CALL_H
12 : #define HCCL_CCU_LOOP_CALL_H
13 :
14 : #include "ccu_rep_loopcall.h"
15 : #include "ccu_rep_context.h"
16 :
17 : namespace Hccl {
18 : namespace CcuRep {
19 :
20 : class LoopCall {
21 : public:
22 : LoopCall(CcuRepContext *context, const std::string &label);
23 51 : const std::string &GetLabel() const
24 : {
25 51 : return label;
26 : }
27 :
28 51 : template <typename... Arguments> LoopCall &operator()(const Arguments &...args)
29 : {
30 51 : SetArgHelper(args...);
31 51 : AppendToContext();
32 51 : return *this;
33 : }
34 :
35 : LoopCall &operator()()
36 : {
37 : AppendToContext();
38 : return *this;
39 : }
40 :
41 : void AppendToContext();
42 :
43 : private:
44 51 : template <typename First> void SetArgHelper(const First &first)
45 : {
46 51 : repLoopCall->SetInArg(first);
47 51 : }
48 :
49 105 : template <typename First, typename... Rest> void SetArgHelper(const First &first, const Rest &...rest)
50 : {
51 105 : repLoopCall->SetInArg(first);
52 105 : SetArgHelper(rest...);
53 105 : }
54 :
55 : CcuRepContext *context{nullptr};
56 : std::string label;
57 :
58 : std::shared_ptr<CcuRepLoopCall> repLoopCall{nullptr};
59 : };
60 :
61 : }; // namespace CcuRep
62 : }; // namespace Hccl
63 : #endif // HCCL_CCU_LOOP_CALL_H
|