TODO(phawkins): replace with C++ API for calling functions, when that exists.
| 113 | |
| 114 | // TODO(phawkins): replace with C++ API for calling functions, when that exists. |
| 115 | Output Call(Scope* scope, const string& op_name, const string& fn_name, |
| 116 | gtl::ArraySlice<Input> inputs) { |
| 117 | NodeDef def; |
| 118 | NodeDefBuilder builder(op_name, fn_name, scope->graph()->op_registry()); |
| 119 | for (const Input& input : inputs) { |
| 120 | builder.Input(input.node()->name(), input.index(), |
| 121 | input.node()->output_type(input.index())); |
| 122 | } |
| 123 | TF_CHECK_OK(builder.Finalize(&def)); |
| 124 | Status status; |
| 125 | Node* n = scope->graph()->AddNode(def, &status); |
| 126 | TF_CHECK_OK(status); |
| 127 | TF_CHECK_OK(scope->DoShapeInference(n)); |
| 128 | for (int i = 0; i < inputs.size(); ++i) { |
| 129 | scope->graph()->AddEdge(inputs[i].node(), inputs[i].index(), n, i); |
| 130 | } |
| 131 | return Output(n); |
| 132 | } |
| 133 | |
| 134 | } // namespace function |
| 135 | } // namespace test |
no test coverage detected