message: Disable PinToHostOptimizer for any TPU graphs.
diff: @@ -157,6 +157,16 @@ string TryFindHostDevice(const gtl::FlatSet<string>& devices,
  return device;
  }
  +bool IsTPUGraphDef(const GraphDef& def) {
  + for (auto node : def.node()) {
  + if (node.op() == "TPUCompile" || node.op() == "TPUExecute" ||
  + node.op() == "TPUPartitionedCall") {
  + return true;
  + }
  + }
  + return false;
  +}
  +
  // All the nodes that should be blacklisted and not swapped.
  bool IsBlacklisted(const NodeDef& node) { return IsCollective(node); }
  } // end namespace internal
  @@ -165,6 +175,11 @@ Status PinToHostOptimizer::Optimize(Cluster* cluster, const GrapplerItem& item,
  GraphDef* optimized_graph) {
  *optimized_graph = item.graph;
  + // Skip all TPU graphs.
  + if (internal::IsTPUGraphDef(*optimized_graph)) {
  + return Status::OK();
  + }
  +
  GraphProperties properties(item);
  bool has_properties = false;
  GraphView graph(optimized_graph);
  