1 /* Copyright 2020 The TensorFlow Authors. All Rights Reserved. 2 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 ==============================================================================*/ 15 16 #include "tensorflow/compiler/mlir/tensorflow/ir/tf_structs.h" 17 18 namespace mlir { 19 namespace TF { 20 AddDevice(const ParsedName & device)21void RuntimeDevices::AddDevice(const ParsedName& device) { 22 device_names_.push_back(device); 23 } 24 AddGpuDevice(const ParsedName & device,const GpuDeviceMetadata & metadata)25void RuntimeDevices::AddGpuDevice(const ParsedName& device, 26 const GpuDeviceMetadata& metadata) { 27 device_names_.push_back(device); 28 gpu_metadata_.insert({DeviceNameUtils::ParsedNameToString(device), metadata}); 29 } 30 GetGpuDeviceMetadata(const ParsedName & device) const31llvm::Optional<GpuDeviceMetadata> RuntimeDevices::GetGpuDeviceMetadata( 32 const ParsedName& device) const { 33 auto it = gpu_metadata_.find(DeviceNameUtils::ParsedNameToString(device)); 34 if (it != gpu_metadata_.end()) { 35 return it->second; 36 } else { 37 return llvm::None; 38 } 39 } 40 41 } // namespace TF 42 } // namespace mlir 43