| 56 | } |
| 57 | |
| 58 | void UpdateEdge(TF_Graph* graph, TF_Output new_src, TF_Input dst, |
| 59 | TF_Status* status) { |
| 60 | mutex_lock l(graph->mu); |
| 61 | tensorflow::shape_inference::InferenceContext* ic = |
| 62 | graph->refiner.GetContext(&new_src.oper->node); |
| 63 | |
| 64 | if (ic->num_outputs() <= new_src.index) { |
| 65 | status->status = tensorflow::errors::OutOfRange( |
| 66 | "Cannot update edge. Output index [", new_src.index, |
| 67 | "] is greater than the number of total outputs [", ic->num_outputs(), |
| 68 | "]."); |
| 69 | return; |
| 70 | } |
| 71 | tensorflow::shape_inference::ShapeHandle shape = ic->output(new_src.index); |
| 72 | |
| 73 | tensorflow::shape_inference::InferenceContext* ic_dst = |
| 74 | graph->refiner.GetContext(&dst.oper->node); |
| 75 | if (ic_dst->num_inputs() <= dst.index) { |
| 76 | status->status = tensorflow::errors::OutOfRange( |
| 77 | "Cannot update edge. Input index [", dst.index, |
| 78 | "] is greater than the number of total inputs [", ic_dst->num_inputs(), |
| 79 | "]."); |
| 80 | return; |
| 81 | } |
| 82 | if (!ic_dst->MergeInput(dst.index, shape)) { |
| 83 | status->status = tensorflow::errors::InvalidArgument( |
| 84 | "Cannot update edge, incompatible shapes: ", ic_dst->DebugString(shape), |
| 85 | " and ", ic_dst->DebugString(ic_dst->input(dst.index)), "."); |
| 86 | return; |
| 87 | } |
| 88 | status->status = graph->graph.UpdateEdge(&new_src.oper->node, new_src.index, |
| 89 | &dst.oper->node, dst.index); |
| 90 | |
| 91 | if (TF_GetCode(status) == TF_OK) { |
| 92 | // This modification only updates the destination node for |
| 93 | // the purposes of running this graph in a session. Thus, we don't |
| 94 | // record the source node as being modified. |
| 95 | RecordMutation(graph, *dst.oper, "updating input tensor"); |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | void RemoveAllControlInputs(TF_Graph* graph, TF_Operation* op) { |
| 100 | mutex_lock l(graph->mu); |
no test coverage detected