• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2023 Huawei Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef MINDSPORE_CORE_OPS_SYMBOL_OPS_IMPL_COMMON_H_
17 #define MINDSPORE_CORE_OPS_SYMBOL_OPS_IMPL_COMMON_H_
18 #include <algorithm>
19 #include <memory>
20 #include <vector>
21 #include <string>
22 #include <utility>
23 
24 #include "mindspore/core/symbolic_shape/symbol.h"
25 #include "mindspore/core/symbolic_shape/utils.h"
26 #include "mindspore/core/symbolic_shape/operation.h"
27 #include "mindspore/core/symbolic_shape/operation_builder.h"
28 
29 namespace mindspore {
30 namespace symshape {
31 namespace ops {
32 class MS_CORE_API InferShapeOp : public Operation {
33  public:
34   using Operation::Operation;
35   ~InferShapeOp() override = default;
36   MS_DECLARE_PARENT(InferShapeOp, Operation)
37   static void SetPositive(const ListSymbol *list);
38 
39  protected:
UpdateMathInfo()40   void UpdateMathInfo() override { SetPositive(output_as<ListSymbol>()); }
41 };
42 
43 class MS_CORE_API InferValueOp : public Operation {
44  public:
45   using Operation::Operation;
46   ~InferValueOp() override = default;
47   MS_DECLARE_PARENT(InferValueOp, Operation)
48 };
49 
50 class MS_CORE_API ScalarIntOp : public InferValueOp {
51  public:
52   using InferValueOp::InferValueOp;
53   MS_DECLARE_PARENT(ScalarIntOp, InferValueOp)
54 };
55 
56 /// \brief Set input value to output shape symbol.
57 ///
58 /// \note This function will set the input value symbol to positive.
59 SymbolPtr TransValueToShape(OperationBuilder *b);
60 
61 /// \brief accumulate int symbols, only support ScalarAdd or ScalarMul
62 template <typename OP>
63 SymbolPtr Accumulate(const SymbolPtrList &symbols, const OperationEmitter &e);
64 }  // namespace ops
65 }  // namespace symshape
66 }  // namespace mindspore
67 #endif  // MINDSPORE_CORE_OPS_SYMBOL_OPS_IMPL_COMMON_H_
68