• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2021 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 // For Google-internal use only.
17 
18 #ifndef TENSORFLOW_CORE_UTIL_AUTOTUNE_MAPS_DEVICE_IDENTIFIER_UTILS_H_
19 #define TENSORFLOW_CORE_UTIL_AUTOTUNE_MAPS_DEVICE_IDENTIFIER_UTILS_H_
20 
21 #include <string>
22 #include <vector>
23 
24 #include "tensorflow/core/platform/protobuf.h"
25 namespace tensorflow {
26 namespace autotune_maps_utils {
27 
28 #if GOOGLE_CUDA || TENSORFLOW_USE_ROCM
29 // Given a device_id, this function computes an identifier string that
30 // represents the corresponding GPU device type. Currently the identifier is
31 // computed as
32 // "<device_name> <compute_compatibility> <GPU_memory> <multiprocessor_count>".
33 // We cannot simply use <device_name> output by GetDeviceName here because for
34 // some GPUs the it will output uninformative names like "Graphics Device",
35 // which cannot identify device types of GPUs.
36 // TODO(ruochengw): Replace the identifier with something that uniquely
37 // determines a GPU device type, e.g. PCI device ID.
38 std::string DeviceIdToIdentifier(int device_id);
39 
40 // Precomputes a map storing the results of DeviceIdToIdentifierHelper for all
41 // device_ids available and outputs "Unknown Graphics Device" when
42 // DeviceIdToIdentifierHelper returns an error.
43 std::vector<std::string> GetDeviceIdToIdentifierMap();
44 
45 #endif  // GOOGLE_CUDA || TENSORFLOW_USE_ROCM
46 std::string SerializeProtoDeterministic(const protobuf::Message& proto);
47 
48 uint64_t HashProto(const protobuf::Message& proto);
49 
50 }  // namespace autotune_maps_utils
51 }  // namespace tensorflow
52 
53 #endif  // TENSORFLOW_CORE_UTIL_AUTOTUNE_MAPS_DEVICE_IDENTIFIER_UTILS_H_
54