Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to call tf.compat.v1 from the C++ API? #48635

Open
Rabahjamal opened this issue Apr 20, 2021 · 1 comment
Open

How to call tf.compat.v1 from the C++ API? #48635

Rabahjamal opened this issue Apr 20, 2021 · 1 comment
Assignees
Labels
comp:apis Highlevel API related issues stat:awaiting tensorflower Status - Awaiting response from tensorflower TF 2.4 for issues related to TF 2.4 type:support Support issues

Comments

@Rabahjamal
Copy link

I have a frozen graph that was frozen in TensorFlow v1 from the python API, and I want to load it using TensorFlow v2.4 from the C++ API using something like tf.compat.v1 in python. I can do it in python with this script:

def wrap_frozen_graph(graph_def, inputs, outputs):
  def _imports_graph_def():
    tf.compat.v1.import_graph_def(graph_def, name="")
  wrapped_import = tf.compat.v1.wrap_function(_imports_graph_def, [])
  import_graph = wrapped_import.graph
  return wrapped_import.prune(
      tf.nest.map_structure(import_graph.as_graph_element, inputs),
      tf.nest.map_structure(import_graph.as_graph_element, outputs))


graph_def = tf.compat.v1.GraphDef()
loaded = graph_def.ParseFromString(open(path,'rb').read())


frozen_func = wrap_frozen_graph(graph_def=graph_def,
                                    inputs=["x:0"],
                                    outputs=["Identity:0", "Identity_1:0"])

But I didn't find any related document to do the same from the C++ API.

@Rabahjamal Rabahjamal added the type:others issues not falling in bug, perfromance, support, build and install or feature label Apr 20, 2021
@Rabahjamal Rabahjamal changed the title How to call tf.compat.v1from the C++ API? How to call tf.compat.v1 from the C++ API? Apr 20, 2021
@saikumarchalla saikumarchalla added TF 1.12 Issues related to TF 1.12 TF 2.4 for issues related to TF 2.4 comp:apis Highlevel API related issues type:support Support issues and removed type:others issues not falling in bug, perfromance, support, build and install or feature labels Apr 21, 2021
@amahendrakar amahendrakar removed the TF 1.12 Issues related to TF 1.12 label Apr 26, 2021
@jvishnuvardhan jvishnuvardhan added the stat:awaiting tensorflower Status - Awaiting response from tensorflower label Apr 26, 2021
@anishlukk123
Copy link

anishlukk123 commented Apr 17, 2023

is this a still a priortity?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:apis Highlevel API related issues stat:awaiting tensorflower Status - Awaiting response from tensorflower TF 2.4 for issues related to TF 2.4 type:support Support issues
Projects
None yet
Development

No branches or pull requests

5 participants