• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2015 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 
16 #include "tensorflow/stream_executor/stream_executor_internal.h"
17 
18 namespace stream_executor {
19 namespace internal {
20 
21 // -- CUDA
22 
MakeCUDAExecutorImplementation()23 StreamExecutorFactory* MakeCUDAExecutorImplementation() {
24   static StreamExecutorFactory instance;
25   return &instance;
26 }
27 
28 // -- ROCm
29 
MakeROCMExecutorImplementation()30 StreamExecutorFactory* MakeROCMExecutorImplementation() {
31   static StreamExecutorFactory instance;
32   return &instance;
33 }
34 
35 // -- OpenCL
36 
MakeOpenCLExecutorImplementation()37 StreamExecutorFactory* MakeOpenCLExecutorImplementation() {
38   static StreamExecutorFactory instance;
39   return &instance;
40 }
41 
42 // -- Host
43 
44 StreamExecutorFactory MakeHostExecutorImplementation;
45 
46 // The default implementation just calls the other HostCallback method.
47 // It should make all existing code that uses a void() callback still work.
HostCallback(Stream * stream,std::function<void ()> callback)48 bool StreamExecutorInterface::HostCallback(Stream* stream,
49                                            std::function<void()> callback) {
50   return HostCallback(
51       stream, std::function<port::Status()>([callback]() -> port::Status {
52         callback();
53         return port::Status::OK();
54       }));
55 }
56 
57 }  // namespace internal
58 }  // namespace stream_executor
59