You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

less.cc 1.9 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * Copyright 2020 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 <map>
  17. #include <string>
  18. #include "ops/less.h"
  19. #include "ops/op_utils.h"
  20. #include "utils/check_convert_utils.h"
  21. #include "abstract/primitive_infer_map.h"
  22. namespace mindspore {
  23. namespace ops {
  24. namespace {
  25. abstract::ShapePtr InferShape(const PrimitivePtr &primitive, const std::vector<AbstractBasePtr> &input_args) {
  26. MS_EXCEPTION_IF_NULL(primitive);
  27. auto op_name = primitive->name();
  28. return BroadCastInferShape(op_name, input_args);
  29. }
  30. TypePtr InferType(const PrimitivePtr &prim, const std::vector<AbstractBasePtr> &input_args) {
  31. for (const auto &item : input_args) {
  32. MS_EXCEPTION_IF_NULL(item);
  33. }
  34. std::map<std::string, TypePtr> types;
  35. types.emplace("x", input_args[0]->BuildType());
  36. types.emplace("y", input_args[1]->BuildType());
  37. CheckAndConvertUtils::CheckTensorTypeSame(types, common_valid_types, prim->name());
  38. return kBool;
  39. }
  40. } // namespace
  41. AbstractBasePtr LessInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive,
  42. const std::vector<AbstractBasePtr> &input_args) {
  43. return std::make_shared<abstract::AbstractTensor>(InferType(primitive, input_args),
  44. InferShape(primitive, input_args)->shape());
  45. }
  46. REGISTER_PRIMITIVE_C(kNameLess, Less);
  47. } // namespace ops
  48. } // namespace mindspore