1 /** 2 * Copyright 2022 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 #ifndef MINDSPORE_CCSRC_RUNTIME_HARDWARE_DEVICE_TYPE_H_ 18 #define MINDSPORE_CCSRC_RUNTIME_HARDWARE_DEVICE_TYPE_H_ 19 20 #include <string> 21 #include <map> 22 #include "include/backend/visible.h" 23 24 namespace mindspore { 25 namespace device { 26 enum class RunMode { kUnknown, kKernelMode, kGraphMode }; 27 enum class DeviceType { kUnknown = 0, kCPU = 1, kAscend = 2, kGPU = 3 }; 28 const std::map<DeviceType, std::string> device_type_to_name_map = {{DeviceType::kUnknown, "Unknown"}, 29 {DeviceType::kAscend, "Ascend"}, 30 {DeviceType::kCPU, "CPU"}, 31 {DeviceType::kGPU, "GPU"}}; 32 33 const std::map<std::string, DeviceType> device_name_to_type_map = {{"Unknown", DeviceType::kUnknown}, 34 {"Ascend", DeviceType::kAscend}, 35 {"CPU", DeviceType::kCPU}, 36 {"GPU", DeviceType::kGPU}}; 37 38 BACKEND_EXPORT std::string GetDeviceNameByType(const DeviceType &type); 39 BACKEND_EXPORT DeviceType GetDeviceTypeByName(const std::string &name); 40 } // namespace device 41 } // namespace mindspore 42 #endif // MINDSPORE_CCSRC_RUNTIME_HARDWARE_DEVICE_TYPE_H_ 43