tensorflow/compiler/mlir/tensorflow/ir/tf_ops.cc
bool CanUseGpuDevice(Operation *op) {
  auto device_attr = op->getAttrOfType<StringAttr>("device");
  if (!device_attr || device_attr.getValue().empty()) return true;

  DeviceNameUtils::ParsedName device;
  if (!DeviceNameUtils::ParseFullName(device_attr.getValue().str(), &device))
    return false;

  // We can't use GPU if operation explicitly placed on non-GPU device.
  return !device.has_type || device.type == ::tensorflow::DEVICE_GPU;
}
// Returns true if operation does not have explicit device placement that would
// prevent it from running on GPU device.
Returns true if operation does not have explicit device placement that would
prevent it from running on GPU device.
Returns true if operation does not have explicit device placement that would prevent it from running on GPU device .
bool CanUseGpuDevice(Operation *op) {
  auto device_attr = op->getAttrOfType<StringAttr>("device");
  if (!device_attr || device_attr.getValue().empty()) return true;
  DeviceNameUtils::ParsedName device;
  if (!DeviceNameUtils::ParseFullName(device_attr.getValue().str(), &device))
    return false;
  return !device.has_type || device.type == ::tensorflow::DEVICE_GPU;
}
bool CanUseGpuDevice ( Operation * op ) { auto device_attr = op -> getAttrOfType < StringAttr > ( " " ) ; if ( ! device_attr || device_attr . getValue ( ) . empty ( ) ) return true ; DeviceNameUtils :: ParsedName device ; if ( ! DeviceNameUtils :: ParseFullName ( device_attr . getValue ( ) . str ( ) , & device ) ) return false ; return ! device . has_type || device . type == :: tensorflow :: DEVICE_GPU ; }
Returns true if operation does not have explicit device placement that would
prevent it from running on GPU device.
Returns true if operation does not have explicit device placement that would prevent it from running on GPU device .
// We can't use GPU if operation explicitly placed on non-GPU device.