• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 #ifndef TENSORFLOW_CORE_COMMON_RUNTIME_EAGER_EXECUTE_H_
16 #define TENSORFLOW_CORE_COMMON_RUNTIME_EAGER_EXECUTE_H_
17 
18 #include "tensorflow/core/common_runtime/device.h"
19 #include "tensorflow/core/common_runtime/eager/context.h"
20 #include "tensorflow/core/common_runtime/eager/eager_operation.h"
21 #include "tensorflow/core/common_runtime/eager/kernel_and_device.h"
22 #include "tensorflow/core/common_runtime/eager/tensor_handle.h"
23 #include "tensorflow/core/framework/step_stats.pb.h"
24 #include "tensorflow/core/lib/core/status.h"
25 #include "tensorflow/core/lib/gtl/inlined_vector.h"
26 
27 namespace tensorflow {
28 
29 // Utility function that executes a fully constructed EagerOperation.
30 // There are a few possible different combinations of how things can be
31 // executed:
32 //  - Async (the op context is configured to schedule asynchronously)
33 //    Eager execute should return quickly after scheduling this operation to
34 //    execute.
35 //  - Remote (the op device is on a remote task)
36 //    Eager execute will send an RPC to execute the op on a remote device.
37 //  Note that in the Async + Remote case, EagerExecute should still return
38 //  quickly, but it will schedule the op to be executed remotely.
39 Status EagerExecute(
40     EagerOperation* op,
41     tensorflow::gtl::InlinedVector<tensorflow::TensorHandle*, 2>* retvals,
42     int* num_retvals);
43 
44 // Low-level utility to execute the kernel specified by `kernel` on
45 // `kernel->device()`, with the inputs op_inputs, in the context 'ctx'.
46 Status EagerKernelExecute(EagerContext* ctx,
47                           const gtl::InlinedVector<TensorHandle*, 4>& op_inputs,
48                           KernelAndDevice* kernel, NodeExecStats* maybe_stats,
49                           StepStats* maybe_step_stats,
50                           GraphCollector* graph_collector,
51                           TensorHandle** retvals, int num_retvals);
52 
53 // Low-level utility to copy a tensor handle from one device to another.
54 Status EagerCopyToDevice(TensorHandle* h, EagerContext* ctx,
55                          const char* device_name, TensorHandle** result);
56 
57 }  // namespace tensorflow
58 
59 #endif  // TENSORFLOW_CORE_COMMON_RUNTIME_EAGER_EXECUTE_H_
60