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.

split.cc 1.7 kB

5 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 "ops/split.h"
  17. #include "ops/op_utils.h"
  18. #include "utils/check_convert_utils.h"
  19. #include "abstract/primitive_infer_map.h"
  20. namespace mindspore {
  21. namespace ops {
  22. void Split::Init(const std::vector<int64_t> &size_splits, const int64_t axis, const int64_t output_num) {
  23. this->set_axis(axis);
  24. this->set_output_num(output_num);
  25. }
  26. void Split::set_size_splits(const std::vector<int64_t> &size_splits) {
  27. this->AddAttr(kSizeSplits, MakeValue(size_splits));
  28. }
  29. void Split::set_axis(const int64_t axis) { this->AddAttr(kAxis, MakeValue(axis)); }
  30. void Split::set_output_num(const int64_t output_num) { this->AddAttr(kOutputNum, MakeValue(output_num)); }
  31. std::vector<int64_t> Split::get_size_splits() const {
  32. auto value_ptr = GetAttr(kSizeSplits);
  33. return GetValue<std::vector<int64_t>>(value_ptr);
  34. }
  35. int64_t Split::get_axis() const {
  36. auto value_ptr = GetAttr(kAxis);
  37. return GetValue<int64_t>(value_ptr);
  38. }
  39. int64_t Split::get_output_num() const {
  40. auto value_ptr = GetAttr(kOutputNum);
  41. return GetValue<int64_t>(value_ptr);
  42. }
  43. REGISTER_PRIMITIVE_C(kNameSplit, Split);
  44. } // namespace ops
  45. } // namespace mindspore