From b586b44bd6ab75d796c46147fcc7d047031e0d15 Mon Sep 17 00:00:00 2001 From: Justin Lebar Date: Fri, 3 May 2019 11:06:44 -0700 Subject: [PATCH] [XLA] Clean up function signatures in HloRunner. Top-level const on value types in function declarations (i.e. headers) has no semantic meaning, so removed. Removed the corresponding const in the function definitions (i.e. cc files) because it's noise in these cases; there's no need for these Spans to be const. PiperOrigin-RevId: 246539671 --- tensorflow/compiler/xla/service/hlo_runner.cc | 33 +++++++++---------- tensorflow/compiler/xla/service/hlo_runner.h | 22 ++++++------- 2 files changed, 25 insertions(+), 30 deletions(-) diff --git a/tensorflow/compiler/xla/service/hlo_runner.cc b/tensorflow/compiler/xla/service/hlo_runner.cc index 9416324b92b..4dca2d40bbd 100644 --- a/tensorflow/compiler/xla/service/hlo_runner.cc +++ b/tensorflow/compiler/xla/service/hlo_runner.cc @@ -109,7 +109,7 @@ StatusOr HloRunner::TransferLiteralToDevice( } StatusOr> HloRunner::TransferLiteralsToDevice( - const absl::Span literals) { + absl::Span literals) { std::vector buffers; for (const Literal* literal : literals) { CHECK(literal != nullptr); @@ -121,7 +121,7 @@ StatusOr> HloRunner::TransferLiteralsToDevice( } StatusOr> HloRunner::TransferLiteralsToDevice( - const absl::Span literals) { + absl::Span literals) { std::vector literal_pointers; literal_pointers.reserve(literals.size()); for (const auto& literal : literals) { @@ -138,10 +138,10 @@ StatusOr HloRunner::TransferLiteralFromDevice( buffer); } -StatusOr HloRunner::Execute( - std::unique_ptr module, - const absl::Span arguments, bool run_hlo_passes, - ExecutionProfile* profile) { +StatusOr HloRunner::Execute(std::unique_ptr module, + absl::Span arguments, + bool run_hlo_passes, + ExecutionProfile* profile) { TF_ASSIGN_OR_RETURN(std::vector argument_buffers, TransferLiteralsToDevice(arguments)); TF_ASSIGN_OR_RETURN(ScopedShapedBuffer result, @@ -154,7 +154,7 @@ StatusOr HloRunner::Execute( } StatusOr HloRunner::Execute(std::unique_ptr module, - const absl::Span arguments, + absl::Span arguments, bool run_hlo_passes, ExecutionProfile* profile) { // Construct a vector of plain pointers for the arguments. @@ -170,10 +170,9 @@ StatusOr HloRunner::Execute(std::unique_ptr module, /*profile=*/profile); } -StatusOr HloRunner::Execute( - std::unique_ptr executable, - const absl::Span arguments, - ExecutionProfile* profile) { +StatusOr HloRunner::Execute(std::unique_ptr executable, + absl::Span arguments, + ExecutionProfile* profile) { TF_ASSIGN_OR_RETURN(std::vector argument_buffers, TransferLiteralsToDevice(arguments)); TF_ASSIGN_OR_RETURN(ScopedShapedBuffer result, @@ -185,7 +184,7 @@ StatusOr HloRunner::Execute( } StatusOr HloRunner::Execute(std::unique_ptr executable, - const absl::Span arguments, + absl::Span arguments, ExecutionProfile* profile) { // Construct a vector of plain pointers for the arguments. std::vector argument_pointers; @@ -201,7 +200,7 @@ StatusOr HloRunner::Execute(std::unique_ptr executable, StatusOr HloRunner::ExecuteWithDeviceBuffers( std::unique_ptr module, - const absl::Span arguments, bool run_hlo_passes, + absl::Span arguments, bool run_hlo_passes, ExecutionProfile* profile) { // Get service run options. se::Stream stream(backend().default_stream_executor()); @@ -222,7 +221,7 @@ StatusOr HloRunner::ExecuteWithDeviceBuffers( StatusOr HloRunner::ExecuteWithDeviceBuffers( std::unique_ptr module, - const absl::Span arguments, bool run_hlo_passes, + absl::Span arguments, bool run_hlo_passes, ExecutionProfile* profile) { std::vector argument_pointers; argument_pointers.reserve(arguments.size()); @@ -237,8 +236,7 @@ StatusOr HloRunner::ExecuteWithDeviceBuffers( } StatusOr HloRunner::ExecuteWithDeviceBuffers( - Executable* executable, - const absl::Span arguments, + Executable* executable, absl::Span arguments, ExecutionProfile* profile) { // Get service run options. se::Stream stream(backend().default_stream_executor()); @@ -256,8 +254,7 @@ StatusOr HloRunner::ExecuteWithDeviceBuffers( } StatusOr HloRunner::ExecuteWithDeviceBuffers( - Executable* executable, - const absl::Span arguments, + Executable* executable, absl::Span arguments, ExecutionProfile* profile) { std::vector argument_pointers; argument_pointers.reserve(arguments.size()); diff --git a/tensorflow/compiler/xla/service/hlo_runner.h b/tensorflow/compiler/xla/service/hlo_runner.h index e7827864c18..34d08ecfba5 100644 --- a/tensorflow/compiler/xla/service/hlo_runner.h +++ b/tensorflow/compiler/xla/service/hlo_runner.h @@ -110,9 +110,9 @@ class HloRunner { // Transfers data between the host and device. StatusOr TransferLiteralToDevice(const Literal& literal); StatusOr> TransferLiteralsToDevice( - const absl::Span literals); + absl::Span literals); StatusOr> TransferLiteralsToDevice( - const absl::Span literals); + absl::Span literals); StatusOr TransferLiteralFromDevice(const ShapedBuffer& buffer); // Executes the given module with given literals as input and returns the @@ -121,46 +121,44 @@ class HloRunner { // If run_hlo_passes is false, the module will be executed without Hlo // optimization. StatusOr Execute(std::unique_ptr module, - const absl::Span arguments, + absl::Span arguments, bool run_hlo_passes = true, ExecutionProfile* profile = nullptr); StatusOr Execute(std::unique_ptr module, - const absl::Span arguments, + absl::Span arguments, bool run_hlo_passes = true, ExecutionProfile* profile = nullptr); StatusOr Execute(std::unique_ptr executable, - const absl::Span arguments, + absl::Span arguments, ExecutionProfile* profile = nullptr); StatusOr Execute(std::unique_ptr executable, - const absl::Span arguments, + absl::Span arguments, ExecutionProfile* profile = nullptr); // As Execute(), but accepts and returns device buffers instead of host // buffers. StatusOr ExecuteWithDeviceBuffers( std::unique_ptr module, - const absl::Span arguments, + absl::Span arguments, bool run_hlo_passes = true, ExecutionProfile* profile = nullptr); StatusOr ExecuteWithDeviceBuffers( std::unique_ptr module, - const absl::Span arguments, + absl::Span arguments, bool run_hlo_passes = true, ExecutionProfile* profile = nullptr); // In the following two calls, "executable" is not a unique_ptr to allow // reuse of the Executable. This call may update the profile information in // *executable. StatusOr ExecuteWithDeviceBuffers( - Executable* executable, - const absl::Span arguments, + Executable* executable, absl::Span arguments, ExecutionProfile* profile = nullptr); StatusOr ExecuteWithDeviceBuffers( - Executable* executable, - const absl::Span arguments, + Executable* executable, absl::Span arguments, ExecutionProfile* profile = nullptr); // Creates an executable object given an HLO module. If run_hlo_passes is