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_OPERATOR
12 : #define HCCL_CCU_OPERATOR
13 :
14 : #include "exception_util.h"
15 : #include "ccu_api_exception.h"
16 :
17 : namespace Hccl {
18 : namespace CcuRep {
19 :
20 : template <typename lhsT, typename rhsT>
21 : class CcuOperator {
22 : public:
23 68 : CcuOperator(lhsT lhs, rhsT rhs) : lhs(lhs), rhs(rhs) {}
24 : lhsT lhs;
25 : rhsT rhs;
26 : };
27 :
28 : enum class CcuArithmeticOperatorType { ADDITION, INVALID };
29 :
30 : template <typename lhsT, typename rhsT>
31 : class CcuArithmeticOperator : public CcuOperator<lhsT, rhsT> {
32 : public:
33 10 : CcuArithmeticOperator(lhsT lhs, rhsT rhs, CcuArithmeticOperatorType type)
34 : : CcuOperator<lhsT, rhsT>(lhs, rhs),
35 10 : type(type)
36 : {
37 10 : Check();
38 10 : }
39 : void Check() const { THROW<CcuApiException>("Invalid Arithmetic Operator"); }
40 :
41 : CcuArithmeticOperatorType type{CcuArithmeticOperatorType::INVALID};
42 : };
43 :
44 : enum class CcuRelationalOperatorType { EQUAL, NOT_EQUAL, INVALID };
45 :
46 : template <typename lhsT, typename rhsT>
47 : class CcuRelationalOperator : public CcuOperator<lhsT, rhsT> {
48 : public:
49 58 : CcuRelationalOperator(lhsT lhs, rhsT rhs, CcuRelationalOperatorType type)
50 : : CcuOperator<lhsT, rhsT>(lhs, rhs),
51 58 : type(type)
52 : {
53 58 : Check();
54 58 : }
55 : void Check() const { THROW<CcuApiException>("Invalid Relational Operator"); }
56 :
57 : CcuRelationalOperatorType type{CcuRelationalOperatorType::INVALID};
58 : };
59 :
60 : }; // namespace CcuRep
61 : }; // namespace Hccl
62 :
63 : #endif // HCCL_CCU_OPERATOR
|