diff options
author | 2018-06-09 10:39:16 -0700 | |
---|---|---|
committer | 2018-06-09 10:41:54 -0700 | |
commit | 119db15241e29587e0b6ab3912bff5ff63d123eb (patch) | |
tree | ec75f6f45b0eea6a96ad4765f35b20fb583ea83a /tensorflow/core/common_runtime/kernel_benchmark_testlib.cc | |
parent | 898f9664488f0036ccc02bbb34379cb613f07a55 (diff) |
Add a registration mechanism for experimental executor implementations.
Also add an option to the FunctionLibraryRuntime's `InstantiateOptions` that
enables users to select a particular executor implementation when instantiating
a function.
PiperOrigin-RevId: 199920648
Diffstat (limited to 'tensorflow/core/common_runtime/kernel_benchmark_testlib.cc')
-rw-r--r-- | tensorflow/core/common_runtime/kernel_benchmark_testlib.cc | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/tensorflow/core/common_runtime/kernel_benchmark_testlib.cc b/tensorflow/core/common_runtime/kernel_benchmark_testlib.cc index 7de1b80e2d..1f585a8c24 100644 --- a/tensorflow/core/common_runtime/kernel_benchmark_testlib.cc +++ b/tensorflow/core/common_runtime/kernel_benchmark_testlib.cc @@ -18,6 +18,7 @@ limitations under the License. #include <vector> #include "tensorflow/core/common_runtime/device.h" #include "tensorflow/core/common_runtime/device_factory.h" +#include "tensorflow/core/common_runtime/executor_factory.h" #include "tensorflow/core/common_runtime/local_device.h" #include "tensorflow/core/framework/op.h" #include "tensorflow/core/framework/op_kernel.h" @@ -43,7 +44,7 @@ namespace test { // TODO(hongm): Convert `g` and `init` to using std::unique_ptr. Benchmark::Benchmark(const string& device, Graph* g, const SessionOptions* options, Graph* init, - Rendezvous* rendez) { + Rendezvous* rendez, const char* executor_type) { SessionOptions default_options; if (!options) { options = &default_options; @@ -86,23 +87,26 @@ Benchmark::Benchmark(const string& device, Graph* g, }; if (init) { - Executor* init_exec; - TF_CHECK_OK( - NewLocalExecutor(params, std::unique_ptr<Graph>(init), &init_exec)); + std::unique_ptr<Executor> init_exec; + TF_CHECK_OK(NewExecutor(executor_type, params, std::unique_ptr<Graph>(init), + &init_exec)); Executor::Args args; args.rendezvous = rendez_; args.runner = runner; TF_CHECK_OK(init_exec->Run(args)); - delete init_exec; } - TF_CHECK_OK(NewLocalExecutor(params, std::unique_ptr<Graph>(g), &exec_)); + TF_CHECK_OK( + NewExecutor(executor_type, params, std::unique_ptr<Graph>(g), &exec_)); } Benchmark::~Benchmark() { if (device_) { rendez_->Unref(); - delete exec_; + // We delete `exec_` before `device_` because the `exec_` destructor may + // run kernel destructors that may attempt to access state borrowed from + // `device_`, such as the resource manager. + exec_.reset(); delete device_; delete pool_; } |