}
se::Platform::Id InterpreterCompiler::PlatformId() const {
- return sep::kInterpreterPlatformId;
+ return sep::kXlaInterpreterPlatformId;
}
HloCostAnalysis::ShapeSizeFunction InterpreterCompiler::ShapeSizeBytesFunction()
}
static bool InitModule() {
- xla::Compiler::RegisterCompilerFactory(sep::kInterpreterPlatformId, []() {
+ xla::Compiler::RegisterCompilerFactory(sep::kXlaInterpreterPlatformId, []() {
return xla::MakeUnique<xla::interpreter::InterpreterCompiler>();
});
- xla::ComputationPlacer::RegisterComputationPlacer(sep::kInterpreterPlatformId,
- &CreateComputationPlacer);
+ xla::ComputationPlacer::RegisterComputationPlacer(
+ sep::kXlaInterpreterPlatformId, &CreateComputationPlacer);
return true;
}
return dynamic_cast<host::HostStream *>(stream->implementation());
}
-InterpreterExecutor::InterpreterExecutor(const PluginConfig &plugin_config)
+XlaInterpreterExecutor::XlaInterpreterExecutor(
+ const PluginConfig &plugin_config)
: plugin_config_(plugin_config) {}
-InterpreterExecutor::~InterpreterExecutor() {}
+XlaInterpreterExecutor::~XlaInterpreterExecutor() {}
-void *InterpreterExecutor::Allocate(uint64 size) { return new char[size]; }
+void *XlaInterpreterExecutor::Allocate(uint64 size) { return new char[size]; }
-void *InterpreterExecutor::AllocateSubBuffer(DeviceMemoryBase *parent,
- uint64 offset_bytes,
- uint64 /*size_bytes*/) {
+void *XlaInterpreterExecutor::AllocateSubBuffer(DeviceMemoryBase *parent,
+ uint64 offset_bytes,
+ uint64 /*size_bytes*/) {
return parent + offset_bytes;
}
-void InterpreterExecutor::Deallocate(DeviceMemoryBase *mem) {
+void XlaInterpreterExecutor::Deallocate(DeviceMemoryBase *mem) {
if (!mem->is_sub_buffer()) {
delete[] static_cast<char *>(mem->opaque());
}
}
-bool InterpreterExecutor::Memcpy(Stream *stream, void *host_dst,
- const DeviceMemoryBase &dev_src, uint64 size) {
+bool XlaInterpreterExecutor::Memcpy(Stream *stream, void *host_dst,
+ const DeviceMemoryBase &dev_src,
+ uint64 size) {
AsExecutorStream(stream)->EnqueueTask([this, host_dst, dev_src, size]() {
port::Status ok = SynchronousMemcpy(host_dst, dev_src, size);
});
return true;
}
-bool InterpreterExecutor::Memcpy(Stream *stream, DeviceMemoryBase *dev_dst,
- const void *host_src, uint64 size) {
+bool XlaInterpreterExecutor::Memcpy(Stream *stream, DeviceMemoryBase *dev_dst,
+ const void *host_src, uint64 size) {
AsExecutorStream(stream)->EnqueueTask([this, dev_dst, host_src, size]() {
port::Status ok = SynchronousMemcpy(dev_dst, host_src, size);
});
return true;
}
-port::Status InterpreterExecutor::SynchronousMemcpy(DeviceMemoryBase *dev_dst,
- const void *host_src,
- uint64 size) {
+port::Status XlaInterpreterExecutor::SynchronousMemcpy(
+ DeviceMemoryBase *dev_dst, const void *host_src, uint64 size) {
memcpy(dev_dst->opaque(), host_src, size);
return port::Status::OK();
}
-port::Status InterpreterExecutor::SynchronousMemcpy(
+port::Status XlaInterpreterExecutor::SynchronousMemcpy(
void *host_dst, const DeviceMemoryBase &dev_src, uint64 size) {
memcpy(host_dst, dev_src.opaque(), size);
return port::Status::OK();
}
-bool InterpreterExecutor::HostCallback(Stream *stream,
- std::function<void()> callback) {
+bool XlaInterpreterExecutor::HostCallback(Stream *stream,
+ std::function<void()> callback) {
AsExecutorStream(stream)->EnqueueTask(callback);
return true;
}
-bool InterpreterExecutor::CreateStreamDependency(Stream *dependent,
- Stream *other) {
+bool XlaInterpreterExecutor::CreateStreamDependency(Stream *dependent,
+ Stream *other) {
AsExecutorStream(dependent)->EnqueueTask(
[other]() { SE_CHECK_OK(other->BlockHostUntilDone()); });
AsExecutorStream(dependent)->BlockUntilDone();
return true;
}
-bool InterpreterExecutor::StartTimer(Stream *stream, Timer *timer) {
+bool XlaInterpreterExecutor::StartTimer(Stream *stream, Timer *timer) {
dynamic_cast<host::HostTimer *>(timer->implementation())->Start(stream);
return true;
}
-bool InterpreterExecutor::StopTimer(Stream *stream, Timer *timer) {
+bool XlaInterpreterExecutor::StopTimer(Stream *stream, Timer *timer) {
dynamic_cast<host::HostTimer *>(timer->implementation())->Stop(stream);
return true;
}
-port::Status InterpreterExecutor::BlockHostUntilDone(Stream *stream) {
+port::Status XlaInterpreterExecutor::BlockHostUntilDone(Stream *stream) {
AsExecutorStream(stream)->BlockUntilDone();
return port::Status::OK();
}
-DeviceDescription *InterpreterExecutor::PopulateDeviceDescription() const {
+DeviceDescription *XlaInterpreterExecutor::PopulateDeviceDescription() const {
internal::DeviceDescriptionBuilder builder;
builder.set_device_address_bits(64);
limitations under the License.
==============================================================================*/
-// Declares the InterpreterExecutor class, which is a CPU-only implementation of
-// the StreamExecutor interface. For now, this is used for testing and to
+// Declares the XlaInterpreterExecutor class, which is a CPU-only implementation
+// of the StreamExecutor interface. For now, this is used for testing and to
// examine the performance of host-based StreamExecutor code.
#ifndef TENSORFLOW_COMPILER_XLA_SERVICE_INTERPRETER_EXECUTOR_H_
#define TENSORFLOW_COMPILER_XLA_SERVICE_INTERPRETER_EXECUTOR_H_
using Args = tensorflow::gtl::ArraySlice<DeviceMemoryBase>;
-class InterpreterExecutor : public internal::StreamExecutorInterface {
+class XlaInterpreterExecutor : public internal::StreamExecutorInterface {
public:
- explicit InterpreterExecutor(const PluginConfig &plugin_config);
- ~InterpreterExecutor() override;
+ explicit XlaInterpreterExecutor(const PluginConfig &plugin_config);
+ ~XlaInterpreterExecutor() override;
port::Status Init(int device_ordinal, DeviceOptions device_options) override {
return port::Status::OK();
namespace xla {
InterpreterTransferManager::InterpreterTransferManager()
- : GenericTransferManager(sei::kInterpreterPlatformId,
+ : GenericTransferManager(sei::kXlaInterpreterPlatformId,
/*pointer_size=*/sizeof(void*)) {}
} // namespace xla
static bool InitModule() {
xla::TransferManager::RegisterTransferManager(
- sei::kInterpreterPlatformId, &CreateInterpreterTransferManager);
+ sei::kXlaInterpreterPlatformId, &CreateInterpreterTransferManager);
return true;
}
namespace gputools {
namespace interpreter {
-InterpreterPlatform::InterpreterPlatform() : name_("Interpreter") {}
+XlaInterpreterPlatform::XlaInterpreterPlatform() : name_("Interpreter") {}
-InterpreterPlatform::~InterpreterPlatform() {}
+XlaInterpreterPlatform::~XlaInterpreterPlatform() {}
-Platform::Id InterpreterPlatform::id() const { return kInterpreterPlatformId; }
+Platform::Id XlaInterpreterPlatform::id() const {
+ return kXlaInterpreterPlatformId;
+}
-int InterpreterPlatform::VisibleDeviceCount() const { return 1; }
+int XlaInterpreterPlatform::VisibleDeviceCount() const { return 1; }
-const string& InterpreterPlatform::Name() const { return name_; }
+const string& XlaInterpreterPlatform::Name() const { return name_; }
-port::StatusOr<StreamExecutor*> InterpreterPlatform::ExecutorForDevice(
+port::StatusOr<StreamExecutor*> XlaInterpreterPlatform::ExecutorForDevice(
int ordinal) {
StreamExecutorConfig config;
config.ordinal = ordinal;
}
port::StatusOr<StreamExecutor*>
-InterpreterPlatform::ExecutorForDeviceWithPluginConfig(
+XlaInterpreterPlatform::ExecutorForDeviceWithPluginConfig(
int device_ordinal, const PluginConfig& plugin_config) {
StreamExecutorConfig config;
config.ordinal = device_ordinal;
return GetExecutor(config);
}
-port::StatusOr<StreamExecutor*> InterpreterPlatform::GetExecutor(
+port::StatusOr<StreamExecutor*> XlaInterpreterPlatform::GetExecutor(
const StreamExecutorConfig& config) {
return executor_cache_.GetOrCreate(
config, [&]() { return GetUncachedExecutor(config); });
}
port::StatusOr<std::unique_ptr<StreamExecutor>>
-InterpreterPlatform::GetUncachedExecutor(const StreamExecutorConfig& config) {
+XlaInterpreterPlatform::GetUncachedExecutor(
+ const StreamExecutorConfig& config) {
auto executor = port::MakeUnique<StreamExecutor>(
- this, port::MakeUnique<InterpreterExecutor>(config.plugin_config));
+ this, port::MakeUnique<XlaInterpreterExecutor>(config.plugin_config));
auto init_status = executor->Init(config.ordinal, config.device_options);
if (!init_status.ok()) {
return port::Status{
return std::move(executor);
}
-void InterpreterPlatform::RegisterTraceListener(
+void XlaInterpreterPlatform::RegisterTraceListener(
std::unique_ptr<TraceListener> listener) {
LOG(FATAL) << "not yet implemented: register executor trace listener";
}
-void InterpreterPlatform::UnregisterTraceListener(TraceListener* listener) {
+void XlaInterpreterPlatform::UnregisterTraceListener(TraceListener* listener) {
LOG(FATAL) << "not yet implemented: unregister executor trace listener";
}
-static void InitializeInterpreterPlatform() {
- std::unique_ptr<se::Platform> platform(new sep::InterpreterPlatform);
+static void InitializeXlaInterpreterPlatform() {
+ std::unique_ptr<se::Platform> platform(new sep::XlaInterpreterPlatform);
SE_CHECK_OK(se::MultiPlatformManager::RegisterPlatform(std::move(platform)));
}
} // namespace perftools
REGISTER_MODULE_INITIALIZER(interpreter_platform,
- sep::InitializeInterpreterPlatform());
+ sep::InitializeXlaInterpreterPlatform());
DECLARE_MODULE_INITIALIZER(multi_platform_manager);
namespace gputools {
namespace interpreter {
-class InterpreterPlatform : public Platform {
+class XlaInterpreterPlatform : public Platform {
public:
- InterpreterPlatform();
- ~InterpreterPlatform() override;
+ XlaInterpreterPlatform();
+ ~XlaInterpreterPlatform() override;
Platform::Id id() const override;
// Cache of created StreamExecutors.
ExecutorCache executor_cache_;
- SE_DISALLOW_COPY_AND_ASSIGN(InterpreterPlatform);
+ SE_DISALLOW_COPY_AND_ASSIGN(XlaInterpreterPlatform);
};
} // namespace interpreter
namespace gputools {
namespace interpreter {
-PLATFORM_DEFINE_ID(kInterpreterPlatformId);
+PLATFORM_DEFINE_ID(kXlaInterpreterPlatformId);
} // namespace interpreter
} // namespace gputools
namespace gputools {
namespace interpreter {
-extern const Platform::Id kInterpreterPlatformId;
+extern const Platform::Id kXlaInterpreterPlatformId;
} // namespace interpreter
} // namespace gputools