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 #include "tensorflow/compiler/mlir/tensorflow/ir/tf_structs.cc.inc" 19 20 namespace mlir { 21 namespace TF { 22 AddDevice(const ParsedName & device)23void RuntimeDevices::AddDevice(const ParsedName& device) { 24 device_names_.push_back(device); 25 } 26 AddGpuDevice(const ParsedName & device,const GpuDeviceMetadata & metadata)27void RuntimeDevices::AddGpuDevice(const ParsedName& device, 28 const GpuDeviceMetadata& metadata) { 29 device_names_.push_back(device); 30 gpu_metadata_.insert({DeviceNameUtils::ParsedNameToString(device), metadata}); 31 } 32 GetGpuDeviceMetadata(const ParsedName & device) const33llvm::Optional<GpuDeviceMetadata> RuntimeDevices::GetGpuDeviceMetadata( 34 const ParsedName& device) const { 35 auto it = gpu_metadata_.find(DeviceNameUtils::ParsedNameToString(device)); 36 if (it != gpu_metadata_.end()) { 37 return it->second; 38 } else { 39 return llvm::None; 40 } 41 } 42 43 } // namespace TF 44 } // namespace mlir 45