| 2193 | } |
| 2194 | |
| 2195 | int MklLayoutRewritePass::SetUpContiguousInputs( |
| 2196 | std::unique_ptr<Graph>* g, |
| 2197 | const gtl::InlinedVector<std::pair<Node*, int>, 4>& old_node_inputs, |
| 2198 | NodeBuilder* nb, const Node* old_node, |
| 2199 | std::vector<NodeBuilder::NodeOut>* workspace_tensors, |
| 2200 | bool are_workspace_tensors_available) { |
| 2201 | CHECK_NOTNULL(workspace_tensors); |
| 2202 | CHECK_EQ(kTensorOrdering, MklTfTensorOrdering::TENSORS_CONTIGUOUS); |
| 2203 | |
| 2204 | // TODO(nhasabni): Temporary solution to connect filter input of |
| 2205 | // BackpropInput with the converted filter from Conv2D. |
| 2206 | bool do_connect_conv2d_backprop_input_filter = false; |
| 2207 | Node* conv2d_node = nullptr; |
| 2208 | // Filter node is 2nd input (slot index 1) of Conv2D. |
| 2209 | int kConv2DFilterInputSlotIdx = 1; |
| 2210 | int kConv2DBackpropInputFilterInputSlotIdx = 1; |
| 2211 | int kConv2DFilterOutputSlotIdx = 1; |
| 2212 | if (old_node->type_string() == csinfo_.conv2d_grad_input) { |
| 2213 | // We need to find Conv2D node from Conv2DBackpropInput. |
| 2214 | // For that let's first find filter node that is 2nd input (slot 1) |
| 2215 | // of BackpropInput. |
| 2216 | Node* filter_node = nullptr; |
| 2217 | TF_CHECK_OK(old_node->input_node(kConv2DBackpropInputFilterInputSlotIdx, |
| 2218 | &filter_node)); |
| 2219 | CHECK_NOTNULL(filter_node); |
| 2220 | |
| 2221 | // Now check which nodes receive from filter_node. Filter feeds as |
| 2222 | // 2nd input (slot 1) of _MklConv2D, _MklConv2DWithBias, and |
| 2223 | // _MklFusedConv2D. |
| 2224 | for (const Edge* e : filter_node->out_edges()) { |
| 2225 | if ((e->dst()->type_string() == csinfo_.mkl_conv2d || |
| 2226 | e->dst()->type_string() == csinfo_.mkl_pad_with_conv2d || |
| 2227 | e->dst()->type_string() == csinfo_.mkl_pad_with_fused_conv2d || |
| 2228 | e->dst()->type_string() == csinfo_.mkl_conv2d_with_bias || |
| 2229 | e->dst()->type_string() == csinfo_.mkl_fused_conv2d) && |
| 2230 | e->dst_input() == kConv2DFilterInputSlotIdx |
| 2231 | /* filter is 2nd input of Conv2D and _MklConv2D. */) { |
| 2232 | if (conv2d_node != nullptr) { |
| 2233 | VLOG(1) << "MklLayoutRewritePass: unusual case of same filter" |
| 2234 | << " feeding multiple Conv2D nodes: " |
| 2235 | << filter_node->DebugString(); |
| 2236 | // We will not connect filter input of Conv2DBackpropInput |
| 2237 | // to be safe here. |
| 2238 | do_connect_conv2d_backprop_input_filter = false; |
| 2239 | break; |
| 2240 | } else { |
| 2241 | conv2d_node = e->dst(); |
| 2242 | do_connect_conv2d_backprop_input_filter = true; |
| 2243 | } |
| 2244 | } |
| 2245 | } |
| 2246 | } |
| 2247 | |
| 2248 | // Number of input slots to original op |
| 2249 | // Input slots are represented by .Input() calls in REGISTER_OP. |
| 2250 | int old_node_input_slots = old_node->op_def().input_arg_size(); |
| 2251 | int nn_slot_idx = 0; // slot index for inputs of new node |
| 2252 |
nothing calls this directly
no test coverage detected