Home | History | Annotate | Download | only in interpreter
      1 /* Copyright 2017 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_COMPILER_XLA_SERVICE_INTERPRETER_PLATFORM_H_
     16 #define TENSORFLOW_COMPILER_XLA_SERVICE_INTERPRETER_PLATFORM_H_
     17 
     18 #include <memory>
     19 #include <string>
     20 
     21 #include "tensorflow/stream_executor/executor_cache.h"
     22 #include "tensorflow/stream_executor/plugin.h"
     23 #include "tensorflow/stream_executor/stream_executor.h"
     24 #include "tensorflow/stream_executor/trace_listener.h"
     25 
     26 namespace perftools {
     27 namespace gputools {
     28 namespace interpreter {
     29 
     30 class InterpreterPlatform : public Platform {
     31  public:
     32   InterpreterPlatform();
     33   ~InterpreterPlatform() override;
     34 
     35   Platform::Id id() const override;
     36 
     37   int VisibleDeviceCount() const override;
     38 
     39   const string& Name() const override;
     40 
     41   port::StatusOr<StreamExecutor*> ExecutorForDevice(int ordinal) override;
     42 
     43   port::StatusOr<StreamExecutor*> ExecutorForDeviceWithPluginConfig(
     44       int ordinal, const PluginConfig& config) override;
     45 
     46   port::StatusOr<StreamExecutor*> GetExecutor(
     47       const StreamExecutorConfig& config) override;
     48 
     49   port::StatusOr<std::unique_ptr<StreamExecutor>> GetUncachedExecutor(
     50       const StreamExecutorConfig& config) override;
     51 
     52   void RegisterTraceListener(std::unique_ptr<TraceListener> listener) override;
     53 
     54   void UnregisterTraceListener(TraceListener* listener) override;
     55 
     56  private:
     57   // This platform's name.
     58   string name_;
     59 
     60   // Cache of created StreamExecutors.
     61   ExecutorCache executor_cache_;
     62 
     63   SE_DISALLOW_COPY_AND_ASSIGN(InterpreterPlatform);
     64 };
     65 
     66 }  // namespace interpreter
     67 }  // namespace gputools
     68 }  // namespace perftools
     69 
     70 #endif  // TENSORFLOW_COMPILER_XLA_SERVICE_INTERPRETER_PLATFORM_H_
     71