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.

device.h 1.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. #ifndef MINDSPORE_CCSRC_FRONTEND_PARALLEL_DEVICE_H_
  17. #define MINDSPORE_CCSRC_FRONTEND_PARALLEL_DEVICE_H_
  18. #include <cstdint>
  19. #include <string>
  20. #include <utility>
  21. #include "frontend/parallel/status.h"
  22. namespace mindspore {
  23. namespace parallel {
  24. class Device {
  25. // This class abstract the 'device' information, used in Parallel module.
  26. public:
  27. Device() : rank_(0) { name_.clear(); }
  28. explicit Device(int32_t rank) : rank_(rank) { name_.clear(); }
  29. Device(std::string name, int32_t rank) : name_(std::move(name)), rank_(rank) {}
  30. ~Device() = default;
  31. std::string name() const { return name_; }
  32. int32_t rank() const { return rank_; }
  33. private:
  34. std::string name_;
  35. int32_t rank_;
  36. };
  37. } // namespace parallel
  38. } // namespace mindspore
  39. #endif // MINDSPORE_CCSRC_FRONTEND_PARALLEL_DEVICE_H_