• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020-2021 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 
17 #include "ops/not_equal.h"
18 #include <map>
19 #include <string>
20 #include <vector>
21 #include <algorithm>
22 #include <memory>
23 #include "ops/op_utils.h"
24 #include "utils/check_convert_utils.h"
25 #include "abstract/primitive_infer_map.h"
26 
27 namespace mindspore {
28 namespace ops {
29 namespace {
InferType(const PrimitivePtr & prim,const std::vector<AbstractBasePtr> & input_args)30 TypePtr InferType(const PrimitivePtr &prim, const std::vector<AbstractBasePtr> &input_args) {
31   auto op_name = prim->name();
32   std::map<std::string, TypePtr> types;
33   (void)types.emplace("x", input_args[0]->BuildType());
34   (void)types.emplace("y", input_args[1]->BuildType());
35   return CheckAndConvertUtils::CheckTensorTypeSame(types, common_valid_types, op_name);
36 }
37 }  // namespace
38 
NotEqualInfer(const abstract::AnalysisEnginePtr &,const PrimitivePtr & primitive,const std::vector<AbstractBasePtr> & input_args)39 AbstractBasePtr NotEqualInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive,
40                               const std::vector<AbstractBasePtr> &input_args) {
41   MS_EXCEPTION_IF_NULL(primitive);
42   auto op_name = primitive->name();
43   const int64_t input_num = 2;
44   (void)CheckAndConvertUtils::CheckInteger("input number", SizeToLong(input_args.size()), kEqual, input_num, op_name);
45   for (const auto &item : input_args) {
46     MS_EXCEPTION_IF_NULL(item);
47   }
48   (void)InferType(primitive, input_args);
49   return abstract::MakeAbstract(BroadCastInferShape(op_name, input_args), kBool);
50 }
51 REGISTER_PRIMITIVE_C(kNameNotEqual, NotEqual);
52 }  // namespace ops
53 }  // namespace mindspore
54