• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2019-2022 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 #include "backend/operator/ops_backend_infer_function.h"
17 #include "mindspore/core/ops/other_ops.h"
18 #include "mindspore/core/ops/nn_optimizer_ops.h"
19 #include "mindspore/core/ops/nn_ops.h"
20 #include "mindspore/core/ops/math_ops.h"
21 #include "mindspore/core/ops/lite_ops.h"
22 #include "mindspore/core/ops/image_ops.h"
23 #include "mindspore/core/ops/array_ops.h"
24 #include "abstract/ops/infer_functions.h"
25 #include "abstract/ops/primitive_infer_map.h"
26 namespace mindspore {
27 namespace abstract {
28 using R = PrimitiveEvalImplMap::mapped_type;
29 static PrimitiveEvalImplMap prim_backend_eval_implement_map{};
GetBackendPrimitiveInferMapPtr()30 PrimitiveEvalImplMap *GetBackendPrimitiveInferMapPtr() { return &prim_backend_eval_implement_map; }
GetBackendPrimitiveInferMap()31 const PrimitiveEvalImplMap &GetBackendPrimitiveInferMap() { return prim_backend_eval_implement_map; }
32 
GetBackendPrimitiveInferImpl(const PrimitivePtr & primitive)33 std::optional<StandardPrimitiveImplReg> GetBackendPrimitiveInferImpl(const PrimitivePtr &primitive) {
34   auto iter = GetBackendPrimitiveInferMap().find(primitive);
35   if (iter != GetBackendPrimitiveInferMap().end()) {
36     return iter->second;
37   }
38 
39   auto found = abstract::GetPrimitiveInferImpl(primitive);
40   if (found.has_value()) {
41     return found.value();
42   }
43   return std::optional<StandardPrimitiveImplReg>();
44 }
45 }  // namespace abstract
46 }  // namespace mindspore
47