tensorflow/core/grappler/optimizers/implementation_selector.cc
// Rewrites the device_index op to a const op with value of the index.
Rewrites the device_index op to a const op with value of the index.
Rewrites the device_index op to a const op with value of the index .
void RewriteDeviceIndexOp(utils::MutableNodeView* device_index_node,
                          int index) {
  auto node = device_index_node->node();
  node->set_op(kConstOp);
  EraseRegularNodeAttributes(node);
  (*node->mutable_attr())["dtype"].set_type(DT_INT32);
  auto* tensor = (*node->mutable_attr())["value"].mutable_tensor();
  tensor->set_dtype(DT_INT32);
  tensor->add_int_val(index);
  VLOG(2) << "Node after rewriting:" << node->DebugString();
}
void RewriteDeviceIndexOp ( utils :: MutableNodeView * device_index_node , int index ) { auto node = device_index_node -> node ( ) ; node -> set_op ( kConstOp ) ; EraseRegularNodeAttributes ( node ) ; ( * node -> mutable_attr ( ) ) [ " " ] . set_type ( DT_INT32 ) ; auto * tensor = ( * node -> mutable_attr ( ) ) [ " " ] . mutable_tensor ( ) ; tensor -> set_dtype ( DT_INT32 ) ; tensor -> add_int_val ( index ) ; VLOG ( 2 ) << " " << node -> DebugString ( ) ; }
Rewrites the device_index op to a const op with value of the index.
Rewrites the device_index op to a const op with value of the index .
// Modifies the DeviceIndex node to be an Const op with correct device index.