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 { return label; }
24 :
25 : template <typename... Arguments>
26 51 : LoopCall& operator()(const Arguments&... args)
27 : {
28 51 : SetArgHelper(args...);
29 51 : AppendToContext();
30 51 : return *this;
31 : }
32 :
33 : LoopCall& operator()()
34 : {
35 : AppendToContext();
36 : return *this;
37 : }
38 :
39 : void AppendToContext();
40 :
41 : private:
42 : template <typename First>
43 51 : void SetArgHelper(const First& first)
44 : {
45 51 : repLoopCall->SetInArg(first);
46 51 : }
47 :
48 : template <typename First, typename... Rest>
49 105 : 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
|