tensorflow/core/grappler/optimizers/implementation_selector.cc
// Finds the index of the device from the device name list.
Finds the index of the device from the device name list.
Finds the index of the device from the device name list .
Status FindDeviceIndex(const utils::MutableNodeView* device_index_node,
                       const string& device, int* index) {
  DeviceNameUtils::ParsedName parsed_name;
  if (!DeviceNameUtils::ParseFullName(device, &parsed_name) ||
      !parsed_name.has_type) {
    return errors::Internal("Could not parse device name:", device);
  }
  const auto& device_list =
      device_index_node->GetAttr("device_names")->list().s();
  auto it = absl::c_find(device_list, parsed_name.type);
  if (it != device_list.end()) {
    *index = it - device_list.begin();
  } else {
    *index = device_list.size();
  }
  return Status::OK();
}
Status FindDeviceIndex ( const utils :: MutableNodeView * device_index_node , const string & device , int * index ) { DeviceNameUtils :: ParsedName parsed_name ; if ( ! DeviceNameUtils :: ParseFullName ( device , & parsed_name ) || ! parsed_name . has_type ) { return errors :: Internal ( " " , device ) ; } const auto & device_list = device_index_node -> GetAttr ( " " ) -> list ( ) . s ( ) ; auto it = absl :: c_find ( device_list , parsed_name . type ) ; if ( it != device_list . end ( ) ) { * index = it - device_list . begin ( ) ; } else { * index = device_list . size ( ) ; } return Status :: OK ( ) ; }
Finds the index of the device from the device name list.
Finds the index of the device from the device name list .
// Sets *index to device_list.size() because the default_fn is guaranteed to // be the final item in the case op branching list.