I am attempting to assign a value to a variable in a Tensorflow graph loaded using the C API. When I export a graph using Tensorflow 2.x it contains the following ops related to a particular variable:
variable_name type: VarHandleOp device: number inputs: 0 number outputs: 1
Number inputs: 0
Number outputs: 1
dims: 0 []
variable_name/Read/ReadVariableOp type: ReadVariableOp device: number inputs: 1 number outputs: 1
Number inputs: 1
Number outputs: 1
dims: 0 []
According to this video (https://www.youtube.com/watch?v=uaRO0AV6Tto) variables in TF 2.x now use VarHandleOps in order to mediate write access to them. The TF test suite for the C API is the only example I've found so far of using a VarHandleOp to access a variable but it is created from scratch using the Eager API (https://github.com/OAID/TensorFlow-HRT/blob/master/tensorflow/c/eager/c_api_test.cc#L409).
I would like to be able to load a graph and assign to a variable already contained within it, is this even possible with the Eager API? When I try using the older graph API I can fetch the VarHandleOp like so:
TF_Operation* op = TF_GraphOperationByName(graph, "variable_name");
But then I can't figure out how to run this op to return a TFE_TensorHandle (like here https://github.com/OAID/TensorFlow-HRT/blob/master/tensorflow/c/eager/c_api_test.cc#L418), a type which doesn't even seem to exist in the graph API. TF_SessionRun()'s inputs and outputs deal in TF_Output and TFE_Execute expects a TFE_Op rather than the TF_Operation I have access to.
Any tips or pointers gratefully received!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…