| 1867 | bool DoNothing(Graph* g) { return false; } |
| 1868 | |
| 1869 | GraphDef Optimize(const std::function<bool(Graph* g)>& pass, |
| 1870 | const FunctionDef& fdef) { |
| 1871 | InstantiationResult result; |
| 1872 | TF_CHECK_OK(InstantiateFunction(fdef, AttrSlice(), GetOpSig, &result)); |
| 1873 | std::unique_ptr<Graph> g(new Graph(OpRegistry::Global())); |
| 1874 | GraphConstructorOptions opts; |
| 1875 | opts.allow_internal_ops = true; |
| 1876 | opts.expect_device_spec = false; |
| 1877 | TF_CHECK_OK(ConvertNodeDefsToGraph(opts, result.nodes, g.get())); |
| 1878 | pass(g.get()); |
| 1879 | std::unique_ptr<Graph> g1(new Graph(OpRegistry::Global())); |
| 1880 | CopyGraph(*g, g1.get()); |
| 1881 | g = nullptr; |
| 1882 | GraphDef gdef; |
| 1883 | g1->ToGraphDef(&gdef); |
| 1884 | return gdef; |
| 1885 | } |
| 1886 | |
| 1887 | } // end namespace |
| 1888 |
no test coverage detected