Copies `src_graph` into `dst_graph`. Any node in `src_graph` with input `src_inputs[i]` will have that input replaced with `dst_inputs[i]`. `prefix` will be prepended to copied node names. `control_deps` are nodes in `dst_graph` that the copied `src_graph` nodes will have control dependencies on. `return_nodes` are nodes in `src_graph`, and the new corresponding nodes in `dst_graph` will be retur
| 1825 | // on. `return_nodes` are nodes in `src_graph`, and the new corresponding nodes |
| 1826 | // in `dst_graph` will be returned. `return_nodes` must be non-null. |
| 1827 | Status CopyGraph(Graph* src_graph, Graph* dst_graph, |
| 1828 | tensorflow::ShapeRefiner* dst_refiner, |
| 1829 | const TF_Output* src_inputs, |
| 1830 | const std::vector<tensorflow::Output>& dst_inputs, |
| 1831 | const string& prefix, |
| 1832 | const std::vector<tensorflow::Operation>& control_deps, |
| 1833 | const TF_Output* nodes_to_return, int nreturn_nodes, |
| 1834 | std::vector<tensorflow::Output>* return_nodes) { |
| 1835 | DCHECK(return_nodes != nullptr); |
| 1836 | GraphDef gdef; |
| 1837 | src_graph->ToGraphDef(&gdef); |
| 1838 | |
| 1839 | tensorflow::ImportGraphDefOptions opts; |
| 1840 | opts.prefix = prefix; |
| 1841 | |
| 1842 | for (int i = 0; i < dst_inputs.size(); ++i) { |
| 1843 | opts.input_map[ToTensorId(src_inputs[i])] = |
| 1844 | TensorId(dst_inputs[i].node()->name(), dst_inputs[i].index()); |
| 1845 | } |
| 1846 | opts.skip_mapped_nodes = true; |
| 1847 | |
| 1848 | for (const tensorflow::Operation& op : control_deps) { |
| 1849 | opts.control_dependencies.push_back(op.node()->name()); |
| 1850 | } |
| 1851 | |
| 1852 | for (int i = 0; i < nreturn_nodes; ++i) { |
| 1853 | opts.return_tensors.push_back(ToTensorId(nodes_to_return[i])); |
| 1854 | } |
| 1855 | |
| 1856 | // TODO(skyewm): change to OutputTensor |
| 1857 | tensorflow::ImportGraphDefResults results; |
| 1858 | TF_RETURN_IF_ERROR( |
| 1859 | ImportGraphDef(opts, gdef, dst_graph, dst_refiner, &results)); |
| 1860 | |
| 1861 | for (const auto& pair : results.return_tensors) { |
| 1862 | return_nodes->emplace_back(pair.first, pair.second); |
| 1863 | } |
| 1864 | return Status::OK(); |
| 1865 | } |
| 1866 | |
| 1867 | bool ValidateConstWhileParams(const TF_WhileParams& params, TF_Status* s) { |
| 1868 | if (params.cond_graph == nullptr || params.body_graph == nullptr || |
no test coverage detected