| 57 | } |
| 58 | |
| 59 | Status RunOnce( |
| 60 | const RunOptions& run_options, |
| 61 | const std::vector<std::pair<string, Tensor>>& inputs, |
| 62 | const std::vector<string>& output_tensor_names, |
| 63 | const std::vector<string>& target_node_names, |
| 64 | std::vector<Tensor>* outputs, RunMetadata* run_metadata, |
| 65 | Session* session) { |
| 66 | CallableOptions callable_options; |
| 67 | std::vector<Tensor> feed_tensors; |
| 68 | *callable_options.mutable_run_options() = run_options; |
| 69 | for (const auto& input : inputs) { |
| 70 | const string& name = input.first; |
| 71 | const Tensor& tensor = input.second; |
| 72 | callable_options.add_feed(name); |
| 73 | feed_tensors.push_back(tensor); |
| 74 | } |
| 75 | for (const string& output_tensor_name : output_tensor_names) { |
| 76 | callable_options.add_fetch(output_tensor_name); |
| 77 | } |
| 78 | for (const string& target_node_name : target_node_names) { |
| 79 | callable_options.add_target(target_node_name); |
| 80 | } |
| 81 | |
| 82 | Session::CallableHandle callable_handle; |
| 83 | TF_RETURN_IF_ERROR(session->MakeCallable(callable_options, &callable_handle)); |
| 84 | |
| 85 | const Status run_status = session->RunCallable(callable_handle, feed_tensors, |
| 86 | outputs, run_metadata); |
| 87 | // Be sure to call ReleaseCallable() regardless of the outcome of |
| 88 | // RunCallable(). |
| 89 | session->ReleaseCallable(callable_handle).IgnoreError(); |
| 90 | |
| 91 | return run_status; |
| 92 | } |
| 93 | |
| 94 | Status RunOnce( |
| 95 | const RunOptions& run_options, |
no test coverage detected