• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2019 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 <memory>
17 #include <string>
18 
19 #include "abstract/param_validator.h"
20 #include "abstract/ops/infer_functions.h"
21 #include "abstract/abstract_value.h"
22 #include "abstract/dshape.h"
23 #include "base/base.h"
24 #include "ir/anf.h"
25 #include "ir/primitive.h"
26 #include "mindapi/base/shape_vector.h"
27 #include "utils/convert_utils_base.h"
28 #include "utils/log_adapter.h"
29 namespace mindspore {
30 namespace abstract {
InferImplDebug(const AnalysisEnginePtr &,const PrimitivePtr & primitive,const AbstractBasePtrList & args_abs_list)31 AbstractBasePtr InferImplDebug(const AnalysisEnginePtr &, const PrimitivePtr &primitive,
32                                const AbstractBasePtrList &args_abs_list) {
33   // Inputs: a tensor(value)
34   const std::string op_name = primitive->name();
35 
36   CheckArgsSize(op_name, args_abs_list, 1);
37   auto tensor_value = CheckArg<AbstractTensor>(op_name, args_abs_list, 0);
38 
39   int64_t tensor_rank = SizeToLong(tensor_value->shape()->shape().size());
40   if (tensor_rank == 0) {
41     MS_LOG(EXCEPTION) << op_name << " summary evaluator second arg should be an tensor, but got a scalar, rank is 0";
42   }
43 
44   return std::make_shared<AbstractTuple>(AbstractBasePtrList({tensor_value->Broaden()}));
45 }
46 }  // namespace abstract
47 }  // namespace mindspore
48