apivovarov opened a new pull request, #13260: URL: https://github.com/apache/tvm/pull/13260
This PR Imports `graph_def` to default graph before calling `function_def_to_graph_def()`. It is needed for `function_def_to_graph_def(func, inshape)` which is called inside `from_tensorflow(graph_def)`. The `func` might have a reference(s) by name to another function(s) in the graph_def functions library. Internally `function_def_to_graph_def()` checks if another function is actually a function using [graph._is_function(fname)](https://github.com/tensorflow/tensorflow/blob/v2.9.0/tensorflow/python/framework/function_def_to_graph.py#L141) We need to import `graph_def` to the default context / graph before calling `function_def_to_graph_def()`. Otherwise we might face errors such as the following ``` File "/Users/pivovaa/miniconda3/lib/python3.8/site-packages/tensorflow/python/framework/function_def_to_graph.py", line 258, in function_def_to_graph_def raise ValueError(f"Function {fname} was not found. Please make sure " ValueError: Function __inference_map_while_Preprocessor_ResizeToRange_cond_true_18925_191476 was not found. Please make sure the FunctionDef `fdef` is correct. ``` ### Testing Tested on custom TF2 model compilation. After the fix the compilation works fine. The model has the following functions relationships btw functions in the functions library ``` func.signature.name:__inference_map_while_body_18879_191591 =============== node_def ==================== name: "map/while/Preprocessor/ResizeToRange/cond" op: "StatelessIf" input: "map/while/Preprocessor/ResizeToRange/Less:z:0" input: "map/while/Preprocessor/unstack:output:0" attr { key: "else_branch" value { func { name: "__inference_map_while_Preprocessor_ResizeToRange_cond_false_18926_190800" } } } attr { key: "then_branch" value { func { name: "__inference_map_while_Preprocessor_ResizeToRange_cond_true_18925_191476" } } } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
