Line data Source code
1 : /**
2 : * Copyright (c) 2026 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 HCOMM_CCU_REPRESENTATION_ARG_H
12 : #define HCOMM_CCU_REPRESENTATION_ARG_H
13 :
14 : #include <vector>
15 : #include <memory>
16 :
17 : #include "ccu_datatype_v1.h"
18 :
19 : namespace hcomm {
20 : namespace CcuRep {
21 :
22 : enum class CcuArgType {
23 : VARIABLE,
24 : MEMORY,
25 : VARIABLE_LIST,
26 : MEMORY_LIST,
27 : LOCAL_ADDR, // 1. 新增枚举值
28 : LOCAL_ADDR_LIST, // 2. List 类型,以防后面需要 vector<LocalAddr>
29 : REMOTE_ADDR,
30 : REMOTE_ADDR_LIST,
31 : };
32 :
33 : struct CcuRepArg {
34 26 : explicit CcuRepArg(const Variable& var) : type(CcuArgType::VARIABLE), var(var) {}
35 2 : explicit CcuRepArg(const Memory& mem) : type(CcuArgType::MEMORY), mem(mem) {}
36 6 : explicit CcuRepArg(const std::vector<Variable>& varList) : type(CcuArgType::VARIABLE_LIST), varList(varList) {}
37 2 : explicit CcuRepArg(const std::vector<Memory>& memList) : type(CcuArgType::MEMORY_LIST), memList(memList) {}
38 : // 新增:LocalAddr 的构造函数
39 4 : explicit CcuRepArg(const LocalAddr& addr) : type(CcuArgType::LOCAL_ADDR), localAddr(addr) {}
40 : // 新增:LocalAddr 列表的构造函数
41 2 : explicit CcuRepArg(const std::vector<LocalAddr>& addrList)
42 2 : : type(CcuArgType::LOCAL_ADDR_LIST),
43 2 : localAddrList(addrList)
44 2 : {}
45 2 : explicit CcuRepArg(const RemoteAddr& addr) : type(CcuArgType::REMOTE_ADDR), remoteAddr(addr) {}
46 2 : explicit CcuRepArg(const std::vector<RemoteAddr>& addrList)
47 2 : : type(CcuArgType::REMOTE_ADDR_LIST),
48 2 : remoteAddrList(addrList)
49 2 : {}
50 :
51 : CcuArgType type;
52 : Variable var;
53 : Memory mem;
54 : std::vector<Variable> varList;
55 : std::vector<Memory> memList;
56 : LocalAddr localAddr; // 3. 新增成员变量来存储
57 : std::vector<LocalAddr> localAddrList; // 新增成员变量
58 : RemoteAddr remoteAddr;
59 : std::vector<RemoteAddr> remoteAddrList;
60 : };
61 :
62 : }; // namespace CcuRep
63 : }; // namespace hcomm
64 : #endif // HCOMM_CCU_REPRESENTATION_ARG_H
|