aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Justin Lebar <jlebar@google.com>2018-08-23 10:23:44 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-08-23 10:27:38 -0700
commit90d9d2b1946f80e0a13babd376ec1d91cbeef266 (patch)
treee77cd4704a0db69fd5c3240f7ac87791578d22c6
parent5da5e8af4650287c9dcde8869ac1158d79c1415f (diff)
[XLA] Use absl string types and functions instead of the TF versions.
Unfortunately this has to be one big patch, because e.g. absl::StrCat doesn't accept a TF StringPiece, but as soon as we switch to absl::string_view, we have to switch away from all of the TF functions. PiperOrigin-RevId: 209957896
-rw-r--r--tensorflow/compiler/aot/embedded_protocol_buffers.cc2
-rw-r--r--tensorflow/compiler/aot/tests/BUILD1
-rw-r--r--tensorflow/compiler/aot/tests/tfcompile_test.cc3
-rw-r--r--tensorflow/compiler/jit/kernels/BUILD1
-rw-r--r--tensorflow/compiler/jit/kernels/parallel_check_op.cc7
-rw-r--r--tensorflow/compiler/xla/BUILD19
-rw-r--r--tensorflow/compiler/xla/array.h2
-rw-r--r--tensorflow/compiler/xla/array2d.h2
-rw-r--r--tensorflow/compiler/xla/array4d.h2
-rw-r--r--tensorflow/compiler/xla/client/BUILD3
-rw-r--r--tensorflow/compiler/xla/client/client.cc4
-rw-r--r--tensorflow/compiler/xla/client/compile_only_client.cc2
-rw-r--r--tensorflow/compiler/xla/client/compile_only_client.h2
-rw-r--r--tensorflow/compiler/xla/client/executable_build_options.cc8
-rw-r--r--tensorflow/compiler/xla/client/executable_build_options.h10
-rw-r--r--tensorflow/compiler/xla/client/lib/BUILD3
-rw-r--r--tensorflow/compiler/xla/client/lib/arithmetic.cc4
-rw-r--r--tensorflow/compiler/xla/client/lib/testing.cc5
-rw-r--r--tensorflow/compiler/xla/client/xla_builder.cc12
-rw-r--r--tensorflow/compiler/xla/client/xla_builder.h2
-rw-r--r--tensorflow/compiler/xla/device_util.h6
-rw-r--r--tensorflow/compiler/xla/layout_util.cc7
-rw-r--r--tensorflow/compiler/xla/legacy_flags/BUILD2
-rw-r--r--tensorflow/compiler/xla/legacy_flags/debug_options_flags.cc3
-rw-r--r--tensorflow/compiler/xla/legacy_flags/debug_options_parsers.h18
-rw-r--r--tensorflow/compiler/xla/literal.cc4
-rw-r--r--tensorflow/compiler/xla/literal.h2
-rw-r--r--tensorflow/compiler/xla/literal_comparison.cc6
-rw-r--r--tensorflow/compiler/xla/literal_test.cc23
-rw-r--r--tensorflow/compiler/xla/literal_util.cc6
-rw-r--r--tensorflow/compiler/xla/literal_util.h4
-rw-r--r--tensorflow/compiler/xla/metric_table_report.cc23
-rw-r--r--tensorflow/compiler/xla/metric_table_report.h4
-rw-r--r--tensorflow/compiler/xla/python/BUILD1
-rw-r--r--tensorflow/compiler/xla/python/local_computation_builder.i3
-rw-r--r--tensorflow/compiler/xla/python/numpy_bridge.cc5
-rw-r--r--tensorflow/compiler/xla/service/BUILD53
-rw-r--r--tensorflow/compiler/xla/service/algebraic_simplifier.cc7
-rw-r--r--tensorflow/compiler/xla/service/algebraic_simplifier.h2
-rw-r--r--tensorflow/compiler/xla/service/algebraic_simplifier_test.cc13
-rw-r--r--tensorflow/compiler/xla/service/allocation_tracker.cc2
-rw-r--r--tensorflow/compiler/xla/service/backend.h4
-rw-r--r--tensorflow/compiler/xla/service/batch_dot_simplification.cc2
-rw-r--r--tensorflow/compiler/xla/service/batch_dot_simplification.h2
-rw-r--r--tensorflow/compiler/xla/service/batchnorm_expander.h2
-rw-r--r--tensorflow/compiler/xla/service/bfloat16_conversion_folding.h2
-rw-r--r--tensorflow/compiler/xla/service/bfloat16_normalization.h4
-rw-r--r--tensorflow/compiler/xla/service/bfloat16_propagation.h4
-rw-r--r--tensorflow/compiler/xla/service/buffer_assignment.cc12
-rw-r--r--tensorflow/compiler/xla/service/buffer_value.cc2
-rw-r--r--tensorflow/compiler/xla/service/call_graph.cc4
-rw-r--r--tensorflow/compiler/xla/service/call_inliner.h2
-rw-r--r--tensorflow/compiler/xla/service/channel_tracker.cc2
-rw-r--r--tensorflow/compiler/xla/service/compile_only_service.cc8
-rw-r--r--tensorflow/compiler/xla/service/computation_layout.cc7
-rw-r--r--tensorflow/compiler/xla/service/computation_placer.cc6
-rw-r--r--tensorflow/compiler/xla/service/conditional_simplifier.cc2
-rw-r--r--tensorflow/compiler/xla/service/conditional_simplifier.h6
-rw-r--r--tensorflow/compiler/xla/service/convolution_feature_group_converter.h4
-rw-r--r--tensorflow/compiler/xla/service/copy_insertion.cc6
-rw-r--r--tensorflow/compiler/xla/service/copy_insertion.h2
-rw-r--r--tensorflow/compiler/xla/service/cpu/BUILD8
-rw-r--r--tensorflow/compiler/xla/service/cpu/conv_canonicalization.h2
-rw-r--r--tensorflow/compiler/xla/service/cpu/cpu_compiler.cc2
-rw-r--r--tensorflow/compiler/xla/service/cpu/cpu_copy_insertion.h2
-rw-r--r--tensorflow/compiler/xla/service/cpu/cpu_executable.cc4
-rw-r--r--tensorflow/compiler/xla/service/cpu/cpu_hlo_support_checker.h4
-rw-r--r--tensorflow/compiler/xla/service/cpu/cpu_instruction_fusion_test.cc5
-rw-r--r--tensorflow/compiler/xla/service/cpu/cpu_options.cc21
-rw-r--r--tensorflow/compiler/xla/service/cpu/dot_op_emitter.cc19
-rw-r--r--tensorflow/compiler/xla/service/cpu/dot_op_emitter.h2
-rw-r--r--tensorflow/compiler/xla/service/cpu/ir_emitter.cc21
-rw-r--r--tensorflow/compiler/xla/service/cpu/ir_emitter.h13
-rw-r--r--tensorflow/compiler/xla/service/cpu/ir_function.cc14
-rw-r--r--tensorflow/compiler/xla/service/cpu/ir_function.h2
-rw-r--r--tensorflow/compiler/xla/service/cpu/parallel_loop_emitter.cc4
-rw-r--r--tensorflow/compiler/xla/service/cpu/parallel_loop_emitter.h2
-rw-r--r--tensorflow/compiler/xla/service/cpu/parallel_task_assignment.cc4
-rw-r--r--tensorflow/compiler/xla/service/cpu/parallel_task_assignment.h2
-rw-r--r--tensorflow/compiler/xla/service/cpu/simple_orc_jit.cc17
-rw-r--r--tensorflow/compiler/xla/service/cpu/tests/BUILD2
-rw-r--r--tensorflow/compiler/xla/service/cpu/tests/cpu_eigen_dot_operation_test.cc2
-rw-r--r--tensorflow/compiler/xla/service/cpu/tests/cpu_intrinsic_test.cc13
-rw-r--r--tensorflow/compiler/xla/service/defuser.h2
-rw-r--r--tensorflow/compiler/xla/service/despecializer.cc4
-rw-r--r--tensorflow/compiler/xla/service/despecializer.h2
-rw-r--r--tensorflow/compiler/xla/service/dfs_hlo_visitor.h2
-rw-r--r--tensorflow/compiler/xla/service/dfs_hlo_visitor_with_default.h2
-rw-r--r--tensorflow/compiler/xla/service/dot_decomposer.h2
-rw-r--r--tensorflow/compiler/xla/service/elemental_ir_emitter.cc4
-rw-r--r--tensorflow/compiler/xla/service/flatten_call_graph.h2
-rw-r--r--tensorflow/compiler/xla/service/gather_expander.h2
-rw-r--r--tensorflow/compiler/xla/service/gpu/BUILD11
-rw-r--r--tensorflow/compiler/xla/service/gpu/buffer_comparator.cc6
-rw-r--r--tensorflow/compiler/xla/service/gpu/convolution_thunk.cc2
-rw-r--r--tensorflow/compiler/xla/service/gpu/cudnn_batchnorm_rewriter.h4
-rw-r--r--tensorflow/compiler/xla/service/gpu/cudnn_batchnorm_thunk.cc2
-rw-r--r--tensorflow/compiler/xla/service/gpu/cudnn_convolution_algorithm_picker.cc10
-rw-r--r--tensorflow/compiler/xla/service/gpu/cudnn_convolution_algorithm_picker.h2
-rw-r--r--tensorflow/compiler/xla/service/gpu/cudnn_convolution_rewriter.h2
-rw-r--r--tensorflow/compiler/xla/service/gpu/cudnn_convolution_runner.cc3
-rw-r--r--tensorflow/compiler/xla/service/gpu/elemental_ir_emitter.cc6
-rw-r--r--tensorflow/compiler/xla/service/gpu/fft_thunk.cc2
-rw-r--r--tensorflow/compiler/xla/service/gpu/fusion_merger.cc3
-rw-r--r--tensorflow/compiler/xla/service/gpu/fusion_merger.h2
-rw-r--r--tensorflow/compiler/xla/service/gpu/gemm_thunk.cc2
-rw-r--r--tensorflow/compiler/xla/service/gpu/gpu_copy_insertion.h2
-rw-r--r--tensorflow/compiler/xla/service/gpu/gpu_executable.h2
-rw-r--r--tensorflow/compiler/xla/service/gpu/gpu_hlo_support_checker.h4
-rw-r--r--tensorflow/compiler/xla/service/gpu/gpu_layout_assignment_test.cc7
-rw-r--r--tensorflow/compiler/xla/service/gpu/hlo_to_ir_bindings.cc6
-rw-r--r--tensorflow/compiler/xla/service/gpu/ir_emission_utils.cc2
-rw-r--r--tensorflow/compiler/xla/service/gpu/ir_emission_utils.h2
-rw-r--r--tensorflow/compiler/xla/service/gpu/ir_emitter.h2
-rw-r--r--tensorflow/compiler/xla/service/gpu/ir_emitter_unnested.cc6
-rw-r--r--tensorflow/compiler/xla/service/gpu/kernel_thunk.cc6
-rw-r--r--tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/BUILD1
-rw-r--r--tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/dump_ir_pass.cc4
-rw-r--r--tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/nvptx_backend_lib.cc30
-rw-r--r--tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/nvptx_backend_lib.h2
-rw-r--r--tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/utils.cc17
-rw-r--r--tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/utils.h6
-rw-r--r--tensorflow/compiler/xla/service/gpu/multi_output_fusion_test.cc27
-rw-r--r--tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc13
-rw-r--r--tensorflow/compiler/xla/service/gpu/pad_for_tensor_cores.h4
-rw-r--r--tensorflow/compiler/xla/service/gpu/pad_insertion.h2
-rw-r--r--tensorflow/compiler/xla/service/gpu/parallel_loop_emitter.cc4
-rw-r--r--tensorflow/compiler/xla/service/gpu/parallel_loop_emitter.h2
-rw-r--r--tensorflow/compiler/xla/service/gpu/thunk_schedule.cc11
-rw-r--r--tensorflow/compiler/xla/service/graphviz_example.cc5
-rw-r--r--tensorflow/compiler/xla/service/hlo_alias_analysis.cc6
-rw-r--r--tensorflow/compiler/xla/service/hlo_buffer.cc4
-rw-r--r--tensorflow/compiler/xla/service/hlo_computation.cc12
-rw-r--r--tensorflow/compiler/xla/service/hlo_computation.h2
-rw-r--r--tensorflow/compiler/xla/service/hlo_constant_folding.h2
-rw-r--r--tensorflow/compiler/xla/service/hlo_creation_utils.cc5
-rw-r--r--tensorflow/compiler/xla/service/hlo_creation_utils.h2
-rw-r--r--tensorflow/compiler/xla/service/hlo_cse.h2
-rw-r--r--tensorflow/compiler/xla/service/hlo_dataflow_analysis.cc6
-rw-r--r--tensorflow/compiler/xla/service/hlo_dce.h2
-rw-r--r--tensorflow/compiler/xla/service/hlo_domain_isolator.h2
-rw-r--r--tensorflow/compiler/xla/service/hlo_domain_metadata.h4
-rw-r--r--tensorflow/compiler/xla/service/hlo_domain_remover.h6
-rw-r--r--tensorflow/compiler/xla/service/hlo_domain_test.cc11
-rw-r--r--tensorflow/compiler/xla/service/hlo_domain_verifier.cc2
-rw-r--r--tensorflow/compiler/xla/service/hlo_domain_verifier.h2
-rw-r--r--tensorflow/compiler/xla/service/hlo_element_type_converter.h4
-rw-r--r--tensorflow/compiler/xla/service/hlo_evaluator.cc2
-rw-r--r--tensorflow/compiler/xla/service/hlo_execution_profile_test.cc4
-rw-r--r--tensorflow/compiler/xla/service/hlo_graph_dumper.cc24
-rw-r--r--tensorflow/compiler/xla/service/hlo_graph_dumper_test.cc4
-rw-r--r--tensorflow/compiler/xla/service/hlo_instruction.cc19
-rw-r--r--tensorflow/compiler/xla/service/hlo_instruction.h12
-rw-r--r--tensorflow/compiler/xla/service/hlo_instructions.cc28
-rw-r--r--tensorflow/compiler/xla/service/hlo_instructions.h7
-rw-r--r--tensorflow/compiler/xla/service/hlo_lexer.cc34
-rw-r--r--tensorflow/compiler/xla/service/hlo_lexer.h12
-rw-r--r--tensorflow/compiler/xla/service/hlo_liveness_analysis.cc2
-rw-r--r--tensorflow/compiler/xla/service/hlo_matchers.h6
-rw-r--r--tensorflow/compiler/xla/service/hlo_module.cc7
-rw-r--r--tensorflow/compiler/xla/service/hlo_module.h4
-rw-r--r--tensorflow/compiler/xla/service/hlo_module_config.cc7
-rw-r--r--tensorflow/compiler/xla/service/hlo_module_dce.h2
-rw-r--r--tensorflow/compiler/xla/service/hlo_module_group_util.cc6
-rw-r--r--tensorflow/compiler/xla/service/hlo_parser.cc66
-rw-r--r--tensorflow/compiler/xla/service/hlo_parser.h16
-rw-r--r--tensorflow/compiler/xla/service/hlo_parser_test.cc23
-rw-r--r--tensorflow/compiler/xla/service/hlo_pass_interface.h2
-rw-r--r--tensorflow/compiler/xla/service/hlo_pass_pipeline.cc6
-rw-r--r--tensorflow/compiler/xla/service/hlo_pass_pipeline.h2
-rw-r--r--tensorflow/compiler/xla/service/hlo_rematerialization.cc41
-rw-r--r--tensorflow/compiler/xla/service/hlo_runner.cc2
-rw-r--r--tensorflow/compiler/xla/service/hlo_runner.h3
-rw-r--r--tensorflow/compiler/xla/service/hlo_sharding.cc3
-rw-r--r--tensorflow/compiler/xla/service/hlo_sharding_metadata.h4
-rw-r--r--tensorflow/compiler/xla/service/hlo_subcomputation_unification.h2
-rw-r--r--tensorflow/compiler/xla/service/hlo_tfgraph_builder.cc8
-rw-r--r--tensorflow/compiler/xla/service/hlo_value.cc6
-rw-r--r--tensorflow/compiler/xla/service/hlo_verifier.h2
-rw-r--r--tensorflow/compiler/xla/service/human_readable_profile_builder.cc6
-rw-r--r--tensorflow/compiler/xla/service/human_readable_profile_builder.h9
-rw-r--r--tensorflow/compiler/xla/service/implicit_broadcast_remover.h2
-rw-r--r--tensorflow/compiler/xla/service/indexed_array_analysis.cc27
-rw-r--r--tensorflow/compiler/xla/service/indexed_array_analysis.h2
-rw-r--r--tensorflow/compiler/xla/service/indexed_array_analysis_test.cc6
-rw-r--r--tensorflow/compiler/xla/service/inliner.h2
-rw-r--r--tensorflow/compiler/xla/service/instruction_fusion.h2
-rw-r--r--tensorflow/compiler/xla/service/layout_assignment.cc22
-rw-r--r--tensorflow/compiler/xla/service/layout_assignment.h2
-rw-r--r--tensorflow/compiler/xla/service/layout_assignment_test.cc2
-rw-r--r--tensorflow/compiler/xla/service/llvm_ir/BUILD8
-rw-r--r--tensorflow/compiler/xla/service/llvm_ir/alias_analysis.h2
-rw-r--r--tensorflow/compiler/xla/service/llvm_ir/buffer_assignment_util.cc3
-rw-r--r--tensorflow/compiler/xla/service/llvm_ir/dynamic_update_slice_util.cc5
-rw-r--r--tensorflow/compiler/xla/service/llvm_ir/dynamic_update_slice_util.h3
-rw-r--r--tensorflow/compiler/xla/service/llvm_ir/ir_array.cc8
-rw-r--r--tensorflow/compiler/xla/service/llvm_ir/ir_array.h6
-rw-r--r--tensorflow/compiler/xla/service/llvm_ir/kernel_support_library.cc8
-rw-r--r--tensorflow/compiler/xla/service/llvm_ir/kernel_support_library.h42
-rw-r--r--tensorflow/compiler/xla/service/llvm_ir/llvm_loop.cc37
-rw-r--r--tensorflow/compiler/xla/service/llvm_ir/llvm_loop.h30
-rw-r--r--tensorflow/compiler/xla/service/llvm_ir/llvm_util.cc56
-rw-r--r--tensorflow/compiler/xla/service/llvm_ir/llvm_util.h29
-rw-r--r--tensorflow/compiler/xla/service/llvm_ir/loop_emitter.cc4
-rw-r--r--tensorflow/compiler/xla/service/llvm_ir/loop_emitter.h4
-rw-r--r--tensorflow/compiler/xla/service/llvm_ir/sort_util.cc4
-rw-r--r--tensorflow/compiler/xla/service/llvm_ir/sort_util.h4
-rw-r--r--tensorflow/compiler/xla/service/local_service.cc2
-rw-r--r--tensorflow/compiler/xla/service/logical_buffer.cc10
-rw-r--r--tensorflow/compiler/xla/service/multi_output_fusion.h6
-rw-r--r--tensorflow/compiler/xla/service/name_uniquer.cc15
-rw-r--r--tensorflow/compiler/xla/service/name_uniquer.h4
-rw-r--r--tensorflow/compiler/xla/service/pattern_matcher.h8
-rw-r--r--tensorflow/compiler/xla/service/reduce_precision_insertion.h2
-rw-r--r--tensorflow/compiler/xla/service/reshape_mover.h2
-rw-r--r--tensorflow/compiler/xla/service/scatter_expander.h2
-rw-r--r--tensorflow/compiler/xla/service/service.cc4
-rw-r--r--tensorflow/compiler/xla/service/shape_inference.cc18
-rw-r--r--tensorflow/compiler/xla/service/shaped_buffer.cc3
-rw-r--r--tensorflow/compiler/xla/service/transfer_manager.cc3
-rw-r--r--tensorflow/compiler/xla/service/transpose_folding.h2
-rw-r--r--tensorflow/compiler/xla/service/tuple_points_to_analysis.cc45
-rw-r--r--tensorflow/compiler/xla/service/tuple_simplifier.h2
-rw-r--r--tensorflow/compiler/xla/service/while_loop_constant_sinking.h2
-rw-r--r--tensorflow/compiler/xla/service/while_loop_invariant_code_motion.h2
-rw-r--r--tensorflow/compiler/xla/service/while_loop_simplifier.cc5
-rw-r--r--tensorflow/compiler/xla/service/while_loop_simplifier.h4
-rw-r--r--tensorflow/compiler/xla/service/while_loop_simplifier_test.cc14
-rw-r--r--tensorflow/compiler/xla/service/while_util.cc4
-rw-r--r--tensorflow/compiler/xla/service/zero_sized_hlo_elimination.h2
-rw-r--r--tensorflow/compiler/xla/shape_util.cc39
-rw-r--r--tensorflow/compiler/xla/shape_util.h2
-rw-r--r--tensorflow/compiler/xla/shape_util_test.cc8
-rw-r--r--tensorflow/compiler/xla/status_macros.cc23
-rw-r--r--tensorflow/compiler/xla/test_helpers.h2
-rw-r--r--tensorflow/compiler/xla/tests/BUILD33
-rw-r--r--tensorflow/compiler/xla/tests/client_library_test_base.cc9
-rw-r--r--tensorflow/compiler/xla/tests/client_library_test_base.h4
-rw-r--r--tensorflow/compiler/xla/tests/compute_constant_test.cc9
-rw-r--r--tensorflow/compiler/xla/tests/convolution_test.cc2
-rw-r--r--tensorflow/compiler/xla/tests/dot_operation_test.cc17
-rw-r--r--tensorflow/compiler/xla/tests/hlo_test_base.cc12
-rw-r--r--tensorflow/compiler/xla/tests/hlo_test_base.h12
-rw-r--r--tensorflow/compiler/xla/tests/hlo_verified_test_base.cc2
-rw-r--r--tensorflow/compiler/xla/tests/hlo_verified_test_base.h2
-rw-r--r--tensorflow/compiler/xla/tests/matrix_ops_simple_test.cc3
-rw-r--r--tensorflow/compiler/xla/tests/multioutput_fusion_test.cc17
-rw-r--r--tensorflow/compiler/xla/tests/reduce_hlo_test.cc2
-rw-r--r--tensorflow/compiler/xla/tests/reduce_precision_test.cc5
-rw-r--r--tensorflow/compiler/xla/tests/reduce_window_test.cc17
-rw-r--r--tensorflow/compiler/xla/tests/scalar_computations_test.cc2
-rw-r--r--tensorflow/compiler/xla/tests/slice_test.cc3
-rw-r--r--tensorflow/compiler/xla/tests/test_macros.cc9
-rw-r--r--tensorflow/compiler/xla/tests/token_hlo_test.cc2
-rw-r--r--tensorflow/compiler/xla/tests/xla_hlo_profile_test.cc28
-rw-r--r--tensorflow/compiler/xla/tests/xla_internal_test_main.cc13
-rw-r--r--tensorflow/compiler/xla/text_literal_reader.cc43
-rw-r--r--tensorflow/compiler/xla/text_literal_reader.h5
-rw-r--r--tensorflow/compiler/xla/text_literal_writer.cc13
-rw-r--r--tensorflow/compiler/xla/text_literal_writer.h5
-rw-r--r--tensorflow/compiler/xla/tools/BUILD1
-rw-r--r--tensorflow/compiler/xla/tools/dumped_computation_to_operation_list.cc3
-rw-r--r--tensorflow/compiler/xla/tools/hex_floats_to_packed_literal.cc2
-rw-r--r--tensorflow/compiler/xla/util.cc45
-rw-r--r--tensorflow/compiler/xla/util.h32
-rw-r--r--tensorflow/compiler/xla/window_util.cc10
266 files changed, 1111 insertions, 1043 deletions
diff --git a/tensorflow/compiler/aot/embedded_protocol_buffers.cc b/tensorflow/compiler/aot/embedded_protocol_buffers.cc
index 8fb2fad31c..e56b49296a 100644
--- a/tensorflow/compiler/aot/embedded_protocol_buffers.cc
+++ b/tensorflow/compiler/aot/embedded_protocol_buffers.cc
@@ -97,7 +97,7 @@ static StatusOr<std::unique_ptr<llvm::TargetMachine>>
GetTargetMachineFromTriple(StringPiece target_triple) {
std::string error;
std::string normalized_triple =
- llvm::Triple::normalize(AsStringRef(target_triple));
+ llvm::Triple::normalize(AsStringRef(absl::string_view(target_triple)));
const llvm::Target* target =
llvm::TargetRegistry::lookupTarget(normalized_triple, error);
if (target == nullptr) {
diff --git a/tensorflow/compiler/aot/tests/BUILD b/tensorflow/compiler/aot/tests/BUILD
index 0ecc3feeb6..7364d63b53 100644
--- a/tensorflow/compiler/aot/tests/BUILD
+++ b/tensorflow/compiler/aot/tests/BUILD
@@ -226,5 +226,6 @@ tf_cc_test(
"//tensorflow/core:test",
"//tensorflow/core:test_main",
"//third_party/eigen3",
+ "@com_google_absl//absl/strings",
],
)
diff --git a/tensorflow/compiler/aot/tests/tfcompile_test.cc b/tensorflow/compiler/aot/tests/tfcompile_test.cc
index 0c0c676ece..a2b824da17 100644
--- a/tensorflow/compiler/aot/tests/tfcompile_test.cc
+++ b/tensorflow/compiler/aot/tests/tfcompile_test.cc
@@ -16,6 +16,7 @@ limitations under the License.
#define EIGEN_USE_THREADS
#define EIGEN_USE_CUSTOM_THREAD_POOL
+#include "absl/strings/str_split.h"
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
#include "tensorflow/compiler/aot/tests/test_graph_tfadd.h"
#include "tensorflow/compiler/aot/tests/test_graph_tfadd_with_ckpt.h"
@@ -546,7 +547,7 @@ TEST(TFCompileTest, HloProfiling) {
VLOG(1) << "HLO profile string:\n" << hlo_profile_as_string;
std::vector<string> hlo_profile_lines =
- tensorflow::str_util::Split(hlo_profile_as_string, '\n');
+ absl::StrSplit(hlo_profile_as_string, '\n');
auto header = HasSubstr("Execution profile for");
auto total_cycles_profile_line = HasSubstr("[total]");
diff --git a/tensorflow/compiler/jit/kernels/BUILD b/tensorflow/compiler/jit/kernels/BUILD
index 8f78c110cb..671cc7278d 100644
--- a/tensorflow/compiler/jit/kernels/BUILD
+++ b/tensorflow/compiler/jit/kernels/BUILD
@@ -39,6 +39,7 @@ cc_library(
"//tensorflow/core:core_cpu",
"//tensorflow/core:framework",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
],
alwayslink = 1,
)
diff --git a/tensorflow/compiler/jit/kernels/parallel_check_op.cc b/tensorflow/compiler/jit/kernels/parallel_check_op.cc
index bd4eefbc0b..5b88f2ff51 100644
--- a/tensorflow/compiler/jit/kernels/parallel_check_op.cc
+++ b/tensorflow/compiler/jit/kernels/parallel_check_op.cc
@@ -13,6 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
+#include "absl/strings/numbers.h"
#include "tensorflow/compiler/jit/legacy_flags/parallel_check_op_flags.h"
#include "tensorflow/core/common_runtime/device.h"
#include "tensorflow/core/framework/op.h"
@@ -41,14 +42,12 @@ class ParallelCheckOp : public OpKernel {
double rtol;
legacy_flags::ParallelCheckOpFlags* flags =
legacy_flags::GetParallelCheckOpFlags();
- if (!tensorflow::strings::safe_strtod(flags->parallel_check_rtol.c_str(),
- &rtol)) {
+ if (!absl::SimpleAtod(flags->parallel_check_rtol.c_str(), &rtol)) {
LOG(ERROR) << "can't convert parallel_check_rtol "
<< flags->parallel_check_rtol << " to double";
}
double atol;
- if (!tensorflow::strings::safe_strtod(flags->parallel_check_atol.c_str(),
- &atol)) {
+ if (!absl::SimpleAtod(flags->parallel_check_atol.c_str(), &atol)) {
LOG(ERROR) << "can't convert parallel_check_atol "
<< flags->parallel_check_atol << " to double";
}
diff --git a/tensorflow/compiler/xla/BUILD b/tensorflow/compiler/xla/BUILD
index 1a8fa627a0..b0609b9e8a 100644
--- a/tensorflow/compiler/xla/BUILD
+++ b/tensorflow/compiler/xla/BUILD
@@ -113,6 +113,7 @@ cc_library(
":statusor",
":types",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
],
)
@@ -173,6 +174,7 @@ cc_library(
"//tensorflow/core:lib",
"@com_google_absl//absl/algorithm:container",
"@com_google_absl//absl/container:inlined_vector",
+ "@com_google_absl//absl/strings",
],
)
@@ -242,6 +244,7 @@ cc_library(
"//tensorflow/core:lib_internal",
"//tensorflow/core:regexp_internal",
"@com_google_absl//absl/container:inlined_vector",
+ "@com_google_absl//absl/strings",
"@com_google_absl//absl/types:optional",
],
)
@@ -259,6 +262,7 @@ tf_cc_test(
":xla_data_proto",
"//tensorflow/core:lib",
"//tensorflow/core:test_main",
+ "@com_google_absl//absl/strings",
],
)
@@ -301,6 +305,7 @@ cc_library(
":xla_data_proto",
"//tensorflow/core:lib",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
@@ -320,6 +325,7 @@ tf_cc_test(
"//tensorflow/core:test",
"//tensorflow/core:test_main",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
@@ -341,6 +347,7 @@ cc_library(
":xla_data_proto",
"//tensorflow/core:lib",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
@@ -359,6 +366,7 @@ cc_library(
":literal_util",
":util",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
],
)
@@ -370,6 +378,7 @@ cc_library(
deps = [
":util",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
],
)
@@ -379,8 +388,8 @@ cc_library(
visibility = ["//visibility:public"],
deps = [
":types",
- "//tensorflow/core:lib",
"//tensorflow/core:stream_executor_no_cuda",
+ "@com_google_absl//absl/strings",
],
)
@@ -391,6 +400,7 @@ cc_library(
":status",
":types",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
],
)
@@ -411,8 +421,10 @@ cc_library(
deps = [
":array",
":types",
+ ":util",
"//tensorflow/core:lib",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
@@ -457,6 +469,7 @@ cc_library(
":array2d",
":types",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
],
)
@@ -510,6 +523,7 @@ cc_library(
"//tensorflow/core:lib",
"//tensorflow/core:regexp_internal",
"//tensorflow/core:test",
+ "@com_google_absl//absl/strings",
],
)
@@ -529,6 +543,7 @@ cc_library(
"//tensorflow/core:lib",
"//tensorflow/core:lib_internal",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
@@ -559,6 +574,7 @@ cc_library(
":types",
":xla_data_proto",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
],
)
@@ -629,6 +645,7 @@ cc_library(
":types",
":xla_data_proto",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
],
)
diff --git a/tensorflow/compiler/xla/array.h b/tensorflow/compiler/xla/array.h
index 2d5d078aa7..90762a8e2a 100644
--- a/tensorflow/compiler/xla/array.h
+++ b/tensorflow/compiler/xla/array.h
@@ -27,12 +27,12 @@ limitations under the License.
#include <type_traits>
#include <vector>
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/status.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/core/lib/core/bits.h"
#include "tensorflow/core/lib/gtl/array_slice.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/macros.h"
#include "tensorflow/core/platform/types.h"
diff --git a/tensorflow/compiler/xla/array2d.h b/tensorflow/compiler/xla/array2d.h
index 340f94fab7..f48244531c 100644
--- a/tensorflow/compiler/xla/array2d.h
+++ b/tensorflow/compiler/xla/array2d.h
@@ -25,11 +25,11 @@ limitations under the License.
#include <vector>
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/array.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/core/lib/core/bits.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/macros.h"
#include "tensorflow/core/platform/types.h"
diff --git a/tensorflow/compiler/xla/array4d.h b/tensorflow/compiler/xla/array4d.h
index a75fffc605..089b3b667c 100644
--- a/tensorflow/compiler/xla/array4d.h
+++ b/tensorflow/compiler/xla/array4d.h
@@ -26,12 +26,12 @@ limitations under the License.
#include <string>
#include <vector>
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/array.h"
#include "tensorflow/compiler/xla/array2d.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/core/lib/gtl/array_slice.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/lib/strings/stringprintf.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/macros.h"
diff --git a/tensorflow/compiler/xla/client/BUILD b/tensorflow/compiler/xla/client/BUILD
index c8b2a1ac73..9ad8ee2014 100644
--- a/tensorflow/compiler/xla/client/BUILD
+++ b/tensorflow/compiler/xla/client/BUILD
@@ -77,6 +77,7 @@ cc_library(
"//tensorflow/compiler/xla/service:hlo_proto",
"//tensorflow/core:lib",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
@@ -90,6 +91,7 @@ cc_library(
"//tensorflow/compiler/xla:xla_data_proto",
"//tensorflow/compiler/xla/service:device_memory_allocator",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
"@com_google_absl//absl/types:optional",
],
)
@@ -216,6 +218,7 @@ cc_library(
"//tensorflow/core:lib",
"@com_google_absl//absl/algorithm:container",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
diff --git a/tensorflow/compiler/xla/client/client.cc b/tensorflow/compiler/xla/client/client.cc
index 25608d6616..1fdf8f6260 100644
--- a/tensorflow/compiler/xla/client/client.cc
+++ b/tensorflow/compiler/xla/client/client.cc
@@ -19,6 +19,7 @@ limitations under the License.
#include <utility>
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/client/xla_computation.h"
#include "tensorflow/compiler/xla/execution_options_util.h"
#include "tensorflow/compiler/xla/legacy_flags/debug_options_flags.h"
@@ -26,7 +27,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/status_macros.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/core/lib/core/errors.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/protobuf.h"
#include "tensorflow/core/platform/types.h"
@@ -400,7 +400,7 @@ StatusOr<string> Client::ExecutionStatsAsString(
int64 nanoseconds = profile.compute_time_ns();
int64 cycle_count = profile.compute_cycle_count();
double gflops = total_flops / nanoseconds;
- return tensorflow::strings::StrCat(
+ return absl::StrCat(
"[Execution Statistics] flop count: ", computation_stats.flop_count(),
", transcendental count: ", computation_stats.transcendental_count(),
", compute execution time: ", nanoseconds, " nsec",
diff --git a/tensorflow/compiler/xla/client/compile_only_client.cc b/tensorflow/compiler/xla/client/compile_only_client.cc
index b6012a0352..040344c9a6 100644
--- a/tensorflow/compiler/xla/client/compile_only_client.cc
+++ b/tensorflow/compiler/xla/client/compile_only_client.cc
@@ -41,7 +41,7 @@ CompileOnlyClient::CompileAheadOfTime(
metadata);
}
-int64 CompileOnlyClient::PointerSizeForTriple(tensorflow::StringPiece triple) {
+int64 CompileOnlyClient::PointerSizeForTriple(absl::string_view triple) {
llvm::Triple llvm_triple(
llvm::Triple::normalize(llvm::StringRef(triple.data(), triple.size())));
if (llvm_triple.isArch64Bit()) {
diff --git a/tensorflow/compiler/xla/client/compile_only_client.h b/tensorflow/compiler/xla/client/compile_only_client.h
index a551edeab0..d0c83cbfcc 100644
--- a/tensorflow/compiler/xla/client/compile_only_client.h
+++ b/tensorflow/compiler/xla/client/compile_only_client.h
@@ -57,7 +57,7 @@ class CompileOnlyClient : public Client {
std::unique_ptr<AotCompilationMetadata>* metadata = nullptr);
// Returns the size of a pointer in bytes for a given triple.
- static int64 PointerSizeForTriple(tensorflow::StringPiece triple);
+ static int64 PointerSizeForTriple(absl::string_view triple);
private:
CompileOnlyService* compiler_service_;
diff --git a/tensorflow/compiler/xla/client/executable_build_options.cc b/tensorflow/compiler/xla/client/executable_build_options.cc
index 5fe28c33df..5a73408db5 100644
--- a/tensorflow/compiler/xla/client/executable_build_options.cc
+++ b/tensorflow/compiler/xla/client/executable_build_options.cc
@@ -77,7 +77,7 @@ const absl::optional<string>& ExecutableBuildOptions::generate_hlo_graph()
}
ExecutableBuildOptions& ExecutableBuildOptions::set_dump_optimized_hlo_proto_to(
- tensorflow::StringPiece dirpath) {
+ absl::string_view dirpath) {
dump_optimized_hlo_proto_to_ = string(dirpath);
return *this;
}
@@ -89,8 +89,8 @@ ExecutableBuildOptions::dump_optimized_hlo_proto_to() const {
ExecutableBuildOptions&
ExecutableBuildOptions::set_dump_unoptimized_hlo_proto_to(
- tensorflow::StringPiece dirpath) {
- dump_unoptimized_hlo_proto_to_ = dirpath.ToString();
+ absl::string_view dirpath) {
+ dump_unoptimized_hlo_proto_to_ = string(dirpath);
return *this;
}
@@ -100,7 +100,7 @@ ExecutableBuildOptions::dump_unoptimized_hlo_proto_to() const {
}
ExecutableBuildOptions& ExecutableBuildOptions::set_dump_per_pass_hlo_proto_to(
- tensorflow::StringPiece dirpath) {
+ absl::string_view dirpath) {
dump_per_pass_hlo_proto_to_ = string(dirpath);
return *this;
}
diff --git a/tensorflow/compiler/xla/client/executable_build_options.h b/tensorflow/compiler/xla/client/executable_build_options.h
index 904d230981..888d2f28eb 100644
--- a/tensorflow/compiler/xla/client/executable_build_options.h
+++ b/tensorflow/compiler/xla/client/executable_build_options.h
@@ -16,11 +16,11 @@ limitations under the License.
#ifndef TENSORFLOW_COMPILER_XLA_CLIENT_EXECUTABLE_BUILD_OPTIONS_H_
#define TENSORFLOW_COMPILER_XLA_CLIENT_EXECUTABLE_BUILD_OPTIONS_H_
+#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "tensorflow/compiler/xla/service/device_memory_allocator.h"
#include "tensorflow/compiler/xla/util.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
namespace xla {
@@ -62,19 +62,19 @@ class ExecutableBuildOptions {
// If set, specifies a dirpath to dump the end-of-optimization-pipeline HLO
// protobuf to (as in DebugOptions).
ExecutableBuildOptions& set_dump_optimized_hlo_proto_to(
- tensorflow::StringPiece dirpath);
+ absl::string_view dirpath);
const absl::optional<string>& dump_optimized_hlo_proto_to() const;
// If set, specifies a dirpath to dump the start-of-optimization-pipeline HLO
// protobuf to (as in DebugOptions).
ExecutableBuildOptions& set_dump_unoptimized_hlo_proto_to(
- tensorflow::StringPiece dirpath);
+ absl::string_view dirpath);
const absl::optional<string>& dump_unoptimized_hlo_proto_to() const;
// If set, specifies a dirpath to dump the per-pass-in-pipeline HLO protobufs
// to (as in DebugOptions).
ExecutableBuildOptions& set_dump_per_pass_hlo_proto_to(
- tensorflow::StringPiece dirpath);
+ absl::string_view dirpath);
const absl::optional<string>& dump_per_pass_hlo_proto_to() const;
// If true, specifies that we should record an HLO profile during execution
@@ -83,7 +83,7 @@ class ExecutableBuildOptions {
ExecutableBuildOptions& set_hlo_profile(bool enabled);
absl::optional<bool> hlo_profile() const;
- void add_disabled_hlo_pass(tensorflow::StringPiece pass_name) {
+ void add_disabled_hlo_pass(absl::string_view pass_name) {
disabled_hlo_passes_.push_back(std::string(pass_name));
}
const tensorflow::gtl::ArraySlice<std::string> disabled_hlo_passes() const {
diff --git a/tensorflow/compiler/xla/client/lib/BUILD b/tensorflow/compiler/xla/client/lib/BUILD
index 4d233741bd..8736f18dcf 100644
--- a/tensorflow/compiler/xla/client/lib/BUILD
+++ b/tensorflow/compiler/xla/client/lib/BUILD
@@ -31,7 +31,7 @@ cc_library(
"//tensorflow/compiler/xla:xla_data_proto",
"//tensorflow/compiler/xla/client:xla_builder",
"//tensorflow/compiler/xla/client:xla_computation",
- "//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
],
)
@@ -221,5 +221,6 @@ cc_library(
"//tensorflow/compiler/xla/client:xla_computation",
"//tensorflow/compiler/xla/tests:test_utils",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
],
)
diff --git a/tensorflow/compiler/xla/client/lib/arithmetic.cc b/tensorflow/compiler/xla/client/lib/arithmetic.cc
index 9225b1acd6..e86c10f030 100644
--- a/tensorflow/compiler/xla/client/lib/arithmetic.cc
+++ b/tensorflow/compiler/xla/client/lib/arithmetic.cc
@@ -17,6 +17,7 @@ limitations under the License.
#include <string>
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/client/lib/constants.h"
#include "tensorflow/compiler/xla/client/xla_builder.h"
#include "tensorflow/compiler/xla/client/xla_computation.h"
@@ -24,7 +25,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/status_macros.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
-#include "tensorflow/core/lib/strings/strcat.h"
namespace xla {
namespace {
@@ -39,7 +39,7 @@ XlaComputation CreateScalarComputation(const string& name, PrimitiveType type,
b = builder->CreateSubBuilder(name);
} else {
b = builder->CreateSubBuilder(
- tensorflow::strings::StrCat(name, "_", PrimitiveType_Name(type)));
+ absl::StrCat(name, "_", PrimitiveType_Name(type)));
}
const Shape scalar = ShapeUtil::MakeShape(type, {});
diff --git a/tensorflow/compiler/xla/client/lib/testing.cc b/tensorflow/compiler/xla/client/lib/testing.cc
index 081fec7ad9..6861521acc 100644
--- a/tensorflow/compiler/xla/client/lib/testing.cc
+++ b/tensorflow/compiler/xla/client/lib/testing.cc
@@ -15,6 +15,7 @@ limitations under the License.
#include "tensorflow/compiler/xla/client/lib/testing.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/client/xla_builder.h"
#include "tensorflow/compiler/xla/execution_options_util.h"
#include "tensorflow/compiler/xla/literal.h"
@@ -23,7 +24,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/tests/test_utils.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/compiler/xla/util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/protobuf.h"
#include "tensorflow/core/platform/types.h"
@@ -61,8 +61,7 @@ XlaOp BuildFakeDataOpOnDevice(const Shape& shape, XlaBuilder* builder) {
std::unique_ptr<GlobalData> MakeFakeDataViaDeviceOrDie(const Shape& shape,
Client* client) {
- XlaBuilder b(
- tensorflow::strings::StrCat("make_fake_", ShapeUtil::HumanString(shape)));
+ XlaBuilder b(absl::StrCat("make_fake_", ShapeUtil::HumanString(shape)));
BuildFakeDataOpOnDevice(shape, &b);
XlaComputation computation = b.Build().ConsumeValueOrDie();
diff --git a/tensorflow/compiler/xla/client/xla_builder.cc b/tensorflow/compiler/xla/client/xla_builder.cc
index 4e7ef66dc5..e88c8b6efc 100644
--- a/tensorflow/compiler/xla/client/xla_builder.cc
+++ b/tensorflow/compiler/xla/client/xla_builder.cc
@@ -23,6 +23,8 @@ limitations under the License.
#include "absl/algorithm/container.h"
#include "absl/memory/memory.h"
+#include "absl/strings/match.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/client/sharding_builder.h"
#include "tensorflow/compiler/xla/client/xla_computation.h"
#include "tensorflow/compiler/xla/execution_options_util.h"
@@ -31,12 +33,11 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/shape_inference.h"
#include "tensorflow/compiler/xla/util.h"
#include "tensorflow/core/lib/gtl/flatset.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/mutex.h"
namespace xla {
-using tensorflow::strings::StrCat;
+using absl::StrCat;
namespace {
@@ -223,8 +224,7 @@ XlaComputation XlaBuilder::BuildAndNoteError() {
auto build_status = Build();
if (!build_status.ok()) {
parent_builder_->ReportError(
- AddStatus(build_status.status(),
- tensorflow::strings::StrCat("error from: ", name_)));
+ AddStatus(build_status.status(), absl::StrCat("error from: ", name_)));
return {};
}
return build_status.ConsumeValueOrDie();
@@ -1013,7 +1013,7 @@ StatusOr<Window> XlaBuilder::MakeWindow(
return Status::OK();
} else {
return InvalidArgument(
- "%s", tensorflow::strings::StrCat(
+ "%s", absl::StrCat(
"Window has different number of window dimensions than of ",
x_name,
"\nNumber of window dimensions: ", window_dimensions.size(),
@@ -1283,7 +1283,7 @@ XlaOp XlaBuilder::CustomCall(const string& call_target_name,
const Shape& shape) {
return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> {
HloInstructionProto instr;
- if (tensorflow::str_util::StartsWith(call_target_name, "$")) {
+ if (absl::StartsWith(call_target_name, "$")) {
return InvalidArgument(
"Invalid custom_call_target \"%s\": Call targets that start with '$' "
"are reserved for internal use.",
diff --git a/tensorflow/compiler/xla/client/xla_builder.h b/tensorflow/compiler/xla/client/xla_builder.h
index 3dbf1e5bee..baa2ae5184 100644
--- a/tensorflow/compiler/xla/client/xla_builder.h
+++ b/tensorflow/compiler/xla/client/xla_builder.h
@@ -21,6 +21,7 @@ limitations under the License.
#include <type_traits>
#include <utility>
+#include "absl/strings/string_view.h"
#include "tensorflow/compiler/xla/client/padding.h"
#include "tensorflow/compiler/xla/client/xla_computation.h"
#include "tensorflow/compiler/xla/literal.h"
@@ -32,7 +33,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/statusor.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/gtl/array_slice.h"
#include "tensorflow/core/lib/gtl/flatset.h"
#include "tensorflow/core/platform/macros.h"
diff --git a/tensorflow/compiler/xla/device_util.h b/tensorflow/compiler/xla/device_util.h
index 1a51fdee68..6d51126d88 100644
--- a/tensorflow/compiler/xla/device_util.h
+++ b/tensorflow/compiler/xla/device_util.h
@@ -21,8 +21,8 @@ limitations under the License.
#include <string>
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/types.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/stream_executor_no_cuda.h"
namespace xla {
@@ -30,8 +30,8 @@ namespace xla {
// Returns a string that represents the device in terms of platform and ordinal;
// e.g. the first CUDA device will be "cuda:0"
string DeviceIdentifier(se::StreamExecutor* stream_exec) {
- return tensorflow::strings::StrCat(stream_exec->platform()->Name(), ":",
- stream_exec->device_ordinal());
+ return absl::StrCat(stream_exec->platform()->Name(), ":",
+ stream_exec->device_ordinal());
}
} // namespace xla
diff --git a/tensorflow/compiler/xla/layout_util.cc b/tensorflow/compiler/xla/layout_util.cc
index b72d190d54..8afdc0d1b1 100644
--- a/tensorflow/compiler/xla/layout_util.cc
+++ b/tensorflow/compiler/xla/layout_util.cc
@@ -23,6 +23,7 @@ limitations under the License.
#include <unordered_map>
#include <vector>
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/protobuf_util.h"
#include "tensorflow/compiler/xla/shape_util.h"
#include "tensorflow/compiler/xla/status_macros.h"
@@ -32,7 +33,6 @@ limitations under the License.
#include "tensorflow/core/lib/hash/hash.h"
#include "tensorflow/core/lib/strings/numbers.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/protobuf.h"
@@ -403,11 +403,10 @@ Layout CreateDefaultLayoutForRank(int64 rank) {
/* static */ string LayoutUtil::HumanString(const Layout& layout) {
if (IsSparse(layout)) {
- return tensorflow::strings::StrCat("sparse{", layout.max_sparse_elements(),
- "}");
+ return absl::StrCat("sparse{", layout.max_sparse_elements(), "}");
}
CHECK(IsDense(layout));
- return tensorflow::strings::StrCat(
+ return absl::StrCat(
"{", tensorflow::str_util::Join(layout.minor_to_major(), ","), "}");
}
diff --git a/tensorflow/compiler/xla/legacy_flags/BUILD b/tensorflow/compiler/xla/legacy_flags/BUILD
index 89353448e2..989035896b 100644
--- a/tensorflow/compiler/xla/legacy_flags/BUILD
+++ b/tensorflow/compiler/xla/legacy_flags/BUILD
@@ -56,6 +56,7 @@ cc_library(
"//tensorflow/compiler/xla/service:hlo",
"//tensorflow/core:framework_internal",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
],
)
@@ -73,5 +74,6 @@ tf_cc_test(
"//tensorflow/core:framework_internal",
"//tensorflow/core:lib",
"//tensorflow/core:test",
+ "@com_google_absl//absl/strings",
],
)
diff --git a/tensorflow/compiler/xla/legacy_flags/debug_options_flags.cc b/tensorflow/compiler/xla/legacy_flags/debug_options_flags.cc
index 5d27e4a46b..7ab331df7d 100644
--- a/tensorflow/compiler/xla/legacy_flags/debug_options_flags.cc
+++ b/tensorflow/compiler/xla/legacy_flags/debug_options_flags.cc
@@ -17,6 +17,7 @@ limitations under the License.
#include <mutex> // NOLINT(build/c++11): only using std::call_once, not mutex.
#include <vector>
+#include "absl/strings/str_split.h"
#include "tensorflow/compiler/xla/legacy_flags/debug_options_parsers.h"
#include "tensorflow/compiler/xla/legacy_flags/parse_flags_from_env.h"
#include "tensorflow/core/lib/strings/str_util.h"
@@ -87,7 +88,7 @@ void AllocateFlags() {
// Custom "sub-parser" lambda for xla_disable_hlo_passes.
auto setter_for_xla_disable_hlo_passes = [](string comma_separated_values) {
std::vector<string> disabled_passes =
- tensorflow::str_util::Split(comma_separated_values, ',');
+ absl::StrSplit(comma_separated_values, ',');
for (const auto& passname : disabled_passes) {
flag_values->add_xla_disable_hlo_passes(passname);
}
diff --git a/tensorflow/compiler/xla/legacy_flags/debug_options_parsers.h b/tensorflow/compiler/xla/legacy_flags/debug_options_parsers.h
index e9cf435d83..7696b66bd3 100644
--- a/tensorflow/compiler/xla/legacy_flags/debug_options_parsers.h
+++ b/tensorflow/compiler/xla/legacy_flags/debug_options_parsers.h
@@ -17,6 +17,7 @@ limitations under the License.
#define TENSORFLOW_COMPILER_XLA_LEGACY_FLAGS_DEBUG_OPTIONS_PARSERS_H_
#include <vector>
+#include "absl/strings/str_split.h"
#include "tensorflow/compiler/xla/service/hlo_opcode.h"
#include "tensorflow/compiler/xla/xla.pb.h"
#include "tensorflow/core/lib/strings/str_util.h"
@@ -30,7 +31,7 @@ template <typename T>
void parse_xla_backend_extra_options(T* extra_options_map,
string comma_separated_values) {
std::vector<string> extra_options_parts =
- tensorflow::str_util::Split(comma_separated_values, ',');
+ absl::StrSplit(comma_separated_values, ',');
// The flag contains a comma-separated list of options; some options
// have arguments following "=", some don't.
@@ -59,8 +60,7 @@ void parse_xla_backend_extra_options(T* extra_options_map,
inline bool parse_xla_reduce_precision_option(
HloReducePrecisionOptions* options, string option_string) {
// Split off "LOCATION" from remainder of string.
- std::vector<string> eq_split =
- tensorflow::str_util::Split(option_string, '=');
+ std::vector<string> eq_split = absl::StrSplit(option_string, '=');
if (eq_split.size() != 2) {
return false;
}
@@ -80,8 +80,7 @@ inline bool parse_xla_reduce_precision_option(
}
// Split off "E,M" from remainder of string.
- std::vector<string> colon_split =
- tensorflow::str_util::Split(eq_split[1], ':');
+ std::vector<string> colon_split = absl::StrSplit(eq_split[1], ':');
if (colon_split.size() != 2) {
return false;
}
@@ -98,8 +97,7 @@ inline bool parse_xla_reduce_precision_option(
// Split off OPS comma-separated list from remainder of string, if the
// remainder exists.
- std::vector<string> semicolon_split =
- tensorflow::str_util::Split(colon_split[1], ';');
+ std::vector<string> semicolon_split = absl::StrSplit(colon_split[1], ';');
if (semicolon_split.size() > 2) {
return false;
}
@@ -113,8 +111,7 @@ inline bool parse_xla_reduce_precision_option(
options->add_opcodes_to_suffix(i);
}
} else {
- std::vector<string> opcodes =
- tensorflow::str_util::Split(opcode_string, ',');
+ std::vector<string> opcodes = absl::StrSplit(opcode_string, ',');
for (const string& opcode : opcodes) {
bool found = false;
for (int i = 0; i < HloOpcodeCount(); i++) {
@@ -132,8 +129,7 @@ inline bool parse_xla_reduce_precision_option(
// Process the NAMES string, if it exists.
if (semicolon_split.size() == 2) {
- std::vector<string> opnames =
- tensorflow::str_util::Split(semicolon_split[1], ',');
+ std::vector<string> opnames = absl::StrSplit(semicolon_split[1], ',');
for (const string& opname : opnames) {
if (opname.length() > 0) {
options->add_opname_substrings_to_suffix(opname);
diff --git a/tensorflow/compiler/xla/literal.cc b/tensorflow/compiler/xla/literal.cc
index d54f051a1a..cef42d8ad8 100644
--- a/tensorflow/compiler/xla/literal.cc
+++ b/tensorflow/compiler/xla/literal.cc
@@ -23,6 +23,7 @@ limitations under the License.
#include <vector>
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/index_util.h"
#include "tensorflow/compiler/xla/shape_util.h"
#include "tensorflow/compiler/xla/status_macros.h"
@@ -32,13 +33,12 @@ limitations under the License.
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/hash/hash.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/lib/strings/stringprintf.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/types.h"
+using absl::StrCat;
using tensorflow::strings::Printf;
-using tensorflow::strings::StrCat;
namespace xla {
diff --git a/tensorflow/compiler/xla/literal.h b/tensorflow/compiler/xla/literal.h
index ed9de65299..aad435ed5b 100644
--- a/tensorflow/compiler/xla/literal.h
+++ b/tensorflow/compiler/xla/literal.h
@@ -26,6 +26,7 @@ limitations under the License.
#include <vector>
#include "absl/memory/memory.h"
+#include "absl/strings/string_view.h"
#include "tensorflow/compiler/xla/array2d.h"
#include "tensorflow/compiler/xla/array3d.h"
#include "tensorflow/compiler/xla/array4d.h"
@@ -40,7 +41,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/xla_data.pb.h"
#include "tensorflow/core/lib/core/bitmap.h"
#include "tensorflow/core/lib/core/status.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/gtl/array_slice.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/macros.h"
diff --git a/tensorflow/compiler/xla/literal_comparison.cc b/tensorflow/compiler/xla/literal_comparison.cc
index 6883a6bbab..a36e81bc90 100644
--- a/tensorflow/compiler/xla/literal_comparison.cc
+++ b/tensorflow/compiler/xla/literal_comparison.cc
@@ -19,16 +19,16 @@ limitations under the License.
#include <cmath>
#include <vector>
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/literal_util.h"
#include "tensorflow/compiler/xla/util.h"
#include "tensorflow/core/lib/core/casts.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/env.h"
+using absl::StrAppend;
+using absl::StrCat;
using tensorflow::strings::Appendf;
using tensorflow::strings::Printf;
-using tensorflow::strings::StrAppend;
-using tensorflow::strings::StrCat;
namespace xla {
namespace literal_comparison {
diff --git a/tensorflow/compiler/xla/literal_test.cc b/tensorflow/compiler/xla/literal_test.cc
index c5d0c2c267..aef87e46d8 100644
--- a/tensorflow/compiler/xla/literal_test.cc
+++ b/tensorflow/compiler/xla/literal_test.cc
@@ -18,6 +18,8 @@ limitations under the License.
#include <vector>
#include "absl/memory/memory.h"
+#include "absl/strings/match.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/tf2xla/shape_util.h"
#include "tensorflow/compiler/xla/array3d.h"
#include "tensorflow/compiler/xla/array4d.h"
@@ -1324,8 +1326,8 @@ TEST_F(LiteralUtilTest, BitcastConvertBetweenInvalidTypes) {
auto literal = LiteralUtil::CreateR0<uint32>(1234);
Status status = literal->BitcastConvert(F64).status();
EXPECT_NE(Status::OK(), status);
- EXPECT_TRUE(tensorflow::str_util::StrContains(status.error_message(),
- "bit widths are different"));
+ EXPECT_TRUE(
+ absl::StrContains(status.error_message(), "bit widths are different"));
}
TEST_F(LiteralUtilTest, CopyFromProto_Bool) {
@@ -1819,21 +1821,20 @@ TEST_F(LiteralUtilTest, GetSparseElementAsString) {
"false");
ASSERT_EQ(LiteralUtil::CreateSparse<int64>(dimensions, indices, {1, 2, 3})
->GetSparseElementAsString(1),
- tensorflow::strings::StrCat(int64{2}));
+ absl::StrCat(int64{2}));
ASSERT_EQ(
LiteralUtil::CreateSparse<double>(dimensions, indices, {1.0, 2.0, 3.0})
->GetSparseElementAsString(1),
- tensorflow::strings::StrCat(double{2.0}));
+ absl::StrCat(double{2.0}));
ASSERT_EQ(LiteralUtil::CreateSparse<half>(dimensions, indices,
{half{1.0}, half{2.0}, half{3.0}})
->GetSparseElementAsString(1),
- tensorflow::strings::StrCat(static_cast<float>(half{2.0})));
- ASSERT_EQ(
- LiteralUtil::CreateSparse<complex64>(
- dimensions, indices,
- std::vector<complex64>{{1.0, 2.0}, {3.0, 4.0}, {5.0, 6.0}})
- ->GetSparseElementAsString(1),
- tensorflow::strings::StrCat("(", float{3.0}, ", ", float{4.0}, ")"));
+ absl::StrCat(static_cast<float>(half{2.0})));
+ ASSERT_EQ(LiteralUtil::CreateSparse<complex64>(
+ dimensions, indices,
+ std::vector<complex64>{{1.0, 2.0}, {3.0, 4.0}, {5.0, 6.0}})
+ ->GetSparseElementAsString(1),
+ absl::StrCat("(", float{3.0}, ", ", float{4.0}, ")"));
}
TEST_F(LiteralUtilTest, BroadcastVectorToMatrix0) {
diff --git a/tensorflow/compiler/xla/literal_util.cc b/tensorflow/compiler/xla/literal_util.cc
index d4c7b76b28..721a7d502b 100644
--- a/tensorflow/compiler/xla/literal_util.cc
+++ b/tensorflow/compiler/xla/literal_util.cc
@@ -23,6 +23,7 @@ limitations under the License.
#include <vector>
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/index_util.h"
#include "tensorflow/compiler/xla/shape_util.h"
#include "tensorflow/compiler/xla/status_macros.h"
@@ -32,13 +33,12 @@ limitations under the License.
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/hash/hash.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/lib/strings/stringprintf.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/mem.h"
#include "tensorflow/core/platform/types.h"
-using tensorflow::strings::StrCat;
+using absl::StrCat;
namespace xla {
@@ -287,7 +287,7 @@ std::unique_ptr<Literal> ConvertType(LiteralSlice literal) {
}
/* static */ std::unique_ptr<Literal> LiteralUtil::CreateR1U8(
- tensorflow::StringPiece value) {
+ absl::string_view value) {
auto literal = absl::make_unique<Literal>(
ShapeUtil::MakeShape(U8, {static_cast<int64>(value.size())}));
for (int i = 0; i < value.size(); ++i) {
diff --git a/tensorflow/compiler/xla/literal_util.h b/tensorflow/compiler/xla/literal_util.h
index 1109021ea8..3d28c070f2 100644
--- a/tensorflow/compiler/xla/literal_util.h
+++ b/tensorflow/compiler/xla/literal_util.h
@@ -28,6 +28,7 @@ limitations under the License.
#include <vector>
#include "absl/memory/memory.h"
+#include "absl/strings/string_view.h"
#include "tensorflow/compiler/xla/array2d.h"
#include "tensorflow/compiler/xla/array3d.h"
#include "tensorflow/compiler/xla/array4d.h"
@@ -43,7 +44,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/xla_data.pb.h"
#include "tensorflow/core/lib/core/bitmap.h"
#include "tensorflow/core/lib/core/status.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/gtl/array_slice.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/macros.h"
@@ -187,7 +187,7 @@ class LiteralUtil {
const Array4D<NativeT>& values, const Layout& layout);
// Creates a new vector of U8s literal value from a string.
- static std::unique_ptr<Literal> CreateR1U8(tensorflow::StringPiece value);
+ static std::unique_ptr<Literal> CreateR1U8(absl::string_view value);
// Creates a linspace-populated literal with the given number of rows and
// columns.
diff --git a/tensorflow/compiler/xla/metric_table_report.cc b/tensorflow/compiler/xla/metric_table_report.cc
index 69ef4f7a2f..2f22e02c3e 100644
--- a/tensorflow/compiler/xla/metric_table_report.cc
+++ b/tensorflow/compiler/xla/metric_table_report.cc
@@ -18,6 +18,7 @@ limitations under the License.
#include <cctype>
#include <unordered_map>
+#include "absl/strings/str_cat.h"
#include "tensorflow/core/lib/strings/stringprintf.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/types.h"
@@ -84,7 +85,7 @@ void MetricTableReport::WriteReportToInfoLog(double expected_metric_sum) {
if (end_of_line == string::npos) {
end_of_line = report.size();
}
- tensorflow::StringPiece line(report.data() + pos, end_of_line - pos);
+ absl::string_view line(report.data() + pos, end_of_line - pos);
// TODO(b/34779244): Figure out how to do this without the verbose log-line
// prefix. The usual way didn't compile on open source.
@@ -152,8 +153,8 @@ void MetricTableReport::AppendCategoryTable() {
if (text.empty()) {
text = "[no category]";
}
- tensorflow::strings::StrAppend(&text, " (", category.entries.size(), " ",
- entry_name_, ")");
+ absl::StrAppend(&text, " (", category.entries.size(), " ", entry_name_,
+ ")");
AppendTableRow(text, category.metric_sum, metric_sum);
// Show the top entries in the category.
@@ -177,9 +178,9 @@ void MetricTableReport::AppendCategoryTable() {
}
const int64 remaining_categories = categories.size() - categories_shown;
if (remaining_categories > 0) {
- AppendTableRow(tensorflow::strings::StrCat("... (", remaining_categories,
- " more categories)"),
- expected_metric_sum_ - metric_sum, expected_metric_sum_);
+ AppendTableRow(
+ absl::StrCat("... (", remaining_categories, " more categories)"),
+ expected_metric_sum_ - metric_sum, expected_metric_sum_);
}
}
@@ -206,9 +207,9 @@ void MetricTableReport::AppendEntryTable() {
}
const int64 remaining_entries = entries_.size() - entries_shown;
if (remaining_entries > 0) {
- AppendTableRow(tensorflow::strings::StrCat("... (", remaining_entries,
- " more ", entry_name_, ")"),
- expected_metric_sum_ - metric_sum, expected_metric_sum_);
+ AppendTableRow(
+ absl::StrCat("... (", remaining_entries, " more ", entry_name_, ")"),
+ expected_metric_sum_ - metric_sum, expected_metric_sum_);
}
}
@@ -241,10 +242,10 @@ double MetricTableReport::UnaccountedMetric() {
string MetricTableReport::MetricString(double metric) {
// Round to integer and stringify.
- string s1 = tensorflow::strings::StrCat(std::llround(metric));
+ string s1 = absl::StrCat(std::llround(metric));
// Code below commafies the string, e.g. "1234" becomes "1,234".
- tensorflow::StringPiece sp1(s1);
+ absl::string_view sp1(s1);
string output;
// Copy leading non-digit characters unconditionally.
// This picks up the leading sign.
diff --git a/tensorflow/compiler/xla/metric_table_report.h b/tensorflow/compiler/xla/metric_table_report.h
index 818fb1d3fe..397d969b7a 100644
--- a/tensorflow/compiler/xla/metric_table_report.h
+++ b/tensorflow/compiler/xla/metric_table_report.h
@@ -18,9 +18,9 @@ limitations under the License.
#include <vector>
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/util.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
namespace xla {
@@ -108,7 +108,7 @@ class MetricTableReport {
// Append all parameters to the report.
template <typename... Args>
void AppendLine(Args... args) {
- tensorflow::strings::StrAppend(&report_, std::forward<Args>(args)..., "\n");
+ absl::StrAppend(&report_, std::forward<Args>(args)..., "\n");
}
// Represents a set of entries with the same category_text.
diff --git a/tensorflow/compiler/xla/python/BUILD b/tensorflow/compiler/xla/python/BUILD
index a91336c3ac..2d8fe434b0 100644
--- a/tensorflow/compiler/xla/python/BUILD
+++ b/tensorflow/compiler/xla/python/BUILD
@@ -39,6 +39,7 @@ cc_library(
"//tensorflow/compiler/xla:xla_data_proto",
"//tensorflow/core:lib",
"//tensorflow/python:numpy_lib",
+ "@com_google_absl//absl/strings",
],
)
diff --git a/tensorflow/compiler/xla/python/local_computation_builder.i b/tensorflow/compiler/xla/python/local_computation_builder.i
index e1060d54e2..08dccb3ee1 100644
--- a/tensorflow/compiler/xla/python/local_computation_builder.i
+++ b/tensorflow/compiler/xla/python/local_computation_builder.i
@@ -109,6 +109,7 @@ limitations under the License.
// Must be included first
#include "tensorflow/python/lib/core/numpy.h"
+#include "third_party/absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/literal.h"
#include "tensorflow/compiler/xla/shape_util.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
@@ -896,7 +897,7 @@ tensorflow::ImportNumpy();
if (o != Py_None) {
StatusOr<Shape> statusor = numpy::XlaShapeFromPyShape(o);
if (!statusor.ok()) {
- PyErr_SetString(PyExc_TypeError, tensorflow::strings::StrCat("ExecutableBuildOptions.result_shape could not be created from Python shape value: ", statusor.status().ToString()).c_str());
+ PyErr_SetString(PyExc_TypeError, absl::StrCat("ExecutableBuildOptions.result_shape could not be created from Python shape value: ", statusor.status().ToString()).c_str());
Py_DECREF(o);
SWIG_fail;
}
diff --git a/tensorflow/compiler/xla/python/numpy_bridge.cc b/tensorflow/compiler/xla/python/numpy_bridge.cc
index 4b9970eadc..f2f99c1745 100644
--- a/tensorflow/compiler/xla/python/numpy_bridge.cc
+++ b/tensorflow/compiler/xla/python/numpy_bridge.cc
@@ -14,6 +14,7 @@ limitations under the License.
==============================================================================*/
#include "tensorflow/compiler/xla/python/numpy_bridge.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/literal_util.h"
#include "tensorflow/compiler/xla/shape_util.h"
#include "tensorflow/core/platform/logging.h"
@@ -191,8 +192,8 @@ StatusOr<Shape> XlaShapeFromPyShape(PyObject* o) {
PyObject* result =
PyObject_CallMethod(o, const_cast<char*>(method.c_str()), nullptr);
if (result == nullptr) {
- return error(tensorflow::strings::StrCat(
- "Failed to call method of shape object:", method));
+ return error(
+ absl::StrCat("Failed to call method of shape object:", method));
}
return result;
};
diff --git a/tensorflow/compiler/xla/service/BUILD b/tensorflow/compiler/xla/service/BUILD
index 32723849a6..cfc6853fe5 100644
--- a/tensorflow/compiler/xla/service/BUILD
+++ b/tensorflow/compiler/xla/service/BUILD
@@ -176,6 +176,7 @@ cc_library(
"//tensorflow/compiler/xla:xla_data_proto",
"//tensorflow/core:lib",
"@com_google_absl//absl/algorithm:container",
+ "@com_google_absl//absl/strings",
],
)
@@ -241,6 +242,7 @@ cc_library(
"@com_google_absl//absl/algorithm:container",
"@com_google_absl//absl/container:inlined_vector",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
"@com_google_absl//absl/types:optional",
],
)
@@ -320,6 +322,7 @@ cc_library(
"@com_google_absl//absl/algorithm:container",
"@com_google_absl//absl/container:inlined_vector",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
@@ -346,7 +349,7 @@ cc_library(
deps = [
":hlo",
"//tensorflow/compiler/xla:shape_util",
- "//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
],
)
@@ -460,6 +463,7 @@ cc_library(
"//tensorflow/compiler/xla:util",
"//tensorflow/core:lib",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
@@ -587,6 +591,7 @@ cc_library(
"//tensorflow/core:stream_executor_no_cuda",
"//third_party/eigen3",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
@@ -629,6 +634,7 @@ cc_library(
"//tensorflow/core:ptr_util",
"//tensorflow/core:stream_executor_no_cuda",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
alwayslink = 1,
)
@@ -662,6 +668,7 @@ cc_library(
"//tensorflow/core:lib",
"//tensorflow/core:stream_executor_no_cuda",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
@@ -684,6 +691,7 @@ cc_library(
"//tensorflow/core:lib",
"//tensorflow/core:lib_internal",
"//tensorflow/core:stream_executor_no_cuda",
+ "@com_google_absl//absl/strings",
],
)
@@ -735,6 +743,7 @@ cc_library(
"//tensorflow/core:lib",
"//tensorflow/core:stream_executor_no_cuda",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
@@ -832,6 +841,7 @@ cc_library(
"//tensorflow/core:lib",
"//tensorflow/core:stream_executor_no_cuda",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
@@ -851,6 +861,7 @@ cc_library(
"//tensorflow/compiler/xla:xla_data_proto",
"//tensorflow/core:lib",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
@@ -886,6 +897,7 @@ cc_library(
"//tensorflow/core:lib",
"//tensorflow/core:lib_internal",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
@@ -896,6 +908,7 @@ cc_library(
deps = [
"//tensorflow/compiler/xla:types",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
],
)
@@ -974,6 +987,7 @@ cc_library(
"//tensorflow/core:lib",
"//tensorflow/core:lib_internal",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
@@ -1113,6 +1127,7 @@ cc_library(
"//tensorflow/compiler/xla:util",
"//tensorflow/core:lib",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
@@ -1199,6 +1214,7 @@ cc_library(
"//tensorflow/compiler/xla/service:hlo",
"//tensorflow/compiler/xla/service:hlo_pass",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
],
)
@@ -1215,6 +1231,7 @@ cc_library(
"//tensorflow/compiler/xla:util",
"@com_google_absl//absl/algorithm:container",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
@@ -1330,6 +1347,7 @@ cc_library(
"//tensorflow/core:lib",
"@com_google_absl//absl/algorithm:container",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
"@com_google_absl//absl/types:optional",
],
)
@@ -1355,6 +1373,7 @@ tf_cc_test(
"//tensorflow/core:lib",
"//tensorflow/core:test",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
@@ -1419,6 +1438,7 @@ cc_library(
"//tensorflow/compiler/xla:types",
"//tensorflow/compiler/xla:util",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
],
)
@@ -1457,6 +1477,7 @@ cc_library(
"//tensorflow/compiler/xla:xla_data_proto",
"//tensorflow/core:lib",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
@@ -1497,6 +1518,7 @@ cc_library(
":while_loop_analysis",
"//tensorflow/compiler/xla:statusor",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
"@com_google_absl//absl/types:optional",
],
)
@@ -1511,6 +1533,7 @@ tf_cc_test(
"//tensorflow/compiler/xla/tests:hlo_verified_test_base",
"//tensorflow/core:lib",
"//tensorflow/core:test",
+ "@com_google_absl//absl/strings",
],
)
@@ -1701,6 +1724,7 @@ cc_library(
"//tensorflow/core:lib",
"//tensorflow/core:stream_executor_no_cuda",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
alwayslink = True, # Contains per-platform computation placer registration
)
@@ -1714,6 +1738,7 @@ cc_library(
"//tensorflow/compiler/xla:types",
"//tensorflow/compiler/xla:util",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
],
)
@@ -1807,6 +1832,7 @@ tf_cc_test(
"//tensorflow/compiler/xla/tests:hlo_test_base",
"//tensorflow/compiler/xla/tests:xla_internal_test_main",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
],
)
@@ -1839,6 +1865,7 @@ tf_cc_binary(
"//tensorflow/compiler/xla:xla_data_proto",
"//tensorflow/core:lib",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
@@ -1871,6 +1898,7 @@ cc_library(
"//tensorflow/compiler/xla:xla_data_proto",
"//tensorflow/core:lib",
"//tensorflow/core:lib_internal",
+ "@com_google_absl//absl/strings",
],
)
@@ -1898,6 +1926,7 @@ cc_library(
"//tensorflow/compiler/xla:xla_data_proto",
"//tensorflow/core:lib",
"//tensorflow/core:lib_internal",
+ "@com_google_absl//absl/strings",
],
)
@@ -1916,6 +1945,7 @@ cc_library(
"//tensorflow/compiler/xla:xla_data_proto",
"//tensorflow/core:lib",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
@@ -1936,6 +1966,7 @@ cc_library(
"//tensorflow/core:lib",
"@com_google_absl//absl/container:inlined_vector",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
@@ -1978,6 +2009,7 @@ cc_library(
"//tensorflow/compiler/xla:util",
"//tensorflow/core:lib",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
@@ -2014,6 +2046,7 @@ cc_library(
"//tensorflow/compiler/xla:util",
"//tensorflow/compiler/xla:xla_data_proto",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
],
)
@@ -2034,6 +2067,7 @@ cc_library(
"//tensorflow/compiler/xla:util",
"//tensorflow/compiler/xla:xla_data_proto",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
],
)
@@ -2093,6 +2127,7 @@ cc_library(
"//tensorflow/core:lib",
"@com_google_absl//absl/container:inlined_vector",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
@@ -2144,6 +2179,7 @@ cc_library(
"//tensorflow/compiler/xla:xla_data_proto",
"//tensorflow/core:lib",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
@@ -2166,6 +2202,7 @@ cc_library(
"//tensorflow/compiler/xla:types",
"//tensorflow/compiler/xla:util",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
],
)
@@ -2278,6 +2315,7 @@ cc_library(
"//tensorflow/compiler/xla:util",
"//tensorflow/core:lib",
"@com_google_absl//absl/container:inlined_vector",
+ "@com_google_absl//absl/strings",
],
)
@@ -2400,6 +2438,7 @@ cc_library(
"//tensorflow/compiler/xla:util",
"//tensorflow/core:lib",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
@@ -2633,6 +2672,7 @@ cc_library(
"//tensorflow/core:lib",
"//tensorflow/core:lib_internal",
"@com_google_absl//absl/algorithm:container",
+ "@com_google_absl//absl/strings",
"@llvm//:core",
"@llvm//:transform_utils",
],
@@ -2668,6 +2708,7 @@ cc_library(
"//tensorflow/compiler/xla:xla_proto",
"//tensorflow/core:lib",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
"@com_google_absl//absl/types:optional",
],
)
@@ -2681,6 +2722,7 @@ cc_library(
"//tensorflow/compiler/xla:types",
"//tensorflow/compiler/xla:xla_data_proto",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
],
)
@@ -2719,6 +2761,7 @@ cc_library(
"//tensorflow/core:framework",
"//tensorflow/core:lib",
"//tensorflow/core:protos_all_cc",
+ "@com_google_absl//absl/strings",
],
)
@@ -2752,6 +2795,7 @@ cc_library(
"//tensorflow/core:lib",
"//tensorflow/core:lib_internal",
"//tensorflow/core:regexp_internal",
+ "@com_google_absl//absl/strings",
"@com_google_absl//absl/types:optional",
],
alwayslink = 1,
@@ -2769,6 +2813,7 @@ tf_cc_test(
"//tensorflow/compiler/xla/tests:test_utils",
"//tensorflow/compiler/xla/tests:xla_internal_test_main", # fixdeps: keep
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
],
)
@@ -2997,8 +3042,8 @@ cc_library(
":hlo_creation_utils",
":tuple_util",
"//tensorflow/compiler/xla:literal_util",
- "//tensorflow/core:lib",
"@com_google_absl//absl/algorithm:container",
+ "@com_google_absl//absl/strings",
],
)
@@ -3114,6 +3159,7 @@ cc_library(
"//tensorflow/core:ptr_util",
"@com_google_absl//absl/algorithm:container",
"@com_google_absl//absl/container:inlined_vector",
+ "@com_google_absl//absl/strings",
"@com_google_absl//absl/types:optional",
],
)
@@ -3150,6 +3196,7 @@ cc_library(
"//tensorflow/core:lib_internal",
"@com_google_absl//absl/algorithm:container",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
@@ -3164,6 +3211,7 @@ tf_cc_test(
"//tensorflow/core:lib",
"//tensorflow/core:test",
"//tensorflow/core:test_main", # fixdeps: keep
+ "@com_google_absl//absl/strings",
],
)
@@ -3182,6 +3230,7 @@ cc_library(
"//tensorflow/compiler/xla:xla_data_proto",
"//tensorflow/core:lib",
"//tensorflow/core:regexp_internal",
+ "@com_google_absl//absl/strings",
"@com_google_absl//absl/types:optional",
],
)
diff --git a/tensorflow/compiler/xla/service/algebraic_simplifier.cc b/tensorflow/compiler/xla/service/algebraic_simplifier.cc
index b86b7d2e71..c236453fc7 100644
--- a/tensorflow/compiler/xla/service/algebraic_simplifier.cc
+++ b/tensorflow/compiler/xla/service/algebraic_simplifier.cc
@@ -24,6 +24,7 @@ limitations under the License.
#include "absl/algorithm/container.h"
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "absl/types/optional.h"
#include "tensorflow/compiler/xla/layout_util.h"
#include "tensorflow/compiler/xla/literal.h"
@@ -1989,9 +1990,9 @@ Status AlgebraicSimplifierVisitor::HandleReduceWindow(
VLOG(10) << "Considering folding Pad: " << pad->ToString()
<< "\ninto reduce-window: " << reduce_window->ToString()
- << (convert != nullptr ? tensorflow::strings::StrCat(
- "\nvia convert: ", convert->ToString())
- : "");
+ << (convert != nullptr
+ ? absl::StrCat("\nvia convert: ", convert->ToString())
+ : "");
// Do not fold interior padding into ReduceWindow since the backends do not
// support it.
diff --git a/tensorflow/compiler/xla/service/algebraic_simplifier.h b/tensorflow/compiler/xla/service/algebraic_simplifier.h
index c48196e861..b864c372fa 100644
--- a/tensorflow/compiler/xla/service/algebraic_simplifier.h
+++ b/tensorflow/compiler/xla/service/algebraic_simplifier.h
@@ -47,7 +47,7 @@ class AlgebraicSimplifier : public HloPassInterface {
enable_dot_strength_reduction_(enable_dot_strength_reduction),
enable_conv_simplification_(enable_conv_simplification) {}
~AlgebraicSimplifier() override = default;
- tensorflow::StringPiece name() const override { return "algsimp"; }
+ absl::string_view name() const override { return "algsimp"; }
// Run algebraic simplification on the given computation. Returns whether the
// computation was changed.
diff --git a/tensorflow/compiler/xla/service/algebraic_simplifier_test.cc b/tensorflow/compiler/xla/service/algebraic_simplifier_test.cc
index 427069af5f..8fff4523ba 100644
--- a/tensorflow/compiler/xla/service/algebraic_simplifier_test.cc
+++ b/tensorflow/compiler/xla/service/algebraic_simplifier_test.cc
@@ -19,6 +19,7 @@ limitations under the License.
#include <utility>
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/layout_util.h"
#include "tensorflow/compiler/xla/literal.h"
#include "tensorflow/compiler/xla/service/hlo_computation.h"
@@ -2143,7 +2144,7 @@ TEST_F(AlgebraicSimplifierTest, ConvertConvToMatmul) {
root->operand(0)->opcode() == HloOpcode::kDot) {
auto lhs_shape = root->operand(0)->operand(0)->shape();
auto rhs_shape = root->operand(0)->operand(1)->shape();
- return tensorflow::strings::StrCat(
+ return absl::StrCat(
tensorflow::str_util::Join(lhs_shape.dimensions(), "x"), " DOT ",
tensorflow::str_util::Join(rhs_shape.dimensions(), "x"));
}
@@ -2660,11 +2661,11 @@ struct PadReduceWindowEffectiveBroadcastCase {
bool should_become_broadcast;
string ToTestCaseName() const {
- return tensorflow::strings::StrCat(
- tensorflow::str_util::Join(input_spatials, ","), ";",
- tensorflow::str_util::Join(symmetric_pad_spatials, ","), ";",
- tensorflow::str_util::Join(reduce_window_spatials, ","), ";", prepend_a,
- ";", should_become_broadcast);
+ return absl::StrCat(tensorflow::str_util::Join(input_spatials, ","), ";",
+ tensorflow::str_util::Join(symmetric_pad_spatials, ","),
+ ";",
+ tensorflow::str_util::Join(reduce_window_spatials, ","),
+ ";", prepend_a, ";", should_become_broadcast);
}
};
diff --git a/tensorflow/compiler/xla/service/allocation_tracker.cc b/tensorflow/compiler/xla/service/allocation_tracker.cc
index d0806d24a2..5115a14df0 100644
--- a/tensorflow/compiler/xla/service/allocation_tracker.cc
+++ b/tensorflow/compiler/xla/service/allocation_tracker.cc
@@ -18,6 +18,7 @@ limitations under the License.
#include <utility>
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/map_util.h"
#include "tensorflow/compiler/xla/service/device_memory_allocator.h"
#include "tensorflow/compiler/xla/service/transfer_manager.h"
@@ -25,7 +26,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/status_macros.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/compiler/xla/util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/logging.h"
namespace xla {
diff --git a/tensorflow/compiler/xla/service/backend.h b/tensorflow/compiler/xla/service/backend.h
index 1bc3796fa4..4a6a78daf0 100644
--- a/tensorflow/compiler/xla/service/backend.h
+++ b/tensorflow/compiler/xla/service/backend.h
@@ -21,6 +21,7 @@ limitations under the License.
#include <string>
#include <vector>
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/service/compiler.h"
#include "tensorflow/compiler/xla/service/computation_placer.h"
#include "tensorflow/compiler/xla/service/device_memory_allocator.h"
@@ -29,7 +30,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/statusor.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/core/lib/gtl/array_slice.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/mutex.h"
#include "tensorflow/core/platform/stream_executor_no_cuda.h"
#include "tensorflow/core/platform/thread_annotations.h"
@@ -130,7 +130,7 @@ class Backend {
// Return a string identifier for the given device, eg: "GPU:3".
string device_name(int device_ordinal) const {
- return tensorflow::strings::StrCat(platform_->Name(), ":", device_ordinal);
+ return absl::StrCat(platform_->Name(), ":", device_ordinal);
}
// Returns true if the devices with the given ordinals are equivalent from
diff --git a/tensorflow/compiler/xla/service/batch_dot_simplification.cc b/tensorflow/compiler/xla/service/batch_dot_simplification.cc
index be6fbcc9e3..a16b85a0a5 100644
--- a/tensorflow/compiler/xla/service/batch_dot_simplification.cc
+++ b/tensorflow/compiler/xla/service/batch_dot_simplification.cc
@@ -78,7 +78,7 @@ BatchDotSimplification::ElideDegenerateBatchDimensionFromBatchDot(
return true;
}
-tensorflow::StringPiece BatchDotSimplification::name() const {
+absl::string_view BatchDotSimplification::name() const {
return "batch-dot-simplification";
}
diff --git a/tensorflow/compiler/xla/service/batch_dot_simplification.h b/tensorflow/compiler/xla/service/batch_dot_simplification.h
index c0ca8d8eba..79d37f08d3 100644
--- a/tensorflow/compiler/xla/service/batch_dot_simplification.h
+++ b/tensorflow/compiler/xla/service/batch_dot_simplification.h
@@ -28,7 +28,7 @@ namespace xla {
class BatchDotSimplification : public HloPassInterface {
public:
StatusOr<bool> Run(HloModule* module) override;
- tensorflow::StringPiece name() const override;
+ absl::string_view name() const override;
private:
StatusOr<bool> ElideDegenerateBatchDimensionFromBatchDot(
diff --git a/tensorflow/compiler/xla/service/batchnorm_expander.h b/tensorflow/compiler/xla/service/batchnorm_expander.h
index 7ae202c583..76e32174f3 100644
--- a/tensorflow/compiler/xla/service/batchnorm_expander.h
+++ b/tensorflow/compiler/xla/service/batchnorm_expander.h
@@ -36,7 +36,7 @@ class BatchNormExpander : public HloPassInterface {
rewrite_inference_op_(rewrite_inference_op),
rewrite_grad_op_(rewrite_grad_op) {}
~BatchNormExpander() = default;
- tensorflow::StringPiece name() const override { return "batchnorm_expander"; }
+ absl::string_view name() const override { return "batchnorm_expander"; }
// Run operation expander on the given computation. Returns whether the
// computation was changed.
diff --git a/tensorflow/compiler/xla/service/bfloat16_conversion_folding.h b/tensorflow/compiler/xla/service/bfloat16_conversion_folding.h
index c939838709..5dcd31b83d 100644
--- a/tensorflow/compiler/xla/service/bfloat16_conversion_folding.h
+++ b/tensorflow/compiler/xla/service/bfloat16_conversion_folding.h
@@ -37,7 +37,7 @@ class BFloat16ConversionFolding : public HloPassInterface {
: bfloat16_support_(bfloat16_support) {}
~BFloat16ConversionFolding() override = default;
- tensorflow::StringPiece name() const override { return "bfloat16-fold"; }
+ absl::string_view name() const override { return "bfloat16-fold"; }
// Run BF16 conversion folding on the given computation. Returns whether the
// computation was changed.
diff --git a/tensorflow/compiler/xla/service/bfloat16_normalization.h b/tensorflow/compiler/xla/service/bfloat16_normalization.h
index 2a60fe0af3..30b6346312 100644
--- a/tensorflow/compiler/xla/service/bfloat16_normalization.h
+++ b/tensorflow/compiler/xla/service/bfloat16_normalization.h
@@ -31,7 +31,7 @@ class BFloat16Normalization : public HloPassInterface {
: bfloat16_support_(bfloat16_support) {}
~BFloat16Normalization() override = default;
- tensorflow::StringPiece name() const override { return "bf16-normalization"; }
+ absl::string_view name() const override { return "bf16-normalization"; }
// Run BF16 normalization on the given computation. Returns whether the
// computation was changed.
@@ -54,7 +54,7 @@ class BFloat16MixedPrecisionRemoval : public HloPassInterface {
~BFloat16MixedPrecisionRemoval() override = default;
- tensorflow::StringPiece name() const override {
+ absl::string_view name() const override {
return "bf16-mixed-precision-removal";
}
diff --git a/tensorflow/compiler/xla/service/bfloat16_propagation.h b/tensorflow/compiler/xla/service/bfloat16_propagation.h
index 02b8cad089..1ee64971ab 100644
--- a/tensorflow/compiler/xla/service/bfloat16_propagation.h
+++ b/tensorflow/compiler/xla/service/bfloat16_propagation.h
@@ -64,9 +64,7 @@ class BFloat16Propagation : public HloPassInterface {
~BFloat16Propagation() override = default;
- tensorflow::StringPiece name() const override {
- return "bfloat16-propagation";
- }
+ absl::string_view name() const override { return "bfloat16-propagation"; }
// Runs the pass on the given module. Returns whether the module was changed
// (precision reductions were added).
diff --git a/tensorflow/compiler/xla/service/buffer_assignment.cc b/tensorflow/compiler/xla/service/buffer_assignment.cc
index 0f08e7c52b..17578bc2c1 100644
--- a/tensorflow/compiler/xla/service/buffer_assignment.cc
+++ b/tensorflow/compiler/xla/service/buffer_assignment.cc
@@ -23,6 +23,7 @@ limitations under the License.
#include <utility>
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/map_util.h"
#include "tensorflow/compiler/xla/service/buffer_value_containers.h"
#include "tensorflow/compiler/xla/service/heap_simulator.h"
@@ -37,17 +38,16 @@ limitations under the License.
#include "tensorflow/core/lib/hash/hash.h"
#include "tensorflow/core/lib/strings/numbers.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/lib/strings/stringprintf.h"
namespace xla {
+using ::absl::StrAppend;
using ::tensorflow::gtl::FlatMap;
using ::tensorflow::gtl::FlatSet;
using ::tensorflow::strings::Appendf;
using ::tensorflow::strings::HumanReadableNumBytes;
using ::tensorflow::strings::Printf;
-using ::tensorflow::strings::StrAppend;
namespace {
@@ -236,8 +236,8 @@ size_t BufferAllocation::Slice::Hasher::operator()(Slice s) const {
}
string BufferAllocation::Slice::ToString() const {
- return tensorflow::strings::StrCat("{index:", index(), ", offset:", offset_,
- ", size:", size_, "}");
+ return absl::StrCat("{index:", index(), ", offset:", offset_,
+ ", size:", size_, "}");
}
BufferAllocation::Slice BufferAllocation::GetSlice(
@@ -678,9 +678,9 @@ string BufferAssignment::Stats::ToString() const {
string BufferAssignment::ToString() const {
string output;
- tensorflow::strings::StrAppend(&output, "BufferAssignment:\n");
+ absl::StrAppend(&output, "BufferAssignment:\n");
for (auto& allocation : allocations_) {
- tensorflow::strings::StrAppend(&output, allocation.ToString());
+ absl::StrAppend(&output, allocation.ToString());
}
return output;
}
diff --git a/tensorflow/compiler/xla/service/buffer_value.cc b/tensorflow/compiler/xla/service/buffer_value.cc
index 2bc556a9e2..8d173c1aa9 100644
--- a/tensorflow/compiler/xla/service/buffer_value.cc
+++ b/tensorflow/compiler/xla/service/buffer_value.cc
@@ -17,11 +17,11 @@ limitations under the License.
#include <iosfwd>
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/service/hlo_computation.h"
#include "tensorflow/compiler/xla/service/hlo_instruction.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/types.h"
namespace xla {
diff --git a/tensorflow/compiler/xla/service/call_graph.cc b/tensorflow/compiler/xla/service/call_graph.cc
index d6efef5f12..7386a42b76 100644
--- a/tensorflow/compiler/xla/service/call_graph.cc
+++ b/tensorflow/compiler/xla/service/call_graph.cc
@@ -18,20 +18,20 @@ limitations under the License.
#include <queue>
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/map_util.h"
#include "tensorflow/compiler/xla/status_macros.h"
#include "tensorflow/compiler/xla/util.h"
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/core/status.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/lib/strings/stringprintf.h"
#include "tensorflow/core/platform/types.h"
namespace xla {
+using ::absl::StrCat;
using ::tensorflow::strings::Appendf;
-using ::tensorflow::strings::StrCat;
string CallContextToString(CallContext context) {
switch (context) {
diff --git a/tensorflow/compiler/xla/service/call_inliner.h b/tensorflow/compiler/xla/service/call_inliner.h
index c0e95e1578..c5cd88b9ea 100644
--- a/tensorflow/compiler/xla/service/call_inliner.h
+++ b/tensorflow/compiler/xla/service/call_inliner.h
@@ -35,7 +35,7 @@ class CallInliner : public HloPassInterface {
static StatusOr<InlinedInstructionMap> Inline(HloInstruction* call);
~CallInliner() override = default;
- tensorflow::StringPiece name() const override { return "CallInliner"; }
+ absl::string_view name() const override { return "CallInliner"; }
StatusOr<bool> Run(HloModule* module) override;
};
diff --git a/tensorflow/compiler/xla/service/channel_tracker.cc b/tensorflow/compiler/xla/service/channel_tracker.cc
index 9c9e373821..601a3e9a01 100644
--- a/tensorflow/compiler/xla/service/channel_tracker.cc
+++ b/tensorflow/compiler/xla/service/channel_tracker.cc
@@ -16,13 +16,13 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/channel_tracker.h"
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/service/hlo_computation.h"
#include "tensorflow/compiler/xla/service/hlo_instruction.h"
#include "tensorflow/compiler/xla/status.h"
#include "tensorflow/compiler/xla/status_macros.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/compiler/xla/util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/mutex.h"
#include "tensorflow/core/platform/types.h"
diff --git a/tensorflow/compiler/xla/service/compile_only_service.cc b/tensorflow/compiler/xla/service/compile_only_service.cc
index 7426672a7a..3079695e96 100644
--- a/tensorflow/compiler/xla/service/compile_only_service.cc
+++ b/tensorflow/compiler/xla/service/compile_only_service.cc
@@ -19,6 +19,7 @@ limitations under the License.
#include <utility>
#include <vector>
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/legacy_flags/debug_options_flags.h"
#include "tensorflow/compiler/xla/service/backend.h"
#include "tensorflow/compiler/xla/service/computation_layout.h"
@@ -28,7 +29,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/util.h"
#include "tensorflow/core/lib/gtl/cleanup.h"
#include "tensorflow/core/lib/io/path.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/host_info.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/stream_executor_no_cuda.h"
@@ -76,9 +76,9 @@ CompileOnlyService::CompileAheadOfTime(
if (!directory_path.empty()) {
HloSnapshot hlo_snapshot;
*hlo_snapshot.mutable_hlo()->mutable_hlo_module() = instance.computation;
- string filename = tensorflow::strings::StrCat(
- "computation_", instance.computation.id(), "__",
- instance.computation.entry_computation_name());
+ string filename =
+ absl::StrCat("computation_", instance.computation.id(), "__",
+ instance.computation.entry_computation_name());
const string& per_host_path = tensorflow::io::JoinPath(
directory_path, tensorflow::port::Hostname());
diff --git a/tensorflow/compiler/xla/service/computation_layout.cc b/tensorflow/compiler/xla/service/computation_layout.cc
index cb61f3da39..ed6f7412c4 100644
--- a/tensorflow/compiler/xla/service/computation_layout.cc
+++ b/tensorflow/compiler/xla/service/computation_layout.cc
@@ -17,9 +17,9 @@ limitations under the License.
#include <algorithm>
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
namespace xla {
@@ -52,9 +52,8 @@ string ComputationLayout::ToString() const {
for (auto& param_layout : parameter_layouts_) {
params.push_back(param_layout.ToString());
}
- return tensorflow::strings::StrCat("(",
- tensorflow::str_util::Join(params, ", "),
- ") => ", result_layout_.ToString());
+ return absl::StrCat("(", tensorflow::str_util::Join(params, ", "), ") => ",
+ result_layout_.ToString());
}
} // namespace xla
diff --git a/tensorflow/compiler/xla/service/computation_placer.cc b/tensorflow/compiler/xla/service/computation_placer.cc
index afbbea35b8..61b1dba6c9 100644
--- a/tensorflow/compiler/xla/service/computation_placer.cc
+++ b/tensorflow/compiler/xla/service/computation_placer.cc
@@ -20,6 +20,7 @@ limitations under the License.
#include <vector>
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/literal.h"
#include "tensorflow/compiler/xla/shape_util.h"
#include "tensorflow/compiler/xla/status.h"
@@ -29,12 +30,11 @@ limitations under the License.
#include "tensorflow/compiler/xla/util.h"
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/core/status.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/stream_executor_no_cuda.h"
-using tensorflow::strings::StrAppend;
-using tensorflow::strings::StrCat;
+using absl::StrAppend;
+using absl::StrCat;
namespace xla {
diff --git a/tensorflow/compiler/xla/service/conditional_simplifier.cc b/tensorflow/compiler/xla/service/conditional_simplifier.cc
index b7be3ba605..0a62104065 100644
--- a/tensorflow/compiler/xla/service/conditional_simplifier.cc
+++ b/tensorflow/compiler/xla/service/conditional_simplifier.cc
@@ -19,6 +19,7 @@ limitations under the License.
#include <utility>
#include <vector>
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/literal.h"
#include "tensorflow/compiler/xla/service/call_inliner.h"
#include "tensorflow/compiler/xla/service/hlo_computation.h"
@@ -29,7 +30,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/util.h"
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
namespace xla {
diff --git a/tensorflow/compiler/xla/service/conditional_simplifier.h b/tensorflow/compiler/xla/service/conditional_simplifier.h
index 063261e26d..3de50cbd7f 100644
--- a/tensorflow/compiler/xla/service/conditional_simplifier.h
+++ b/tensorflow/compiler/xla/service/conditional_simplifier.h
@@ -16,10 +16,10 @@ limitations under the License.
#ifndef TENSORFLOW_COMPILER_XLA_SERVICE_CONDITIONAL_SIMPLIFIER_H_
#define TENSORFLOW_COMPILER_XLA_SERVICE_CONDITIONAL_SIMPLIFIER_H_
+#include "absl/strings/string_view.h"
#include "tensorflow/compiler/xla/service/hlo_module.h"
#include "tensorflow/compiler/xla/service/hlo_pass_interface.h"
#include "tensorflow/compiler/xla/statusor.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
namespace xla {
@@ -27,9 +27,7 @@ namespace xla {
// with their true or false computation as appropriate.
class ConditionalSimplifier : public HloPassInterface {
public:
- tensorflow::StringPiece name() const override {
- return "simplify-conditional";
- }
+ absl::string_view name() const override { return "simplify-conditional"; }
StatusOr<bool> Run(HloModule* module) override;
};
diff --git a/tensorflow/compiler/xla/service/convolution_feature_group_converter.h b/tensorflow/compiler/xla/service/convolution_feature_group_converter.h
index f213cc8709..498894737f 100644
--- a/tensorflow/compiler/xla/service/convolution_feature_group_converter.h
+++ b/tensorflow/compiler/xla/service/convolution_feature_group_converter.h
@@ -16,10 +16,10 @@ limitations under the License.
#ifndef TENSORFLOW_COMPILER_XLA_SERVICE_CONVOLUTION_FEATURE_GROUP_CONVERTER_H_
#define TENSORFLOW_COMPILER_XLA_SERVICE_CONVOLUTION_FEATURE_GROUP_CONVERTER_H_
+#include "absl/strings/string_view.h"
#include "tensorflow/compiler/xla/service/hlo_module.h"
#include "tensorflow/compiler/xla/service/hlo_pass_interface.h"
#include "tensorflow/compiler/xla/status_macros.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
namespace xla {
@@ -29,7 +29,7 @@ class ConvolutionFeatureGroupConverter : public HloPassInterface {
public:
ConvolutionFeatureGroupConverter() {}
- tensorflow::StringPiece name() const override {
+ absl::string_view name() const override {
return "convolution-feature-group-converter";
}
diff --git a/tensorflow/compiler/xla/service/copy_insertion.cc b/tensorflow/compiler/xla/service/copy_insertion.cc
index 3e39c1bab1..98735f77c2 100644
--- a/tensorflow/compiler/xla/service/copy_insertion.cc
+++ b/tensorflow/compiler/xla/service/copy_insertion.cc
@@ -15,6 +15,7 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/copy_insertion.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/service/hlo_alias_analysis.h"
#include "tensorflow/compiler/xla/service/hlo_computation.h"
#include "tensorflow/compiler/xla/service/hlo_dce.h"
@@ -32,14 +33,13 @@ limitations under the License.
#include "tensorflow/core/lib/gtl/flatmap.h"
#include "tensorflow/core/lib/gtl/flatset.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/logging.h"
namespace xla {
+using ::absl::StrAppend;
+using ::absl::StrCat;
using ::tensorflow::str_util::Join;
-using ::tensorflow::strings::StrAppend;
-using ::tensorflow::strings::StrCat;
namespace {
diff --git a/tensorflow/compiler/xla/service/copy_insertion.h b/tensorflow/compiler/xla/service/copy_insertion.h
index 5ba64b78a3..f797ee7e4d 100644
--- a/tensorflow/compiler/xla/service/copy_insertion.h
+++ b/tensorflow/compiler/xla/service/copy_insertion.h
@@ -45,7 +45,7 @@ namespace xla {
// InstructionAliasSet::IsDistinct return true.
class CopyInsertion : public HloPassInterface {
public:
- tensorflow::StringPiece name() const override { return "copy-insertion"; }
+ absl::string_view name() const override { return "copy-insertion"; }
// fusion_can_share_buffer: backend specific function that decides whether a
// fusion can share buffer with its operand.
diff --git a/tensorflow/compiler/xla/service/cpu/BUILD b/tensorflow/compiler/xla/service/cpu/BUILD
index 850948b54b..f8500e78b6 100644
--- a/tensorflow/compiler/xla/service/cpu/BUILD
+++ b/tensorflow/compiler/xla/service/cpu/BUILD
@@ -87,6 +87,7 @@ cc_library(
":parallel_task_assignment",
":simple_orc_jit",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
"//tensorflow/compiler/tf2xla:cpu_function_runtime",
"//tensorflow/compiler/xla/service:scatter_expander",
"//tensorflow/compiler/xla:literal",
@@ -232,6 +233,7 @@ cc_library(
"//tensorflow/compiler/xla/service:tuple_points_to_analysis",
"//tensorflow/core:lib",
"//tensorflow/core:stream_executor_no_cuda",
+ "@com_google_absl//absl/strings",
"@llvm//:orc_jit",
],
)
@@ -279,6 +281,7 @@ cc_library(
"//tensorflow/compiler/xla/service/llvm_ir:loop_emitter",
"//tensorflow/compiler/xla/service/llvm_ir:tuple_ops",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
"@llvm//:code_gen",
"@llvm//:core",
"@llvm//:support",
@@ -323,6 +326,7 @@ cc_library(
"//tensorflow/compiler/xla/service/cpu:cpu_runtime",
"//tensorflow/compiler/xla/service/llvm_ir:llvm_util",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
"@llvm//:core",
],
)
@@ -365,6 +369,7 @@ cc_library(
"//tensorflow/compiler/xla/service/llvm_ir:llvm_loop",
"//tensorflow/compiler/xla/service/llvm_ir:llvm_util",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
"@llvm//:core",
],
)
@@ -653,6 +658,7 @@ tf_cc_test(
"//tensorflow/compiler/xla/tests:hlo_test_base",
"//tensorflow/compiler/xla/tests:xla_internal_test_main",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
],
)
@@ -816,6 +822,7 @@ cc_library(
"//tensorflow/compiler/xla/service:hlo_cost_analysis",
"//tensorflow/compiler/xla/service:hlo_pass",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
@@ -852,6 +859,7 @@ cc_library(
deps = [
"//tensorflow/compiler/xla/service:hlo_module_config",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
],
)
diff --git a/tensorflow/compiler/xla/service/cpu/conv_canonicalization.h b/tensorflow/compiler/xla/service/cpu/conv_canonicalization.h
index e6fd1499ed..59437e88af 100644
--- a/tensorflow/compiler/xla/service/cpu/conv_canonicalization.h
+++ b/tensorflow/compiler/xla/service/cpu/conv_canonicalization.h
@@ -38,7 +38,7 @@ class ConvCanonicalization : public HloPassInterface {
: target_machine_features_(*target_machine_features) {}
~ConvCanonicalization() override {}
- tensorflow::StringPiece name() const override {
+ absl::string_view name() const override {
return "convolution-canonicalization";
}
diff --git a/tensorflow/compiler/xla/service/cpu/cpu_compiler.cc b/tensorflow/compiler/xla/service/cpu/cpu_compiler.cc
index 5116f926f5..292ae9d121 100644
--- a/tensorflow/compiler/xla/service/cpu/cpu_compiler.cc
+++ b/tensorflow/compiler/xla/service/cpu/cpu_compiler.cc
@@ -27,6 +27,7 @@ limitations under the License.
// IWYU pragma: no_include "llvm/Config/Disassemblers.def.inc"
// IWYU pragma: no_include "llvm/Config/Targets.def.inc"
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Triple.h"
#include "llvm/IR/Function.h"
@@ -102,7 +103,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/util.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
namespace xla {
namespace cpu {
diff --git a/tensorflow/compiler/xla/service/cpu/cpu_copy_insertion.h b/tensorflow/compiler/xla/service/cpu/cpu_copy_insertion.h
index 6398d8c98d..d49f7d7cc2 100644
--- a/tensorflow/compiler/xla/service/cpu/cpu_copy_insertion.h
+++ b/tensorflow/compiler/xla/service/cpu/cpu_copy_insertion.h
@@ -32,7 +32,7 @@ namespace xla {
// (module-scoped).
class CpuCopyInsertion : public HloPassInterface {
public:
- tensorflow::StringPiece name() const override { return "copy-insertion"; }
+ absl::string_view name() const override { return "copy-insertion"; }
StatusOr<bool> Run(HloModule* module) override;
};
diff --git a/tensorflow/compiler/xla/service/cpu/cpu_executable.cc b/tensorflow/compiler/xla/service/cpu/cpu_executable.cc
index c376864c3e..fb91ae33b0 100644
--- a/tensorflow/compiler/xla/service/cpu/cpu_executable.cc
+++ b/tensorflow/compiler/xla/service/cpu/cpu_executable.cc
@@ -22,6 +22,7 @@ limitations under the License.
#include <utility>
#include <vector>
+#include "absl/strings/str_cat.h"
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
#include "tensorflow/compiler/xla/service/buffer_assignment.h"
#include "tensorflow/compiler/xla/service/computation_layout.h"
@@ -36,7 +37,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/util.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/lib/strings/stringprintf.h"
#include "tensorflow/core/platform/env.h"
#include "tensorflow/core/platform/logging.h"
@@ -177,7 +177,7 @@ Status CpuExecutable::ExecuteComputeFunction(
buffer_pointers.size(), profile_counters_size);
VLOG(3) << tensorflow::strings::Printf(" result = %p", result_buffer);
auto ptr_printer = [](string* out, const void* p) {
- tensorflow::strings::StrAppend(out, tensorflow::strings::Printf("%p", p));
+ absl::StrAppend(out, tensorflow::strings::Printf("%p", p));
};
VLOG(3) << " params = nullptr";
VLOG(3) << tensorflow::strings::Printf(
diff --git a/tensorflow/compiler/xla/service/cpu/cpu_hlo_support_checker.h b/tensorflow/compiler/xla/service/cpu/cpu_hlo_support_checker.h
index 2924b63659..6af724b2a5 100644
--- a/tensorflow/compiler/xla/service/cpu/cpu_hlo_support_checker.h
+++ b/tensorflow/compiler/xla/service/cpu/cpu_hlo_support_checker.h
@@ -28,9 +28,7 @@ class CpuHloSupportChecker : public HloPassInterface {
CpuHloSupportChecker() = default;
~CpuHloSupportChecker() override = default;
- tensorflow::StringPiece name() const override {
- return "cpu_hlo_support_checker";
- }
+ absl::string_view name() const override { return "cpu_hlo_support_checker"; }
// Note: always returns false (no instructions are ever modified by this
// pass).
diff --git a/tensorflow/compiler/xla/service/cpu/cpu_instruction_fusion_test.cc b/tensorflow/compiler/xla/service/cpu/cpu_instruction_fusion_test.cc
index e6130c7d76..c3e03056f0 100644
--- a/tensorflow/compiler/xla/service/cpu/cpu_instruction_fusion_test.cc
+++ b/tensorflow/compiler/xla/service/cpu/cpu_instruction_fusion_test.cc
@@ -18,6 +18,7 @@ limitations under the License.
#include <algorithm>
#include <set>
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/service/hlo_matchers.h"
#include "tensorflow/compiler/xla/service/hlo_parser.h"
#include "tensorflow/compiler/xla/service/transpose_folding.h"
@@ -773,8 +774,8 @@ class GatherLoopFusionTest
TEST_P(GatherLoopFusionTest, GatherLoopFusion) {
const GatherLoopFusionTestSpec& spec = GetParam();
- string hlo_string = tensorflow::strings::StrCat(
- "HloModule ", spec.test_name, "\n\n", spec.hlo_computation_text);
+ string hlo_string = absl::StrCat("HloModule ", spec.test_name, "\n\n",
+ spec.hlo_computation_text);
TF_ASSERT_OK_AND_ASSIGN(std::unique_ptr<HloModule> module,
ParseHloString(hlo_string));
diff --git a/tensorflow/compiler/xla/service/cpu/cpu_options.cc b/tensorflow/compiler/xla/service/cpu/cpu_options.cc
index b6039b465e..0a8dcf0006 100644
--- a/tensorflow/compiler/xla/service/cpu/cpu_options.cc
+++ b/tensorflow/compiler/xla/service/cpu/cpu_options.cc
@@ -15,6 +15,8 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/cpu/cpu_options.h"
+#include "absl/strings/numbers.h"
+#include "absl/strings/str_split.h"
#include "tensorflow/core/lib/strings/numbers.h"
#include "tensorflow/core/lib/strings/str_util.h"
@@ -51,7 +53,7 @@ absl::optional<int64> LlvmIrGemvTilingFactor(const HloModuleConfig& config) {
auto it = extra_options_map.find(kLlvmIrDotTilingFactor);
int64 tiling_factor;
if (it != extra_options_map.end() &&
- tensorflow::strings::safe_strto64(it->second, &tiling_factor)) {
+ absl::SimpleAtoi(it->second, &tiling_factor)) {
return tiling_factor;
}
return absl::nullopt;
@@ -63,8 +65,8 @@ bool EnableExperimentalLlvmIrGemm(const HloModuleConfig& config) {
return extra_options_map.count(kXlaEnableExperimentalLlvmIrGemm) > 0;
}
-static tensorflow::StringPiece RemoveSuffix(tensorflow::StringPiece str,
- tensorflow::StringPiece suffix) {
+static absl::string_view RemoveSuffix(absl::string_view str,
+ absl::string_view suffix) {
CHECK_GE(str.size(), suffix.size());
CHECK_EQ(str.substr(str.size() - suffix.size()), suffix);
return str.substr(0, str.size() - suffix.size());
@@ -79,22 +81,21 @@ absl::optional<std::tuple<int64, int64, int64>> LlvmIrGemmTileSize(
return absl::nullopt;
}
- std::vector<string> tile_components =
- tensorflow::str_util::Split(it->second, ':');
+ std::vector<string> tile_components = absl::StrSplit(it->second, ':');
CHECK_EQ(tile_components.size(), 3);
int64 tile_size_m;
int64 tile_size_k;
int64 tile_size_n_in_vector_width;
- CHECK(tensorflow::strings::safe_strto64(tile_components[0], &tile_size_m));
- CHECK(tensorflow::strings::safe_strto64(tile_components[1], &tile_size_k));
+ CHECK(absl::SimpleAtoi(tile_components[0], &tile_size_m));
+ CHECK(absl::SimpleAtoi(tile_components[1], &tile_size_k));
- tensorflow::StringPiece tile_size_n_in_vector_width_str =
+ absl::string_view tile_size_n_in_vector_width_str =
RemoveSuffix(tile_components[2], "*vectwidth");
- CHECK(tensorflow::strings::safe_strto64(tile_size_n_in_vector_width_str,
- &tile_size_n_in_vector_width));
+ CHECK(absl::SimpleAtoi(tile_size_n_in_vector_width_str,
+ &tile_size_n_in_vector_width));
return std::tuple<int64, int64, int64>(tile_size_m, tile_size_k,
tile_size_n_in_vector_width);
diff --git a/tensorflow/compiler/xla/service/cpu/dot_op_emitter.cc b/tensorflow/compiler/xla/service/cpu/dot_op_emitter.cc
index 797392c265..4af16f4fa0 100644
--- a/tensorflow/compiler/xla/service/cpu/dot_op_emitter.cc
+++ b/tensorflow/compiler/xla/service/cpu/dot_op_emitter.cc
@@ -18,6 +18,7 @@ limitations under the License.
#include <memory>
#include <vector>
+#include "absl/strings/str_cat.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Module.h"
@@ -146,9 +147,9 @@ class GemvConfig {
bool has_addend() const { return has_addend_; }
string GetCacheKey() const {
- return tensorflow::strings::StrCat(
- name_, "_", PrimitiveType_Name(scalar_type()), "_", tile_rows(), "_",
- tile_cols(), "_", m(), "_", k(), has_addend() ? "_with_addend" : "");
+ return absl::StrCat(name_, "_", PrimitiveType_Name(scalar_type()), "_",
+ tile_rows(), "_", tile_cols(), "_", m(), "_", k(),
+ has_addend() ? "_with_addend" : "");
}
protected:
@@ -642,9 +643,7 @@ class TiledSmallGemmEmitter {
int64 k() const { return k_; }
int64 n() const { return n_; }
- string ToString() const {
- return tensorflow::strings::StrCat(m(), "x", k(), "x", n());
- }
+ string ToString() const { return absl::StrCat(m(), "x", k(), "x", n()); }
private:
const int64 m_;
@@ -687,10 +686,10 @@ class TiledSmallGemmEmitter {
tile_size_k_(tile_size_k) {}
string GetCacheKey() const {
- return tensorflow::strings::StrCat(
- "gemm_", PrimitiveType_Name(scalar_type()), "_", dims().ToString(),
- "_", max_vectorization_width(), "_", min_vectorization_width(), "_",
- tile_size_m(), "_", tile_size_k());
+ return absl::StrCat("gemm_", PrimitiveType_Name(scalar_type()), "_",
+ dims().ToString(), "_", max_vectorization_width(),
+ "_", min_vectorization_width(), "_", tile_size_m(),
+ "_", tile_size_k());
}
PrimitiveType scalar_type() const { return scalar_type_; }
diff --git a/tensorflow/compiler/xla/service/cpu/dot_op_emitter.h b/tensorflow/compiler/xla/service/cpu/dot_op_emitter.h
index 05322faa75..4c2041b556 100644
--- a/tensorflow/compiler/xla/service/cpu/dot_op_emitter.h
+++ b/tensorflow/compiler/xla/service/cpu/dot_op_emitter.h
@@ -16,6 +16,7 @@ limitations under the License.
#ifndef TENSORFLOW_COMPILER_XLA_SERVICE_CPU_DOT_OP_EMITTER_H_
#define TENSORFLOW_COMPILER_XLA_SERVICE_CPU_DOT_OP_EMITTER_H_
+#include "absl/strings/string_view.h"
#include "llvm/IR/IRBuilder.h"
#include "tensorflow/compiler/xla/service/cpu/cpu_options.h"
#include "tensorflow/compiler/xla/service/cpu/target_machine_features.h"
@@ -25,7 +26,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/llvm_ir/llvm_loop.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/core/lib/core/status.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/platform/types.h"
namespace xla {
diff --git a/tensorflow/compiler/xla/service/cpu/ir_emitter.cc b/tensorflow/compiler/xla/service/cpu/ir_emitter.cc
index 6f433b4f30..417a1dba1f 100644
--- a/tensorflow/compiler/xla/service/cpu/ir_emitter.cc
+++ b/tensorflow/compiler/xla/service/cpu/ir_emitter.cc
@@ -27,6 +27,7 @@ limitations under the License.
#include "tensorflow/core/lib/math/math_util.h"
#include "tensorflow/core/platform/logging.h"
// IWYU pragma: no_include "llvm/IR/Intrinsics.gen.inc"
+#include "absl/strings/str_cat.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/IR/BasicBlock.h"
@@ -67,7 +68,6 @@ limitations under the License.
#include "tensorflow/core/lib/gtl/array_slice.h"
#include "tensorflow/core/lib/gtl/flatmap.h"
#include "tensorflow/core/lib/gtl/flatset.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/lib/strings/stringprintf.h"
namespace xla {
@@ -502,7 +502,7 @@ Status IrEmitter::HandleTuple(HloInstruction* tuple) {
llvm::Value* IrEmitter::EmitElementalMap(
const HloMapInstruction& map_instr,
tensorflow::gtl::ArraySlice<llvm::Value*> elemental_operands,
- tensorflow::StringPiece name) {
+ absl::string_view name) {
return EmitThreadLocalCall(*map_instr.to_apply(), elemental_operands, name);
}
@@ -846,7 +846,7 @@ StatusOr<llvm::Value*> IrEmitter::EmitTargetElementLoopBodyForConvolution(
loops
.AddLoop(
0, rhs->shape().dimensions(dnums.kernel_spatial_dimensions(i)),
- tensorflow::strings::StrCat("k", i))
+ absl::StrCat("k", i))
->GetIndVarValue();
}
llvm::Value* input_feature =
@@ -2118,7 +2118,7 @@ Status IrEmitter::HandleCall(HloInstruction* call) {
Status IrEmitter::HandleCustomCall(HloInstruction* custom_call) {
gtl::ArraySlice<HloInstruction*> operands(custom_call->operands());
- tensorflow::StringPiece custom_call_target(custom_call->custom_call_target());
+ absl::string_view custom_call_target(custom_call->custom_call_target());
llvm::Type* i8_ptr_type = b_.getInt8PtrTy();
llvm::AllocaInst* operands_alloca =
llvm_ir::EmitAllocaAtFunctionEntryWithCount(
@@ -2687,9 +2687,8 @@ llvm::Value* IrEmitter::EmitThreadLocalTempBufferPointer(
auto buf_it = thread_local_buffers_.find(key);
if (buf_it == thread_local_buffers_.end()) {
llvm::Value* buffer = llvm_ir::EmitAllocaAtFunctionEntry(
- IrShapeType(shape),
- tensorflow::strings::StrCat("thread_local", slice.ToString()), &b_,
- MinimumAlignmentForShape(target_shape));
+ IrShapeType(shape), absl::StrCat("thread_local", slice.ToString()),
+ &b_, MinimumAlignmentForShape(target_shape));
auto it_inserted_pair = thread_local_buffers_.insert({key, buffer});
CHECK(it_inserted_pair.second);
buf_it = it_inserted_pair.first;
@@ -2753,7 +2752,7 @@ Status IrEmitter::EmitTargetElementLoop(
}
Status IrEmitter::EmitTargetElementLoop(
- HloInstruction* target_op, tensorflow::StringPiece desc,
+ HloInstruction* target_op, absl::string_view desc,
const llvm_ir::ElementGenerator& element_generator) {
VLOG(2) << "EmitTargetElementLoop: " << target_op->ToString();
@@ -2848,7 +2847,7 @@ Status IrEmitter::DefaultAction(HloInstruction* hlo) {
llvm::Value* IrEmitter::EmitThreadLocalCall(
const HloComputation& callee,
tensorflow::gtl::ArraySlice<llvm::Value*> parameters,
- tensorflow::StringPiece name) {
+ absl::string_view name) {
const Shape& return_shape = callee.root_instruction()->shape();
// Lifting this restriction to allow "small" arrays should be easy. Allowing
@@ -2869,7 +2868,7 @@ llvm::Value* IrEmitter::EmitThreadLocalCall(
llvm::Value* return_value_buffer = llvm_ir::EmitAllocaAtFunctionEntry(
llvm_ir::PrimitiveTypeToIrType(return_type, module_),
- tensorflow::strings::StrCat(name, "_retval_addr"), &b_,
+ absl::StrCat(name, "_retval_addr"), &b_,
MinimumAlignmentForPrimitiveType(return_type));
b_.CreateCall(
@@ -2886,7 +2885,7 @@ llvm::Value* IrEmitter::EmitThreadLocalCall(
}
void IrEmitter::EmitGlobalCall(const HloComputation& callee,
- tensorflow::StringPiece name) {
+ absl::string_view name) {
b_.CreateCall(FindOrDie(emitted_functions_, &callee),
GetArrayFunctionCallArguments(
/*parameter_addresses=*/{}, &b_, name,
diff --git a/tensorflow/compiler/xla/service/cpu/ir_emitter.h b/tensorflow/compiler/xla/service/cpu/ir_emitter.h
index c9a1dab62d..99c080b3db 100644
--- a/tensorflow/compiler/xla/service/cpu/ir_emitter.h
+++ b/tensorflow/compiler/xla/service/cpu/ir_emitter.h
@@ -23,6 +23,7 @@ limitations under the License.
#include <unordered_map>
#include <vector>
+#include "absl/strings/string_view.h"
#include "llvm/ADT/Triple.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
@@ -44,7 +45,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/statusor.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/gtl/array_slice.h"
#include "tensorflow/core/lib/gtl/flatmap.h"
#include "tensorflow/core/platform/macros.h"
@@ -107,7 +107,7 @@ class IrEmitter : public DfsHloVisitorWithDefault {
llvm::Value* EmitElementalMap(
const HloMapInstruction& map_instr,
tensorflow::gtl::ArraySlice<llvm::Value*> elemental_operands,
- tensorflow::StringPiece name);
+ absl::string_view name);
protected:
//
@@ -239,7 +239,7 @@ class IrEmitter : public DfsHloVisitorWithDefault {
// function that a map operation applies.
StatusOr<llvm::Function*> EmitFunction(
HloComputation* function, // The function to emit.
- tensorflow::StringPiece
+ absl::string_view
function_name_suffix); // Used for LLVM IR register names.
// Emits a call to a thread local function (e.g. to the computation nested
@@ -251,14 +251,13 @@ class IrEmitter : public DfsHloVisitorWithDefault {
llvm::Value* EmitThreadLocalCall(
const HloComputation& callee,
tensorflow::gtl::ArraySlice<llvm::Value*> parameters,
- tensorflow::StringPiece name);
+ absl::string_view name);
// Emits a call to a "global" function (e.g. to the computation nested within
// a kWhile or a kCall). Buffer assignment unabiguously assignes buffers to
// the parameters and return values for these computations so there is no need
// to explicitly pass parameters or return results.
- void EmitGlobalCall(const HloComputation& callee,
- tensorflow::StringPiece name);
+ void EmitGlobalCall(const HloComputation& callee, absl::string_view name);
// Returns the buffer to which a global call to `callee` would have written
// its result.
@@ -285,7 +284,7 @@ class IrEmitter : public DfsHloVisitorWithDefault {
HloInstruction* target_op,
const llvm_ir::ElementGenerator& element_generator);
Status EmitTargetElementLoop(
- HloInstruction* target_op, tensorflow::StringPiece desc,
+ HloInstruction* target_op, absl::string_view desc,
const llvm_ir::ElementGenerator& element_generator);
// Emits a memcpy from the source instruction's result value to the
diff --git a/tensorflow/compiler/xla/service/cpu/ir_function.cc b/tensorflow/compiler/xla/service/cpu/ir_function.cc
index 2db4d000f5..784045313d 100644
--- a/tensorflow/compiler/xla/service/cpu/ir_function.cc
+++ b/tensorflow/compiler/xla/service/cpu/ir_function.cc
@@ -17,6 +17,7 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/cpu/ir_function.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/service/cpu/cpu_runtime.h"
#include "tensorflow/compiler/xla/service/cpu/shape_partition.h"
#include "tensorflow/compiler/xla/service/llvm_ir/llvm_util.h"
@@ -189,7 +190,7 @@ void IrFunction::Initialize(const string& function_name,
llvm::Value* IrFunction::GetDynamicLoopBound(const int64 offset) {
CHECK_GT(num_dynamic_loop_bounds_, 0);
CHECK_LT(offset, num_dynamic_loop_bounds_ * 2);
- string name = tensorflow::strings::StrCat("dynamic_loop_bound_", offset);
+ string name = absl::StrCat("dynamic_loop_bound_", offset);
return b_->CreateLoad(b_->CreateGEP(CHECK_NOTNULL(dynamic_loop_bounds_arg_),
b_->getInt64(offset), AsStringRef(name)));
}
@@ -200,7 +201,7 @@ llvm::Value* IrFunction::GetDynamicLoopBound(const int64 offset) {
// address buffer).
std::vector<llvm::Value*> GetArrayFunctionCallArguments(
tensorflow::gtl::ArraySlice<llvm::Value*> parameter_addresses,
- llvm::IRBuilder<>* b, tensorflow::StringPiece name,
+ llvm::IRBuilder<>* b, absl::string_view name,
llvm::Value* return_value_buffer, llvm::Value* exec_run_options_arg,
llvm::Value* temp_buffers_arg, llvm::Value* profile_counters_arg) {
llvm::Value* parameter_addresses_buffer;
@@ -211,13 +212,13 @@ std::vector<llvm::Value*> GetArrayFunctionCallArguments(
} else {
parameter_addresses_buffer = llvm_ir::EmitAllocaAtFunctionEntryWithCount(
b->getInt8PtrTy(), b->getInt32(parameter_addresses.size()),
- tensorflow::strings::StrCat(name, "_parameter_addresses"), b);
+ absl::StrCat(name, "_parameter_addresses"), b);
for (size_t i = 0; i < parameter_addresses.size(); ++i) {
llvm::Value* parameter_as_i8ptr =
b->CreateBitCast(parameter_addresses[i], b->getInt8PtrTy(),
- AsStringRef(tensorflow::strings::StrCat(
- name, "_parameter_", i, "_address_as_i8ptr")));
+ AsStringRef(absl::StrCat(name, "_parameter_", i,
+ "_address_as_i8ptr")));
llvm::Value* slot_in_param_addresses =
b->CreateInBoundsGEP(parameter_addresses_buffer, {b->getInt64(i)});
b->CreateStore(parameter_as_i8ptr, slot_in_param_addresses);
@@ -320,8 +321,7 @@ Status EmitCallToParallelForkJoin(
/*Linkage=*/llvm::GlobalValue::PrivateLinkage,
/*Initializer=*/partitions_array,
/*Name=*/
- AsStringRef(
- tensorflow::strings::StrCat(name, "_parallel_dimension_partitions")));
+ AsStringRef(absl::StrCat(name, "_parallel_dimension_partitions")));
// Add argument specifying parallel dimension partitions.
fork_join_arguments.push_back(
diff --git a/tensorflow/compiler/xla/service/cpu/ir_function.h b/tensorflow/compiler/xla/service/cpu/ir_function.h
index a41cbb64cd..ee7595f6e9 100644
--- a/tensorflow/compiler/xla/service/cpu/ir_function.h
+++ b/tensorflow/compiler/xla/service/cpu/ir_function.h
@@ -116,7 +116,7 @@ class IrFunction {
// Returns an array of compute function call argument ir values.
std::vector<llvm::Value*> GetArrayFunctionCallArguments(
tensorflow::gtl::ArraySlice<llvm::Value*> parameter_addresses,
- llvm::IRBuilder<>* b, tensorflow::StringPiece name,
+ llvm::IRBuilder<>* b, absl::string_view name,
llvm::Value* return_value_buffer, llvm::Value* exec_run_options_arg,
llvm::Value* temp_buffers_arg, llvm::Value* profile_counters_arg);
diff --git a/tensorflow/compiler/xla/service/cpu/parallel_loop_emitter.cc b/tensorflow/compiler/xla/service/cpu/parallel_loop_emitter.cc
index 8560e4296a..aedb069dce 100644
--- a/tensorflow/compiler/xla/service/cpu/parallel_loop_emitter.cc
+++ b/tensorflow/compiler/xla/service/cpu/parallel_loop_emitter.cc
@@ -30,8 +30,8 @@ ParallelLoopEmitter::ParallelLoopEmitter(
dynamic_loop_bounds_(dynamic_loop_bounds) {}
std::vector<llvm_ir::IrArray::Index>
-ParallelLoopEmitter::EmitIndexAndSetExitBasicBlock(
- tensorflow::StringPiece loop_name, llvm::Type* index_type) {
+ParallelLoopEmitter::EmitIndexAndSetExitBasicBlock(absl::string_view loop_name,
+ llvm::Type* index_type) {
CHECK_NE(index_type, nullptr);
CHECK(!ShapeUtil::IsTuple(shape_));
diff --git a/tensorflow/compiler/xla/service/cpu/parallel_loop_emitter.h b/tensorflow/compiler/xla/service/cpu/parallel_loop_emitter.h
index 076c683ca5..a604e1db22 100644
--- a/tensorflow/compiler/xla/service/cpu/parallel_loop_emitter.h
+++ b/tensorflow/compiler/xla/service/cpu/parallel_loop_emitter.h
@@ -61,7 +61,7 @@ class ParallelLoopEmitter : public llvm_ir::LoopEmitter {
~ParallelLoopEmitter() override = default;
std::vector<llvm_ir::IrArray::Index> EmitIndexAndSetExitBasicBlock(
- tensorflow::StringPiece loop_name, llvm::Type* index_type) override;
+ absl::string_view loop_name, llvm::Type* index_type) override;
private:
const DynamicLoopBounds* dynamic_loop_bounds_;
diff --git a/tensorflow/compiler/xla/service/cpu/parallel_task_assignment.cc b/tensorflow/compiler/xla/service/cpu/parallel_task_assignment.cc
index 286d407ca6..b4c0c09ec0 100644
--- a/tensorflow/compiler/xla/service/cpu/parallel_task_assignment.cc
+++ b/tensorflow/compiler/xla/service/cpu/parallel_task_assignment.cc
@@ -16,6 +16,7 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/cpu/parallel_task_assignment.h"
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/service/cpu/dot_op_emitter.h"
#include "tensorflow/compiler/xla/service/cpu/ir_emission_utils.h"
#include "tensorflow/compiler/xla/service/cpu/shape_partition.h"
@@ -217,8 +218,7 @@ bool ParallelTaskAssigner::AssignParallelTasksHelper(
// Outline 'instruction' in 'computation' for parallel task assignment.
auto* call = module->OutlineExpressionFromComputation(
- {instruction},
- tensorflow::strings::StrCat("parallel_", instruction->name()),
+ {instruction}, absl::StrCat("parallel_", instruction->name()),
computation);
// Set assigned dimension partitioning to 'instruction'.
diff --git a/tensorflow/compiler/xla/service/cpu/parallel_task_assignment.h b/tensorflow/compiler/xla/service/cpu/parallel_task_assignment.h
index 8becc8fa23..a99cd99c14 100644
--- a/tensorflow/compiler/xla/service/cpu/parallel_task_assignment.h
+++ b/tensorflow/compiler/xla/service/cpu/parallel_task_assignment.h
@@ -73,7 +73,7 @@ class ParallelTaskAssigner : public HloPassInterface {
target_machine_features_(*target_machine_features) {}
~ParallelTaskAssigner() override {}
- tensorflow::StringPiece name() const override {
+ absl::string_view name() const override {
return "cpu-parallel-task-assigner";
}
diff --git a/tensorflow/compiler/xla/service/cpu/simple_orc_jit.cc b/tensorflow/compiler/xla/service/cpu/simple_orc_jit.cc
index b026aef3fe..bf98064647 100644
--- a/tensorflow/compiler/xla/service/cpu/simple_orc_jit.cc
+++ b/tensorflow/compiler/xla/service/cpu/simple_orc_jit.cc
@@ -170,15 +170,14 @@ namespace {
bool RegisterKnownJITSymbols() {
CustomCallTargetRegistry* registry = CustomCallTargetRegistry::Global();
-#define REGISTER_CPU_RUNTIME_SYMBOL(base_name) \
- do { \
- auto* function_address = \
- reinterpret_cast<void*>(__xla_cpu_runtime_##base_name); \
- registry->Register(xla::cpu::runtime::k##base_name##SymbolName, \
- function_address); \
- CHECK_EQ( \
- tensorflow::StringPiece(xla::cpu::runtime::k##base_name##SymbolName), \
- "__xla_cpu_runtime_" #base_name); \
+#define REGISTER_CPU_RUNTIME_SYMBOL(base_name) \
+ do { \
+ auto* function_address = \
+ reinterpret_cast<void*>(__xla_cpu_runtime_##base_name); \
+ registry->Register(xla::cpu::runtime::k##base_name##SymbolName, \
+ function_address); \
+ CHECK_EQ(absl::string_view(xla::cpu::runtime::k##base_name##SymbolName), \
+ "__xla_cpu_runtime_" #base_name); \
} while (false)
REGISTER_CPU_RUNTIME_SYMBOL(AcquireInfeedBufferForDequeue);
diff --git a/tensorflow/compiler/xla/service/cpu/tests/BUILD b/tensorflow/compiler/xla/service/cpu/tests/BUILD
index 4635fa5d74..2384166fd2 100644
--- a/tensorflow/compiler/xla/service/cpu/tests/BUILD
+++ b/tensorflow/compiler/xla/service/cpu/tests/BUILD
@@ -110,6 +110,7 @@ tf_cc_test(
"//tensorflow/core:lib",
"//tensorflow/core:test",
"//tensorflow/core:test_main",
+ "@com_google_absl//absl/strings",
],
)
@@ -123,6 +124,7 @@ tf_cc_test(
"//tensorflow/core:lib",
"//tensorflow/core:test",
"//tensorflow/core:test_main",
+ "@com_google_absl//absl/strings",
],
)
diff --git a/tensorflow/compiler/xla/service/cpu/tests/cpu_eigen_dot_operation_test.cc b/tensorflow/compiler/xla/service/cpu/tests/cpu_eigen_dot_operation_test.cc
index 6fcce42eaa..fcd87b36b3 100644
--- a/tensorflow/compiler/xla/service/cpu/tests/cpu_eigen_dot_operation_test.cc
+++ b/tensorflow/compiler/xla/service/cpu/tests/cpu_eigen_dot_operation_test.cc
@@ -19,10 +19,10 @@ limitations under the License.
#include <cctype>
#include <string>
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/service/cpu/cpu_compiler.h"
#include "tensorflow/compiler/xla/service/cpu/tests/cpu_codegen_test.h"
#include "tensorflow/compiler/xla/service/hlo_computation.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/test.h"
namespace xla {
diff --git a/tensorflow/compiler/xla/service/cpu/tests/cpu_intrinsic_test.cc b/tensorflow/compiler/xla/service/cpu/tests/cpu_intrinsic_test.cc
index 973aac8766..9457e57d7b 100644
--- a/tensorflow/compiler/xla/service/cpu/tests/cpu_intrinsic_test.cc
+++ b/tensorflow/compiler/xla/service/cpu/tests/cpu_intrinsic_test.cc
@@ -17,10 +17,10 @@ limitations under the License.
#include <cctype>
#include <string>
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/service/cpu/cpu_compiler.h"
#include "tensorflow/compiler/xla/service/cpu/tests/cpu_codegen_test.h"
#include "tensorflow/compiler/xla/service/hlo_computation.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/test.h"
namespace xla {
@@ -32,9 +32,9 @@ const char* const kTriple_android_arm = "armv7-none-android";
struct IntrinsicTestSpec {
HloOpcode opcode;
- tensorflow::StringPiece triple;
- tensorflow::StringPiece features;
- tensorflow::StringPiece check_lines;
+ absl::string_view triple;
+ absl::string_view features;
+ absl::string_view check_lines;
};
// Tests that unary functions get lowered using intrinsic calls.
@@ -65,9 +65,8 @@ class CpuUnaryIntrinsicTest
features = "";
}
- return tensorflow::strings::StrCat(opcode.c_str(), "_On_", triple.c_str(),
- features.empty() ? "" : "_With",
- features.c_str());
+ return absl::StrCat(opcode.c_str(), "_On_", triple.c_str(),
+ features.empty() ? "" : "_With", features.c_str());
}
};
diff --git a/tensorflow/compiler/xla/service/defuser.h b/tensorflow/compiler/xla/service/defuser.h
index 56b28fd22d..c326beb899 100644
--- a/tensorflow/compiler/xla/service/defuser.h
+++ b/tensorflow/compiler/xla/service/defuser.h
@@ -29,7 +29,7 @@ class Defuser : public HloPassInterface {
public:
Defuser() {}
~Defuser() override {}
- tensorflow::StringPiece name() const override { return "defuser"; }
+ absl::string_view name() const override { return "defuser"; }
// Run defusion on the given module. Returns whether the module was
// changed.
diff --git a/tensorflow/compiler/xla/service/despecializer.cc b/tensorflow/compiler/xla/service/despecializer.cc
index 48e4471499..ba2a674d9a 100644
--- a/tensorflow/compiler/xla/service/despecializer.cc
+++ b/tensorflow/compiler/xla/service/despecializer.cc
@@ -27,9 +27,7 @@ namespace {
class ControlDepRemover : public HloPassInterface {
public:
ControlDepRemover() = default;
- tensorflow::StringPiece name() const override {
- return "control-dep-remover";
- }
+ absl::string_view name() const override { return "control-dep-remover"; }
StatusOr<bool> Run(HloModule* module) override {
bool changed = false;
diff --git a/tensorflow/compiler/xla/service/despecializer.h b/tensorflow/compiler/xla/service/despecializer.h
index cc1695b7f8..7be70add2f 100644
--- a/tensorflow/compiler/xla/service/despecializer.h
+++ b/tensorflow/compiler/xla/service/despecializer.h
@@ -33,7 +33,7 @@ namespace xla {
class Despecializer : public HloPassInterface {
public:
Despecializer();
- tensorflow::StringPiece name() const override { return "despecializer"; }
+ absl::string_view name() const override { return "despecializer"; }
StatusOr<bool> Run(HloModule* module) override;
private:
diff --git a/tensorflow/compiler/xla/service/dfs_hlo_visitor.h b/tensorflow/compiler/xla/service/dfs_hlo_visitor.h
index 690b5df514..275e6cc61d 100644
--- a/tensorflow/compiler/xla/service/dfs_hlo_visitor.h
+++ b/tensorflow/compiler/xla/service/dfs_hlo_visitor.h
@@ -19,13 +19,13 @@ limitations under the License.
#include <type_traits>
#include <vector>
+#include "absl/strings/string_view.h"
#include "tensorflow/compiler/xla/literal.h"
#include "tensorflow/compiler/xla/service/hlo_opcode.h"
#include "tensorflow/compiler/xla/status.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
#include "tensorflow/core/lib/core/status.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/gtl/array_slice.h"
#include "tensorflow/core/lib/gtl/flatmap.h"
#include "tensorflow/core/platform/macros.h"
diff --git a/tensorflow/compiler/xla/service/dfs_hlo_visitor_with_default.h b/tensorflow/compiler/xla/service/dfs_hlo_visitor_with_default.h
index 20c6bafe7c..6ec4893f7a 100644
--- a/tensorflow/compiler/xla/service/dfs_hlo_visitor_with_default.h
+++ b/tensorflow/compiler/xla/service/dfs_hlo_visitor_with_default.h
@@ -16,13 +16,13 @@ limitations under the License.
#ifndef TENSORFLOW_COMPILER_XLA_SERVICE_DFS_HLO_VISITOR_WITH_DEFAULT_H_
#define TENSORFLOW_COMPILER_XLA_SERVICE_DFS_HLO_VISITOR_WITH_DEFAULT_H_
+#include "absl/strings/string_view.h"
#include "tensorflow/compiler/xla/literal.h"
#include "tensorflow/compiler/xla/service/dfs_hlo_visitor.h"
#include "tensorflow/compiler/xla/service/hlo_opcode.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
#include "tensorflow/core/lib/core/status.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/gtl/array_slice.h"
#include "tensorflow/core/platform/macros.h"
#include "tensorflow/core/platform/types.h"
diff --git a/tensorflow/compiler/xla/service/dot_decomposer.h b/tensorflow/compiler/xla/service/dot_decomposer.h
index 1959b687f1..fc38e31700 100644
--- a/tensorflow/compiler/xla/service/dot_decomposer.h
+++ b/tensorflow/compiler/xla/service/dot_decomposer.h
@@ -29,7 +29,7 @@ class DotDecomposer : public HloPassInterface {
DotDecomposer(bool decompose_batch_dot = true)
: decompose_batch_dot_(decompose_batch_dot) {}
~DotDecomposer() = default;
- tensorflow::StringPiece name() const override { return "dot_decomposer"; }
+ absl::string_view name() const override { return "dot_decomposer"; }
// Run DotDecomposer pass on computations in 'module'.
// Returns whether the 'module' was changed.
diff --git a/tensorflow/compiler/xla/service/elemental_ir_emitter.cc b/tensorflow/compiler/xla/service/elemental_ir_emitter.cc
index cc7a87f9e8..fdb6b87519 100644
--- a/tensorflow/compiler/xla/service/elemental_ir_emitter.cc
+++ b/tensorflow/compiler/xla/service/elemental_ir_emitter.cc
@@ -22,6 +22,7 @@ limitations under the License.
// IWYU pragma: no_include "llvm/IR/Intrinsics.gen.inc"
#include "absl/algorithm/container.h"
+#include "absl/strings/str_cat.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Intrinsics.h"
@@ -39,17 +40,16 @@ limitations under the License.
#include "tensorflow/compiler/xla/util.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
#include "tensorflow/core/lib/random/random.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/types.h"
namespace xla {
+using absl::StrCat;
using llvm_ir::AsStringRef;
using llvm_ir::IrArray;
using llvm_ir::IrName;
using llvm_ir::SetToFirstInsertPoint;
-using tensorflow::strings::StrCat;
namespace {
diff --git a/tensorflow/compiler/xla/service/flatten_call_graph.h b/tensorflow/compiler/xla/service/flatten_call_graph.h
index d3efab3614..3cccec9862 100644
--- a/tensorflow/compiler/xla/service/flatten_call_graph.h
+++ b/tensorflow/compiler/xla/service/flatten_call_graph.h
@@ -28,7 +28,7 @@ namespace xla {
// points-to analysis (see b/36865746 for details).
class FlattenCallGraph : public HloPassInterface {
public:
- tensorflow::StringPiece name() const override { return "flatten-call-graph"; }
+ absl::string_view name() const override { return "flatten-call-graph"; }
// Duplicates computations called from multiple call- or while-nodes to
// flatten the call graph.
diff --git a/tensorflow/compiler/xla/service/gather_expander.h b/tensorflow/compiler/xla/service/gather_expander.h
index c1fc8574da..7bd9ea5984 100644
--- a/tensorflow/compiler/xla/service/gather_expander.h
+++ b/tensorflow/compiler/xla/service/gather_expander.h
@@ -25,7 +25,7 @@ namespace xla {
// nevertheless have a minimum level of support.
class GatherExpander : public HloPassInterface {
public:
- tensorflow::StringPiece name() const override { return "gather_expander"; }
+ absl::string_view name() const override { return "gather_expander"; }
StatusOr<bool> Run(HloModule* module) override;
private:
diff --git a/tensorflow/compiler/xla/service/gpu/BUILD b/tensorflow/compiler/xla/service/gpu/BUILD
index fbef487ac8..0440d80275 100644
--- a/tensorflow/compiler/xla/service/gpu/BUILD
+++ b/tensorflow/compiler/xla/service/gpu/BUILD
@@ -129,6 +129,7 @@ cc_library(
"//tensorflow/compiler/xla/service/llvm_ir:llvm_util",
"//tensorflow/compiler/xla/service/llvm_ir:tuple_ops",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
"@llvm//:core",
],
)
@@ -186,6 +187,7 @@ cc_library(
"@com_google_absl//absl/algorithm:container",
"@com_google_absl//absl/container:inlined_vector",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
"@com_google_absl//absl/types:optional",
"@llvm//:core",
"@llvm//:support",
@@ -231,6 +233,7 @@ cc_library(
"//tensorflow/compiler/xla/service/llvm_ir:loop_emitter",
"//tensorflow/compiler/xla/service/llvm_ir:math_ops",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
"@llvm//:core",
"@llvm//:support",
],
@@ -347,6 +350,7 @@ cc_library(
"//tensorflow/core/platform/default/build_config:stream_executor_cuda", # build_cleaner: keep
"//tensorflow/stream_executor",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
"@com_google_absl//absl/types:optional",
],
)
@@ -384,6 +388,7 @@ cc_library(
"//tensorflow/compiler/xla/service:hlo_pass",
"//tensorflow/core:lib",
"//tensorflow/core:stream_executor_no_cuda",
+ "@com_google_absl//absl/strings",
"@com_google_absl//absl/types:optional",
],
)
@@ -402,6 +407,7 @@ cc_library(
"//tensorflow/compiler/xla:util",
"//tensorflow/compiler/xla:xla_data_proto",
"//tensorflow/core:stream_executor_no_cuda",
+ "@com_google_absl//absl/strings",
],
)
@@ -496,6 +502,7 @@ tf_cc_test(
"//tensorflow/compiler/xla/tests:hlo_test_base",
"//tensorflow/compiler/xla/tests:xla_internal_test_main",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
],
)
@@ -687,6 +694,7 @@ cc_library(
"//tensorflow/core:regexp_internal",
"//tensorflow/core:stream_executor_no_cuda",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
"@com_google_absl//absl/types:optional",
"@llvm//:core",
],
@@ -775,6 +783,7 @@ tf_cc_test(
"//tensorflow/compiler/xla/service:hlo_parser",
"//tensorflow/compiler/xla/tests:hlo_test_base",
"//tensorflow/compiler/xla/tests:xla_internal_test_main", # build_cleaner: keep
+ "@com_google_absl//absl/strings",
],
)
@@ -888,9 +897,9 @@ cc_library(
"//tensorflow/compiler/xla/service:compiler",
"//tensorflow/compiler/xla/service:device_memory_allocator",
"//tensorflow/compiler/xla/service:hlo_parser",
- "//tensorflow/compiler/xla/service:hlo_runner",
"//tensorflow/core:lib",
"//tensorflow/core:stream_executor_no_cuda",
+ "@com_google_absl//absl/strings",
],
)
diff --git a/tensorflow/compiler/xla/service/gpu/buffer_comparator.cc b/tensorflow/compiler/xla/service/gpu/buffer_comparator.cc
index 6a285a6b98..f71796e611 100644
--- a/tensorflow/compiler/xla/service/gpu/buffer_comparator.cc
+++ b/tensorflow/compiler/xla/service/gpu/buffer_comparator.cc
@@ -16,6 +16,7 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/gpu/buffer_comparator.h"
#include <cmath>
+#include "absl/strings/str_replace.h"
#include "tensorflow/compiler/xla/service/hlo_parser.h"
#include "tensorflow/compiler/xla/status_macros.h"
#include "tensorflow/core/lib/strings/str_util.h"
@@ -74,9 +75,8 @@ ENTRY MaxDifference {
%error = f32[SIZE] divide(%sub_abs, %denominator)
ROOT %max_diff = f32[] reduce(%error, %zero_constant), dimensions={0}, to_apply=MaxF32
})";
- auto size_string = std::to_string(num_elements);
- return tensorflow::str_util::StringReplace(
- kF16CompHloText, "SIZE", {size_string.data(), size_string.size()}, true);
+ return absl::StrReplaceAll(kF16CompHloText,
+ {{"SIZE", absl::StrCat(num_elements)}});
}
StatusOr<F16BufferComparator> F16BufferComparator::Create(
diff --git a/tensorflow/compiler/xla/service/gpu/convolution_thunk.cc b/tensorflow/compiler/xla/service/gpu/convolution_thunk.cc
index 7833a4077e..854a2f50b2 100644
--- a/tensorflow/compiler/xla/service/gpu/convolution_thunk.cc
+++ b/tensorflow/compiler/xla/service/gpu/convolution_thunk.cc
@@ -17,11 +17,11 @@ limitations under the License.
#include <string>
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/service/gpu/cudnn_convolution_runner.h"
#include "tensorflow/compiler/xla/service/gpu/hlo_execution_profiler.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/compiler/xla/util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/lib/strings/stringprintf.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/stream_executor_no_cuda.h"
diff --git a/tensorflow/compiler/xla/service/gpu/cudnn_batchnorm_rewriter.h b/tensorflow/compiler/xla/service/gpu/cudnn_batchnorm_rewriter.h
index e09cde9abf..6e2e330edd 100644
--- a/tensorflow/compiler/xla/service/gpu/cudnn_batchnorm_rewriter.h
+++ b/tensorflow/compiler/xla/service/gpu/cudnn_batchnorm_rewriter.h
@@ -54,9 +54,7 @@ namespace gpu {
// BatchNormRewriter.
class CudnnBatchNormRewriter : public HloPassInterface {
public:
- tensorflow::StringPiece name() const override {
- return "cudnn_batchnorm_rewriter";
- }
+ absl::string_view name() const override { return "cudnn_batchnorm_rewriter"; }
StatusOr<bool> Run(HloModule* module) override;
};
diff --git a/tensorflow/compiler/xla/service/gpu/cudnn_batchnorm_thunk.cc b/tensorflow/compiler/xla/service/gpu/cudnn_batchnorm_thunk.cc
index 7b172812c3..18a76e8c26 100644
--- a/tensorflow/compiler/xla/service/gpu/cudnn_batchnorm_thunk.cc
+++ b/tensorflow/compiler/xla/service/gpu/cudnn_batchnorm_thunk.cc
@@ -17,11 +17,11 @@ limitations under the License.
#include <string>
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/service/gpu/hlo_execution_profiler.h"
#include "tensorflow/compiler/xla/service/gpu/ir_emission_utils.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/compiler/xla/util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/lib/strings/stringprintf.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/stream_executor_no_cuda.h"
diff --git a/tensorflow/compiler/xla/service/gpu/cudnn_convolution_algorithm_picker.cc b/tensorflow/compiler/xla/service/gpu/cudnn_convolution_algorithm_picker.cc
index 5a8fc76e85..3d421ebb69 100644
--- a/tensorflow/compiler/xla/service/gpu/cudnn_convolution_algorithm_picker.cc
+++ b/tensorflow/compiler/xla/service/gpu/cudnn_convolution_algorithm_picker.cc
@@ -14,6 +14,7 @@ limitations under the License.
==============================================================================*/
#include "tensorflow/compiler/xla/service/gpu/cudnn_convolution_algorithm_picker.h"
+#include "absl/strings/str_cat.h"
#include "absl/types/optional.h"
#include "tensorflow/compiler/xla/literal_util.h"
#include "tensorflow/compiler/xla/service/gpu/backend_configs.pb.h"
@@ -21,7 +22,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/gpu/convolution_thunk.h"
#include "tensorflow/compiler/xla/service/gpu/ir_emission_utils.h"
#include "tensorflow/core/lib/strings/numbers.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/mutex.h"
namespace xla {
@@ -128,14 +128,14 @@ std::vector<AlgorithmDesc> GetAlgorithms(CudnnConvKind kind,
string AlgorithmToString(const AlgorithmDesc& algo) {
if (algo.tensor_ops_enabled()) {
- return tensorflow::strings::StrCat(algo.algo_id(), "+TC");
+ return absl::StrCat(algo.algo_id(), "+TC");
}
- return tensorflow::strings::StrCat(algo.algo_id());
+ return absl::StrCat(algo.algo_id());
}
string NumBytesToString(int64 bytes) {
- return tensorflow::strings::StrCat(
- tensorflow::strings::HumanReadableNumBytes(bytes), " (", bytes, "B)");
+ return absl::StrCat(tensorflow::strings::HumanReadableNumBytes(bytes), " (",
+ bytes, "B)");
}
// Acquires a process-global lock on the device pointed to by the given
diff --git a/tensorflow/compiler/xla/service/gpu/cudnn_convolution_algorithm_picker.h b/tensorflow/compiler/xla/service/gpu/cudnn_convolution_algorithm_picker.h
index 472de2ff0f..f76d273e8c 100644
--- a/tensorflow/compiler/xla/service/gpu/cudnn_convolution_algorithm_picker.h
+++ b/tensorflow/compiler/xla/service/gpu/cudnn_convolution_algorithm_picker.h
@@ -39,7 +39,7 @@ class CudnnConvolutionAlgorithmPicker : public HloPassInterface {
Compiler* compiler)
: stream_exec_(stream_exec), allocator_(allocator), compiler_(compiler) {}
- tensorflow::StringPiece name() const override {
+ absl::string_view name() const override {
return "cudnn-convolution-algorithm-picker";
}
diff --git a/tensorflow/compiler/xla/service/gpu/cudnn_convolution_rewriter.h b/tensorflow/compiler/xla/service/gpu/cudnn_convolution_rewriter.h
index 0c0578d888..fbe7e98494 100644
--- a/tensorflow/compiler/xla/service/gpu/cudnn_convolution_rewriter.h
+++ b/tensorflow/compiler/xla/service/gpu/cudnn_convolution_rewriter.h
@@ -26,7 +26,7 @@ namespace gpu {
// backwards-input convolutions into CustomCall HLOs that call into cuDNN.
class CudnnConvolutionRewriter : public HloPassInterface {
public:
- tensorflow::StringPiece name() const override {
+ absl::string_view name() const override {
return "cudnn-convolution-rewriter";
}
diff --git a/tensorflow/compiler/xla/service/gpu/cudnn_convolution_runner.cc b/tensorflow/compiler/xla/service/gpu/cudnn_convolution_runner.cc
index 7b0d9e53d6..68086c86e9 100644
--- a/tensorflow/compiler/xla/service/gpu/cudnn_convolution_runner.cc
+++ b/tensorflow/compiler/xla/service/gpu/cudnn_convolution_runner.cc
@@ -14,6 +14,7 @@ limitations under the License.
==============================================================================*/
#include "tensorflow/compiler/xla/service/gpu/cudnn_convolution_runner.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/layout_util.h"
#include "tensorflow/compiler/xla/service/gpu/stream_executor_util.h"
#include "tensorflow/compiler/xla/shape_util.h"
@@ -56,7 +57,7 @@ class ScratchBufAllocator : public se::ScratchAllocator {
"Can't allocate twice from a ScratchBufAllocator.");
}
if (byte_size > scratch_.size()) {
- return se::port::InternalError(tensorflow::strings::StrCat(
+ return se::port::InternalError(absl::StrCat(
"Can't allocate ", byte_size,
" bytes from a ScratchBufAllocator of size ", scratch_.size()));
}
diff --git a/tensorflow/compiler/xla/service/gpu/elemental_ir_emitter.cc b/tensorflow/compiler/xla/service/gpu/elemental_ir_emitter.cc
index 9b6de115ad..2460d951bd 100644
--- a/tensorflow/compiler/xla/service/gpu/elemental_ir_emitter.cc
+++ b/tensorflow/compiler/xla/service/gpu/elemental_ir_emitter.cc
@@ -23,6 +23,8 @@ limitations under the License.
#include "tensorflow/core/platform/types.h"
// IWYU pragma: no_include "llvm/IR/Attributes.gen.inc"
// IWYU pragma: no_include "llvm/IR/Intrinsics.gen.inc"
+#include "absl/strings/str_cat.h"
+#include "absl/strings/string_view.h"
#include "llvm/ADT/APInt.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Instructions.h"
@@ -43,16 +45,14 @@ limitations under the License.
#include "tensorflow/compiler/xla/util.h"
#include "tensorflow/compiler/xla/window_util.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
-#include "tensorflow/core/lib/strings/strcat.h"
namespace xla {
namespace gpu {
+using absl::StrAppend;
using llvm_ir::IrArray;
using llvm_ir::IrName;
using llvm_ir::SetToFirstInsertPoint;
-using tensorflow::strings::StrAppend;
namespace {
// Returns whether operand is a floating-point literal with the given value.
diff --git a/tensorflow/compiler/xla/service/gpu/fft_thunk.cc b/tensorflow/compiler/xla/service/gpu/fft_thunk.cc
index 0cdddf8bcf..def595d217 100644
--- a/tensorflow/compiler/xla/service/gpu/fft_thunk.cc
+++ b/tensorflow/compiler/xla/service/gpu/fft_thunk.cc
@@ -17,10 +17,10 @@ limitations under the License.
#include <string>
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/service/gpu/hlo_execution_profiler.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/compiler/xla/util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/lib/strings/stringprintf.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/stream_executor_no_cuda.h"
diff --git a/tensorflow/compiler/xla/service/gpu/fusion_merger.cc b/tensorflow/compiler/xla/service/gpu/fusion_merger.cc
index 9b86e5315b..6a91a7ae9e 100644
--- a/tensorflow/compiler/xla/service/gpu/fusion_merger.cc
+++ b/tensorflow/compiler/xla/service/gpu/fusion_merger.cc
@@ -291,8 +291,7 @@ Status FusionInstructionMerger::HandleFusion(HloInstruction* fusion) {
<< " into users { "
<< tensorflow::str_util::Join(users, ", ",
[](string* out, HloInstruction* user) {
- tensorflow::strings::StrAppend(
- out, user->name());
+ absl::StrAppend(out, user->name());
})
<< " }";
// Remove 'fusion' instruction.
diff --git a/tensorflow/compiler/xla/service/gpu/fusion_merger.h b/tensorflow/compiler/xla/service/gpu/fusion_merger.h
index 4c523a66de..7e3f5775b8 100644
--- a/tensorflow/compiler/xla/service/gpu/fusion_merger.h
+++ b/tensorflow/compiler/xla/service/gpu/fusion_merger.h
@@ -34,7 +34,7 @@ namespace gpu {
//
class FusionMerger : public HloPassInterface {
public:
- tensorflow::StringPiece name() const override { return "fusion merger"; }
+ absl::string_view name() const override { return "fusion merger"; }
StatusOr<bool> Run(HloModule* module) override;
diff --git a/tensorflow/compiler/xla/service/gpu/gemm_thunk.cc b/tensorflow/compiler/xla/service/gpu/gemm_thunk.cc
index 74282c568c..2c02ec2584 100644
--- a/tensorflow/compiler/xla/service/gpu/gemm_thunk.cc
+++ b/tensorflow/compiler/xla/service/gpu/gemm_thunk.cc
@@ -17,8 +17,8 @@ limitations under the License.
#include <functional>
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/stream_executor_no_cuda.h"
#include "tensorflow/core/platform/types.h"
diff --git a/tensorflow/compiler/xla/service/gpu/gpu_copy_insertion.h b/tensorflow/compiler/xla/service/gpu/gpu_copy_insertion.h
index 0c6f9b511f..8ffae18fe8 100644
--- a/tensorflow/compiler/xla/service/gpu/gpu_copy_insertion.h
+++ b/tensorflow/compiler/xla/service/gpu/gpu_copy_insertion.h
@@ -27,7 +27,7 @@ namespace gpu {
// inserting kCopy instructions.
class GpuCopyInsertion : public HloPassInterface {
public:
- tensorflow::StringPiece name() const override { return "copy-insertion"; }
+ absl::string_view name() const override { return "copy-insertion"; }
StatusOr<bool> Run(HloModule* module) override;
diff --git a/tensorflow/compiler/xla/service/gpu/gpu_executable.h b/tensorflow/compiler/xla/service/gpu/gpu_executable.h
index 09a1d9c12b..627a05e240 100644
--- a/tensorflow/compiler/xla/service/gpu/gpu_executable.h
+++ b/tensorflow/compiler/xla/service/gpu/gpu_executable.h
@@ -19,6 +19,7 @@ limitations under the License.
#include <memory>
#include <string>
+#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "tensorflow/compiler/xla/service/buffer_assignment.h"
#include "tensorflow/compiler/xla/service/device_memory_allocator.h"
@@ -33,7 +34,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/tuple_points_to_analysis.h"
#include "tensorflow/compiler/xla/statusor.h"
#include "tensorflow/compiler/xla/types.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/gtl/array_slice.h"
#include "tensorflow/core/lib/gtl/flatmap.h"
#include "tensorflow/core/platform/macros.h"
diff --git a/tensorflow/compiler/xla/service/gpu/gpu_hlo_support_checker.h b/tensorflow/compiler/xla/service/gpu/gpu_hlo_support_checker.h
index d63e213d2b..bbb3340760 100644
--- a/tensorflow/compiler/xla/service/gpu/gpu_hlo_support_checker.h
+++ b/tensorflow/compiler/xla/service/gpu/gpu_hlo_support_checker.h
@@ -28,9 +28,7 @@ class GpuHloSupportChecker : public HloPassInterface {
GpuHloSupportChecker() = default;
~GpuHloSupportChecker() override = default;
- tensorflow::StringPiece name() const override {
- return "gpu_hlo_support_checker";
- }
+ absl::string_view name() const override { return "gpu_hlo_support_checker"; }
// Note: always returns false (no instructions are ever modified by this
// pass).
diff --git a/tensorflow/compiler/xla/service/gpu/gpu_layout_assignment_test.cc b/tensorflow/compiler/xla/service/gpu/gpu_layout_assignment_test.cc
index 286547ebae..fbc8ddf599 100644
--- a/tensorflow/compiler/xla/service/gpu/gpu_layout_assignment_test.cc
+++ b/tensorflow/compiler/xla/service/gpu/gpu_layout_assignment_test.cc
@@ -15,6 +15,7 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/gpu/gpu_layout_assignment.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/layout_util.h"
#include "tensorflow/compiler/xla/service/computation_layout.h"
#include "tensorflow/compiler/xla/service/gpu/ir_emission_utils.h"
@@ -119,7 +120,7 @@ TEST_F(LayoutAssignmentTest, BatchNormInference) {
for (const Shape& input_shape : AllLayoutsOf(shape)) {
for (const Shape& result_shape : AllLayoutsOf(shape)) {
- SCOPED_TRACE(tensorflow::strings::StrCat(
+ SCOPED_TRACE(absl::StrCat(
"input_shape=", ShapeUtil::HumanStringWithLayout(input_shape),
", result_shape=", ShapeUtil::HumanStringWithLayout(result_shape)));
@@ -192,7 +193,7 @@ TEST_F(LayoutAssignmentTest, BatchNormTraining) {
// Enumerate all combinations of shapes.
for (const Shape& input_shape : AllLayoutsOf(shape)) {
for (const Shape& result_shape : AllLayoutsOf(shape)) {
- SCOPED_TRACE(tensorflow::strings::StrCat(
+ SCOPED_TRACE(absl::StrCat(
"input_shape=", ShapeUtil::HumanStringWithLayout(input_shape),
", result_shape=", ShapeUtil::HumanStringWithLayout(result_shape)));
@@ -265,7 +266,7 @@ TEST_F(LayoutAssignmentTest, BatchNormGrad) {
for (const Shape& input_shape : AllLayoutsOf(shape)) {
for (const Shape& result_shape : AllLayoutsOf(shape)) {
for (int constrained_param_no : {0, 4}) {
- SCOPED_TRACE(tensorflow::strings::StrCat(
+ SCOPED_TRACE(absl::StrCat(
"input_shape=", ShapeUtil::HumanStringWithLayout(input_shape),
", result_shape=", ShapeUtil::HumanStringWithLayout(result_shape)));
diff --git a/tensorflow/compiler/xla/service/gpu/hlo_to_ir_bindings.cc b/tensorflow/compiler/xla/service/gpu/hlo_to_ir_bindings.cc
index 8c11cd0541..276bb209d9 100644
--- a/tensorflow/compiler/xla/service/gpu/hlo_to_ir_bindings.cc
+++ b/tensorflow/compiler/xla/service/gpu/hlo_to_ir_bindings.cc
@@ -15,6 +15,7 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/gpu/hlo_to_ir_bindings.h"
+#include "absl/strings/str_cat.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Instructions.h"
@@ -25,15 +26,14 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/llvm_ir/llvm_util.h"
#include "tensorflow/compiler/xla/service/llvm_ir/tuple_ops.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/types.h"
namespace xla {
namespace gpu {
-using tensorflow::strings::StrAppend;
-using tensorflow::strings::StrCat;
+using absl::StrAppend;
+using absl::StrCat;
void HloToIrBindings::EmitBasePointersForHlos(
tensorflow::gtl::ArraySlice<const HloInstruction*> io_hlos,
diff --git a/tensorflow/compiler/xla/service/gpu/ir_emission_utils.cc b/tensorflow/compiler/xla/service/gpu/ir_emission_utils.cc
index c349063c71..f544bcc919 100644
--- a/tensorflow/compiler/xla/service/gpu/ir_emission_utils.cc
+++ b/tensorflow/compiler/xla/service/gpu/ir_emission_utils.cc
@@ -215,7 +215,7 @@ bool IsReductionToVector(const HloInstruction& reduce) {
// This emits a device-side call to
// "i32 vprintf(i8* fmt, arguments_type* arguments)" in the driver; see
// http://docs.nvidia.com/cuda/ptx-writers-guide-to-interoperability/index.html#system-calls
-llvm::Value* EmitPrintf(tensorflow::StringPiece fmt,
+llvm::Value* EmitPrintf(absl::string_view fmt,
tensorflow::gtl::ArraySlice<llvm::Value*> arguments,
llvm::IRBuilder<>* builder) {
std::vector<llvm::Type*> argument_types;
diff --git a/tensorflow/compiler/xla/service/gpu/ir_emission_utils.h b/tensorflow/compiler/xla/service/gpu/ir_emission_utils.h
index 5d23a3d018..a35e250101 100644
--- a/tensorflow/compiler/xla/service/gpu/ir_emission_utils.h
+++ b/tensorflow/compiler/xla/service/gpu/ir_emission_utils.h
@@ -126,7 +126,7 @@ bool ImplementedAsLibraryCall(const HloInstruction& hlo);
bool IsReductionToVector(const HloInstruction& reduce);
// Emits call to "vprintf" with given format and arguments.
-llvm::Value* EmitPrintf(tensorflow::StringPiece fmt,
+llvm::Value* EmitPrintf(absl::string_view fmt,
tensorflow::gtl::ArraySlice<llvm::Value*> arguments,
llvm::IRBuilder<>* builder);
diff --git a/tensorflow/compiler/xla/service/gpu/ir_emitter.h b/tensorflow/compiler/xla/service/gpu/ir_emitter.h
index 561c683879..76e069fc41 100644
--- a/tensorflow/compiler/xla/service/gpu/ir_emitter.h
+++ b/tensorflow/compiler/xla/service/gpu/ir_emitter.h
@@ -22,6 +22,7 @@ limitations under the License.
#include <utility>
#include <vector>
+#include "absl/strings/string_view.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Value.h"
@@ -40,7 +41,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/statusor.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/gtl/array_slice.h"
#include "tensorflow/core/platform/types.h"
diff --git a/tensorflow/compiler/xla/service/gpu/ir_emitter_unnested.cc b/tensorflow/compiler/xla/service/gpu/ir_emitter_unnested.cc
index bda2986202..84043689bd 100644
--- a/tensorflow/compiler/xla/service/gpu/ir_emitter_unnested.cc
+++ b/tensorflow/compiler/xla/service/gpu/ir_emitter_unnested.cc
@@ -24,6 +24,7 @@ limitations under the License.
#include "absl/algorithm/container.h"
#include "absl/container/inlined_vector.h"
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "absl/types/optional.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/BasicBlock.h"
@@ -90,10 +91,10 @@ namespace {
using absl::InlinedVector;
using absl::nullopt;
using absl::optional;
+using absl::StrCat;
using llvm_ir::IrArray;
using llvm_ir::IrName;
using tensorflow::gtl::ArraySlice;
-using tensorflow::strings::StrCat;
// If a dimensions is smaller than this, untiled transposition may be more
// efficient.
@@ -801,8 +802,7 @@ Status IrEmitterUnnested::EmitReductionToScalar(
// // RoundUpToNextMultipleOf(Ceil(num_elems / kTileSize), warpSize),
// //
// // and threads_per_block is a multiple of warpSize.
- // reduce_kernel<<<num_blocks, threads_per_block>>>();
- //
+ // reduce_kernel //
auto loop_body_emitter = [=](const IrArray::Index& tile_index) -> Status {
const int num_reduces = reducers.size();
llvm::Type* element_ir_type =
diff --git a/tensorflow/compiler/xla/service/gpu/kernel_thunk.cc b/tensorflow/compiler/xla/service/gpu/kernel_thunk.cc
index 6305396635..d856299889 100644
--- a/tensorflow/compiler/xla/service/gpu/kernel_thunk.cc
+++ b/tensorflow/compiler/xla/service/gpu/kernel_thunk.cc
@@ -16,11 +16,11 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/gpu/kernel_thunk.h"
#include "absl/memory/memory.h"
+#include "absl/strings/string_view.h"
#include "tensorflow/compiler/xla/service/gpu/gpu_executable.h"
#include "tensorflow/compiler/xla/service/gpu/hlo_execution_profiler.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/compiler/xla/util.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/stream_executor_no_cuda.h"
@@ -41,8 +41,8 @@ Status KernelThunk::Initialize(const GpuExecutable& executable,
tensorflow::mutex_lock lock(mutex_);
if (!loader_spec_) {
loader_spec_.reset(new se::MultiKernelLoaderSpec(args_.size()));
- tensorflow::StringPiece ptx = executable.ptx();
- // Convert tensorflow::StringPiece to se::port::StringPiece because
+ absl::string_view ptx = executable.ptx();
+ // Convert absl::string_view to se::port::StringPiece because
// StreamExecutor uses the latter.
loader_spec_->AddCudaPtxInMemory(
se::port::StringPiece(ptx.data(), ptx.size()), kernel_name_);
diff --git a/tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/BUILD b/tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/BUILD
index 6bd9c58f83..ccf082c4c6 100644
--- a/tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/BUILD
+++ b/tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/BUILD
@@ -35,6 +35,7 @@ cc_library(
"//tensorflow/core:lib",
"//tensorflow/core:lib_internal",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
"@llvm//:amdgpu_code_gen",
"@llvm//:analysis",
"@llvm//:bit_reader",
diff --git a/tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/dump_ir_pass.cc b/tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/dump_ir_pass.cc
index 12a8a59488..a3c74507dd 100644
--- a/tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/dump_ir_pass.cc
+++ b/tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/dump_ir_pass.cc
@@ -15,12 +15,12 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/dump_ir_pass.h"
+#include "absl/strings/string_view.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/raw_ostream.h"
#include "tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/utils.h"
#include "tensorflow/compiler/xla/types.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/io/path.h"
#include "tensorflow/core/lib/strings/stringprintf.h"
#include "tensorflow/core/platform/logging.h"
@@ -86,7 +86,7 @@ void IrDumpingPassManager::run(llvm::Module &module) {
const llvm::PassInfo *PI =
llvm::PassRegistry::getPassRegistry()->getPassInfo(P->getPassID());
const string basename = ReplaceFilenameExtension(
- tensorflow::io::Basename(input_filename_),
+ absl::string_view(tensorflow::io::Basename(input_filename_)),
tensorflow::strings::Printf(
"pass-%02d.before.%s.ll", i,
(PI == nullptr ? "unknown" : PI->getPassArgument().data())));
diff --git a/tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/nvptx_backend_lib.cc b/tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/nvptx_backend_lib.cc
index cce6e48141..e677c87aac 100644
--- a/tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/nvptx_backend_lib.cc
+++ b/tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/nvptx_backend_lib.cc
@@ -27,6 +27,8 @@ limitations under the License.
#include "tensorflow/compiler/xla/status_macros.h"
#include "tensorflow/compiler/xla/util.h"
+#include "absl/strings/str_cat.h"
+#include "absl/strings/string_view.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringSet.h"
@@ -54,7 +56,6 @@ limitations under the License.
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
#include "llvm/Transforms/Scalar.h"
#include "tensorflow/compiler/xla/types.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/io/path.h"
#include "tensorflow/core/lib/strings/str_util.h"
#include "tensorflow/core/lib/strings/stringprintf.h"
@@ -107,8 +108,7 @@ static string GetLibdeviceFilename(const string& libdevice_dir_path,
<< ", " << compute_capability.second << ") ."
<< "Defaulting to libdevice for compute_" << libdevice_version;
}
- return tensorflow::strings::StrCat("libdevice.compute_", libdevice_version,
- ".10.bc");
+ return absl::StrCat("libdevice.compute_", libdevice_version, ".10.bc");
}
// Gets the GPU name as it's known to LLVM for a given compute capability. If
@@ -138,15 +138,16 @@ static string GetSmName(std::pair<int, int> compute_capability) {
<< "Defaulting to telling LLVM that we're compiling for sm_"
<< sm_version;
}
- return tensorflow::strings::StrCat("sm_", sm_version);
+ return absl::StrCat("sm_", sm_version);
}
// Convenience function for producing a name of a temporary compilation product
// from the input filename.
string MakeNameForTempProduct(const std::string& input_filename,
- tensorflow::StringPiece extension) {
- return ReplaceFilenameExtension(
- tensorflow::io::Basename(llvm_ir::AsString(input_filename)), extension);
+ absl::string_view extension) {
+ return ReplaceFilenameExtension(absl::string_view(tensorflow::io::Basename(
+ llvm_ir::AsString(input_filename))),
+ extension);
}
// Initializes LLVM passes. Uses the PassRegistry mechanism.
@@ -167,7 +168,7 @@ void InitializePasses(llvm::PassRegistry* pass_registry) {
// Returns the TargetMachine, given a triple.
std::unique_ptr<llvm::TargetMachine> GetTargetMachine(
- llvm::Triple triple, tensorflow::StringPiece cpu_name,
+ llvm::Triple triple, absl::string_view cpu_name,
const HloModuleConfig& hlo_module_config) {
std::string error;
const llvm::Target* target = TargetRegistry::lookupTarget("", triple, error);
@@ -243,9 +244,9 @@ void AddOptimizationPasses(unsigned opt_level, unsigned size_level,
}
// Emits the given module to a bit code file.
-void EmitBitcodeToFile(const Module& module, tensorflow::StringPiece filename) {
+void EmitBitcodeToFile(const Module& module, absl::string_view filename) {
std::error_code error_code;
- llvm::ToolOutputFile outfile(filename.ToString().c_str(), error_code,
+ llvm::ToolOutputFile outfile(string(filename).c_str(), error_code,
llvm::sys::fs::F_None);
if (error_code) {
LOG(FATAL) << "opening bitcode file for writing: " << error_code.message();
@@ -266,8 +267,9 @@ string EmitModuleToPTX(Module* module, llvm::TargetMachine* target_machine) {
// get creative to add a suffix.
string module_id(llvm_ir::AsString(module->getModuleIdentifier()));
IrDumpingPassManager codegen_passes(
- ReplaceFilenameExtension(tensorflow::io::Basename(module_id),
- "-nvptx.dummy"),
+ ReplaceFilenameExtension(
+ absl::string_view(tensorflow::io::Basename(module_id)),
+ "-nvptx.dummy"),
"", false);
codegen_passes.add(new llvm::TargetLibraryInfoWrapperPass(
llvm::Triple(module->getTargetTriple())));
@@ -332,8 +334,8 @@ Status LinkLibdeviceIfNecessary(llvm::Module* module,
return !GV.hasName() || (GVS.count(GV.getName()) == 0);
});
})) {
- return tensorflow::errors::Internal(tensorflow::strings::StrCat(
- "Error linking libdevice from ", libdevice_path));
+ return tensorflow::errors::Internal(
+ absl::StrCat("Error linking libdevice from ", libdevice_path));
}
return Status::OK();
}
diff --git a/tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/nvptx_backend_lib.h b/tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/nvptx_backend_lib.h
index 54e0e140de..9654175bfa 100644
--- a/tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/nvptx_backend_lib.h
+++ b/tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/nvptx_backend_lib.h
@@ -20,11 +20,11 @@ limitations under the License.
#include <string>
#include <utility>
+#include "absl/strings/string_view.h"
#include "llvm/IR/Module.h"
#include "tensorflow/compiler/xla/service/hlo_module_config.h"
#include "tensorflow/compiler/xla/statusor.h"
#include "tensorflow/compiler/xla/types.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
namespace xla {
namespace gpu {
diff --git a/tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/utils.cc b/tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/utils.cc
index 9ef9bc3a50..3b2c3591d9 100644
--- a/tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/utils.cc
+++ b/tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/utils.cc
@@ -17,13 +17,13 @@ limitations under the License.
#include "tensorflow/core/platform/logging.h"
+#include "absl/strings/str_cat.h"
+#include "absl/strings/string_view.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IRReader/IRReader.h"
#include "llvm/Support/SourceMgr.h"
#include "tensorflow/compiler/xla/types.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
-#include "tensorflow/core/lib/strings/strcat.h"
namespace {
@@ -52,14 +52,13 @@ std::unique_ptr<llvm::Module> LoadIRModule(const string& filename,
return module;
}
-string ReplaceFilenameExtension(tensorflow::StringPiece filename,
- tensorflow::StringPiece new_extension) {
+string ReplaceFilenameExtension(absl::string_view filename,
+ absl::string_view new_extension) {
auto pos = filename.rfind('.');
- tensorflow::StringPiece stem =
- pos == tensorflow::StringPiece::npos
- ? filename
- : tensorflow::StringPiece(filename.data(), pos);
- return tensorflow::strings::StrCat(stem, ".", new_extension);
+ absl::string_view stem = pos == absl::string_view::npos
+ ? filename
+ : absl::string_view(filename.data(), pos);
+ return absl::StrCat(stem, ".", new_extension);
}
} // namespace gpu
diff --git a/tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/utils.h b/tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/utils.h
index a6daeca95a..60f4926849 100644
--- a/tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/utils.h
+++ b/tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/utils.h
@@ -18,8 +18,8 @@ limitations under the License.
#include <memory>
#include <string>
+#include "absl/strings/string_view.h"
#include "tensorflow/compiler/xla/types.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
namespace llvm {
class LLVMContext;
@@ -41,8 +41,8 @@ std::unique_ptr<llvm::Module> LoadIRModule(const string& filename,
//
// For example:
// ReplaceFilenameExtension("/foo/baz.txt", "cc") --> "/foo/baz.cc"
-string ReplaceFilenameExtension(tensorflow::StringPiece filename,
- tensorflow::StringPiece new_extension);
+string ReplaceFilenameExtension(absl::string_view filename,
+ absl::string_view new_extension);
} // namespace gpu
} // namespace xla
diff --git a/tensorflow/compiler/xla/service/gpu/multi_output_fusion_test.cc b/tensorflow/compiler/xla/service/gpu/multi_output_fusion_test.cc
index 072f885bc1..50d2f10c23 100644
--- a/tensorflow/compiler/xla/service/gpu/multi_output_fusion_test.cc
+++ b/tensorflow/compiler/xla/service/gpu/multi_output_fusion_test.cc
@@ -15,6 +15,7 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/gpu/multi_output_fusion.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/service/gpu/instruction_fusion.h"
#include "tensorflow/compiler/xla/service/hlo_matchers.h"
#include "tensorflow/compiler/xla/service/hlo_parser.h"
@@ -47,7 +48,7 @@ const char kModulePrefix[] = R"(
TEST_F(MultiOutputFusionTest, MultiOutputFusionSiblingReduceAndReduceFusion) {
// Fusion with reduce instruction root and a sibling reduce instruction
// sharing the same input param.
- auto module = ParseHloString(tensorflow::strings::StrCat(kModulePrefix, R"(
+ auto module = ParseHloString(absl::StrCat(kModulePrefix, R"(
fused_computation {
p1.1 = f32[128,512,28,28]{3,2,1,0} parameter(1)
mul = f32[128,512,28,28]{3,2,1,0} multiply(p1.1, p1.1)
@@ -74,7 +75,7 @@ TEST_F(MultiOutputFusionTest, MultiOutputFusionSiblingReduceAndReduceFusion) {
}
TEST_F(MultiOutputFusionTest, MultiOutputFusionDifferentReduceInputShapes) {
- auto module = ParseHloString(tensorflow::strings::StrCat(kModulePrefix, R"(
+ auto module = ParseHloString(absl::StrCat(kModulePrefix, R"(
fused_computation_1 {
p1.1 = f32[6400]{0} parameter(1)
mul = f32[6400]{0} multiply(p1.1, p1.1)
@@ -101,7 +102,7 @@ TEST_F(MultiOutputFusionTest, MultiOutputFusionDifferentReduceInputShapes) {
}
TEST_F(MultiOutputFusionTest, MultiOutputFusionDifferentReduceOutputShapes) {
- auto module = ParseHloString(tensorflow::strings::StrCat(kModulePrefix, R"(
+ auto module = ParseHloString(absl::StrCat(kModulePrefix, R"(
fused_computation_1 {
p1.1 = f32[10,10]{1,0} parameter(1)
mul = f32[10,10]{1,0} multiply(p1.1, p1.1)
@@ -130,7 +131,7 @@ TEST_F(MultiOutputFusionTest, MultiOutputFusionDifferentReduceOutputShapes) {
TEST_F(MultiOutputFusionTest, MultiOutputFusionSiblingReduceFusions) {
// Two sibling fusions with reduce instruction roots sharing the same input
// param.
- auto module = ParseHloString(tensorflow::strings::StrCat(kModulePrefix, R"(
+ auto module = ParseHloString(absl::StrCat(kModulePrefix, R"(
fused_computation_1 {
p1.1 = f32[128,512,28,28]{3,2,1,0} parameter(1)
mul = f32[128,512,28,28]{3,2,1,0} multiply(p1.1, p1.1)
@@ -165,7 +166,7 @@ TEST_F(MultiOutputFusionTest,
MultiOutputFusionSiblingReduceAndReduceMultiOutputFusion) {
// Multi-output fusion with two reduce instructions root and a sibling reduce
// instruction sharing the same input param.
- auto module = ParseHloString(tensorflow::strings::StrCat(kModulePrefix, R"(
+ auto module = ParseHloString(absl::StrCat(kModulePrefix, R"(
fused_computation (p0: f32[128,512,28,28]) -> (f32[512], f32[512]) {
const.1 = f32[] constant(1)
p0.1 = f32[128,512,28,28]{3,2,1,0} parameter(0)
@@ -198,7 +199,7 @@ TEST_F(MultiOutputFusionTest,
MultiOutputFusionSiblingFusionCheckAgainstReduceOperand) {
// Verify that if we already have a multi-output fusion that we prefer to pick
// a reduce op from its operands for checking shape compatibility.
- auto module = ParseHloString(tensorflow::strings::StrCat(kModulePrefix, R"(
+ auto module = ParseHloString(absl::StrCat(kModulePrefix, R"(
fused_computation_1 {
p1.1 = f32[10,10]{1,0} parameter(1)
mul = f32[10,10]{1,0} multiply(p1.1, p1.1)
@@ -228,7 +229,7 @@ TEST_F(MultiOutputFusionTest,
}
TEST_F(MultiOutputFusionTest, MultiOutputFusionTwoLoops) {
- auto module = ParseHloString(tensorflow::strings::StrCat(kModulePrefix, R"(
+ auto module = ParseHloString(absl::StrCat(kModulePrefix, R"(
fused_computation_1 {
p0.1 = f32[6400]{0} parameter(0)
ROOT mul = f32[6400]{0} multiply(p0.1, p0.1)
@@ -341,7 +342,7 @@ TEST_F(MultiOutputFusionTest,
}
TEST_F(MultiOutputFusionTest, ProducerConsumerFusionElementwiseAndReduce) {
- auto module = ParseHloString(tensorflow::strings::StrCat(kModulePrefix, R"(
+ auto module = ParseHloString(absl::StrCat(kModulePrefix, R"(
ENTRY reduce {
p0 = f32[2,2,2]{2,1,0} parameter(0)
c0 = f32[] constant(0)
@@ -361,7 +362,7 @@ TEST_F(MultiOutputFusionTest, ProducerConsumerFusionElementwiseAndReduce) {
}
TEST_F(MultiOutputFusionTest, ProducerConsumerFusionLoopFusionAndReduce) {
- auto module = ParseHloString(tensorflow::strings::StrCat(kModulePrefix, R"(
+ auto module = ParseHloString(absl::StrCat(kModulePrefix, R"(
fused_add {
p0.1 = f32[2,2,2]{2,1,0} parameter(0)
p1.1 = f32[2,2,2]{2,1,0} parameter(1)
@@ -388,7 +389,7 @@ TEST_F(MultiOutputFusionTest, ProducerConsumerFusionLoopFusionAndReduce) {
}
TEST_F(MultiOutputFusionTest, ProducerConsumerFusionLoopFusionAndReduceFusion) {
- auto module = ParseHloString(tensorflow::strings::StrCat(kModulePrefix, R"(
+ auto module = ParseHloString(absl::StrCat(kModulePrefix, R"(
fused_select {
p1.1 = f32[2,2,2]{2,1,0} parameter(1)
c0 = f32[] constant(0)
@@ -429,7 +430,7 @@ TEST_F(MultiOutputFusionTest, ProducerConsumerFusionLoopFusionAndReduceFusion) {
}
TEST_F(MultiOutputFusionTest, ProducerConsumerFusionDoNotFuseLoopReduceFusion) {
- auto module = ParseHloString(tensorflow::strings::StrCat(kModulePrefix, R"(
+ auto module = ParseHloString(absl::StrCat(kModulePrefix, R"(
fused_element_wise {
p0.1 = f32[2,2,2]{2,1,0} parameter(0)
p1.1 = f32[2,2,2]{2,1,0} parameter(1)
@@ -456,7 +457,7 @@ TEST_F(MultiOutputFusionTest, ProducerConsumerFusionDoNotFuseLoopReduceFusion) {
TEST_F(MultiOutputFusionTest,
ProducerConsumerFusionFp16LoopFusionAndReduceFusion) {
- auto module = ParseHloString(tensorflow::strings::StrCat(kModulePrefix, R"(
+ auto module = ParseHloString(absl::StrCat(kModulePrefix, R"(
fused_select {
p1.1 = f16[2,2,2]{2,1,0} parameter(1)
c0 = f16[] constant(0)
@@ -497,7 +498,7 @@ TEST_F(MultiOutputFusionTest,
TEST_F(MultiOutputFusionTest,
ProducerConsumerFusionReduceUnfriendlyLoopFusion) {
- auto module = ParseHloString(tensorflow::strings::StrCat(kModulePrefix, R"(
+ auto module = ParseHloString(absl::StrCat(kModulePrefix, R"(
mixed_input_layouts_computation {
p0.1 = f16[128,1024,32,32]{1,3,2,0} parameter(0)
p1.1 = f16[128,1024,32,32]{3,2,1,0} parameter(1)
diff --git a/tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc b/tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc
index 5868c1a42e..d9369f00cc 100644
--- a/tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc
+++ b/tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc
@@ -22,6 +22,8 @@ limitations under the License.
#include <utility>
#include "absl/memory/memory.h"
+#include "absl/strings/numbers.h"
+#include "absl/strings/str_cat.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/DiagnosticPrinter.h"
#include "llvm/IR/LLVMContext.h"
@@ -85,7 +87,6 @@ limitations under the License.
#include "tensorflow/core/lib/core/status.h"
#include "tensorflow/core/lib/gtl/cleanup.h"
#include "tensorflow/core/lib/io/path.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/cuda_libdevice_path.h"
#include "tensorflow/core/platform/env.h"
#include "tensorflow/core/platform/logging.h"
@@ -352,9 +353,9 @@ void WarnIfBadPtxasVersion(const string& ptxas_path) {
string vmaj_str, vmin_str, vdot_str;
if (!RE2::PartialMatch(out, R"(\bV(\d+)\.(\d+)\.(\d+)\b)", &vmaj_str,
&vmin_str, &vdot_str) ||
- !tensorflow::strings::safe_strto64(vmaj_str, &vmaj) ||
- !tensorflow::strings::safe_strto64(vmin_str, &vmin) ||
- !tensorflow::strings::safe_strto64(vdot_str, &vdot)) {
+ !absl::SimpleAtoi(vmaj_str, &vmaj) ||
+ !absl::SimpleAtoi(vmin_str, &vmin) ||
+ !absl::SimpleAtoi(vdot_str, &vdot)) {
LOG(WARNING) << "Couldn't parse ptxas version in output of " << ptxas_path
<< " --version:\n"
<< out;
@@ -466,7 +467,7 @@ StatusOr<std::vector<uint8>> CompilePtx(const string& ptx, int cc_major,
tensorflow::SubProcess ptxas_info_dumper;
std::vector<string> ptxas_args = {
ptxas_path, ptx_path, "-o", cubin_path,
- tensorflow::strings::StrCat("-arch=sm_", cc_major, cc_minor)};
+ absl::StrCat("-arch=sm_", cc_major, cc_minor)};
if (VLOG_IS_ON(2)) {
ptxas_args.push_back("-v");
}
@@ -674,7 +675,7 @@ StatusOr<std::unique_ptr<Executable>> NVPTXCompiler::RunBackend(
// Write PTX to IR dump directory, if IR dumping was requested.
if (!ir_dump_directory.empty()) {
const string ptx_outfile = tensorflow::io::JoinPath(
- ir_dump_directory, tensorflow::strings::StrCat(module->name(), ".ptx"));
+ ir_dump_directory, absl::StrCat(module->name(), ".ptx"));
auto status = [&] {
auto* env = tensorflow::Env::Default();
TF_RETURN_IF_ERROR(env->RecursivelyCreateDir(ir_dump_directory));
diff --git a/tensorflow/compiler/xla/service/gpu/pad_for_tensor_cores.h b/tensorflow/compiler/xla/service/gpu/pad_for_tensor_cores.h
index 192359f026..11dc56a64f 100644
--- a/tensorflow/compiler/xla/service/gpu/pad_for_tensor_cores.h
+++ b/tensorflow/compiler/xla/service/gpu/pad_for_tensor_cores.h
@@ -32,9 +32,7 @@ namespace gpu {
// TODO(jlebar): Also pad dots.
class PadForTensorCores : public HloPassInterface {
public:
- tensorflow::StringPiece name() const override {
- return "pad for tensor cores";
- }
+ absl::string_view name() const override { return "pad for tensor cores"; }
StatusOr<bool> Run(HloModule* module) override;
};
diff --git a/tensorflow/compiler/xla/service/gpu/pad_insertion.h b/tensorflow/compiler/xla/service/gpu/pad_insertion.h
index 67e51509e4..a622e894ed 100644
--- a/tensorflow/compiler/xla/service/gpu/pad_insertion.h
+++ b/tensorflow/compiler/xla/service/gpu/pad_insertion.h
@@ -26,7 +26,7 @@ namespace gpu {
// padding, so that they can be lowered to cuDNN convolution.
class PadInsertion : public HloPassInterface {
public:
- tensorflow::StringPiece name() const override { return "pad insertion"; }
+ absl::string_view name() const override { return "pad insertion"; }
StatusOr<bool> Run(HloModule* module) override;
diff --git a/tensorflow/compiler/xla/service/gpu/parallel_loop_emitter.cc b/tensorflow/compiler/xla/service/gpu/parallel_loop_emitter.cc
index 3838fee674..ca57cacb98 100644
--- a/tensorflow/compiler/xla/service/gpu/parallel_loop_emitter.cc
+++ b/tensorflow/compiler/xla/service/gpu/parallel_loop_emitter.cc
@@ -57,8 +57,8 @@ ParallelLoopEmitter::ParallelLoopEmitter(
unroll_factor_(unroll_factor) {}
std::vector<llvm_ir::IrArray::Index>
-ParallelLoopEmitter::EmitIndexAndSetExitBasicBlock(
- tensorflow::StringPiece loop_name, llvm::Type* index_type) {
+ParallelLoopEmitter::EmitIndexAndSetExitBasicBlock(absl::string_view loop_name,
+ llvm::Type* index_type) {
// Emit the following code in LLVM IR:
// linear_index = blockIdx.x * blockDim.x + threadIdx.x;
// if (linear_index < num_elements) {
diff --git a/tensorflow/compiler/xla/service/gpu/parallel_loop_emitter.h b/tensorflow/compiler/xla/service/gpu/parallel_loop_emitter.h
index b82a23419d..cc7da2e73b 100644
--- a/tensorflow/compiler/xla/service/gpu/parallel_loop_emitter.h
+++ b/tensorflow/compiler/xla/service/gpu/parallel_loop_emitter.h
@@ -58,7 +58,7 @@ class ParallelLoopEmitter : public llvm_ir::LoopEmitter {
~ParallelLoopEmitter() override = default;
std::vector<llvm_ir::IrArray::Index> EmitIndexAndSetExitBasicBlock(
- tensorflow::StringPiece loop_name, llvm::Type* index_type) override;
+ absl::string_view loop_name, llvm::Type* index_type) override;
private:
// The thread and block dimension to parallelize the loop on.
diff --git a/tensorflow/compiler/xla/service/gpu/thunk_schedule.cc b/tensorflow/compiler/xla/service/gpu/thunk_schedule.cc
index bdb062837c..141f321938 100644
--- a/tensorflow/compiler/xla/service/gpu/thunk_schedule.cc
+++ b/tensorflow/compiler/xla/service/gpu/thunk_schedule.cc
@@ -144,16 +144,15 @@ const std::list<const Thunk*>& ThunkSchedule::DependsOn(
string ThunkSchedule::ToString() const {
string result = "Total order:\n";
for (Thunk* thunk : thunk_total_order_) {
- tensorflow::strings::StrAppend(&result, "\t",
- thunk->hlo_instruction()->ToString(), "\n");
+ absl::StrAppend(&result, "\t", thunk->hlo_instruction()->ToString(), "\n");
}
- tensorflow::strings::StrAppend(&result, "Dependencies:\n");
+ absl::StrAppend(&result, "Dependencies:\n");
for (const auto& entry : depends_on_) {
const Thunk* dependent = entry.first;
for (const Thunk* dependency : entry.second) {
- tensorflow::strings::StrAppend(
- &result, "\t", dependent->hlo_instruction()->name(), " depends on ",
- dependency->hlo_instruction()->name(), "\n");
+ absl::StrAppend(&result, "\t", dependent->hlo_instruction()->name(),
+ " depends on ", dependency->hlo_instruction()->name(),
+ "\n");
}
}
return result;
diff --git a/tensorflow/compiler/xla/service/graphviz_example.cc b/tensorflow/compiler/xla/service/graphviz_example.cc
index 31431f115f..a2be89511b 100644
--- a/tensorflow/compiler/xla/service/graphviz_example.cc
+++ b/tensorflow/compiler/xla/service/graphviz_example.cc
@@ -23,6 +23,7 @@ limitations under the License.
#include <string>
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/literal.h"
#include "tensorflow/compiler/xla/literal_util.h"
#include "tensorflow/compiler/xla/service/hlo_computation.h"
@@ -33,7 +34,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/shape_util.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/init_main.h"
#include "tensorflow/core/platform/types.h"
@@ -43,8 +43,7 @@ namespace {
// Adds a computation to the given HLO module which adds a scalar constant to
// its parameter and returns the result.
HloComputation* AddScalarConstantComputation(int64 addend, HloModule* module) {
- auto builder =
- HloComputation::Builder(tensorflow::strings::StrCat("add_", addend));
+ auto builder = HloComputation::Builder(absl::StrCat("add_", addend));
auto x_value = builder.AddInstruction(HloInstruction::CreateParameter(
0, ShapeUtil::MakeShape(F32, {}), "x_value"));
auto half = builder.AddInstruction(
diff --git a/tensorflow/compiler/xla/service/hlo_alias_analysis.cc b/tensorflow/compiler/xla/service/hlo_alias_analysis.cc
index 0ca489846e..e9a2ef26e0 100644
--- a/tensorflow/compiler/xla/service/hlo_alias_analysis.cc
+++ b/tensorflow/compiler/xla/service/hlo_alias_analysis.cc
@@ -20,6 +20,7 @@ limitations under the License.
#include <utility>
#include <vector>
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/map_util.h"
#include "tensorflow/compiler/xla/service/hlo_buffer.h"
#include "tensorflow/compiler/xla/service/hlo_instruction.h"
@@ -29,14 +30,13 @@ limitations under the License.
#include "tensorflow/compiler/xla/util.h"
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/logging.h"
namespace xla {
+using ::absl::StrAppend;
+using ::absl::StrCat;
using ::tensorflow::str_util::Join;
-using ::tensorflow::strings::StrAppend;
-using ::tensorflow::strings::StrCat;
// Data structure used to construct the alias analysis. Thrown away after alias
// analysis is complete. This data structure keeps track of which sets of
diff --git a/tensorflow/compiler/xla/service/hlo_buffer.cc b/tensorflow/compiler/xla/service/hlo_buffer.cc
index e16413f361..cfa662c26f 100644
--- a/tensorflow/compiler/xla/service/hlo_buffer.cc
+++ b/tensorflow/compiler/xla/service/hlo_buffer.cc
@@ -20,6 +20,7 @@ limitations under the License.
#include <utility>
#include <vector>
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/map_util.h"
#include "tensorflow/compiler/xla/service/hlo_instruction.h"
#include "tensorflow/compiler/xla/shape_util.h"
@@ -28,13 +29,12 @@ limitations under the License.
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/gtl/flatset.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/logging.h"
namespace xla {
+using ::absl::StrCat;
using ::tensorflow::str_util::Join;
-using ::tensorflow::strings::StrCat;
bool HloBuffer::operator==(const HloBuffer& other) const {
bool equal = id() == other.id();
diff --git a/tensorflow/compiler/xla/service/hlo_computation.cc b/tensorflow/compiler/xla/service/hlo_computation.cc
index 4c036ea1bf..ae334b2713 100644
--- a/tensorflow/compiler/xla/service/hlo_computation.cc
+++ b/tensorflow/compiler/xla/service/hlo_computation.cc
@@ -25,6 +25,8 @@ limitations under the License.
#include "absl/algorithm/container.h"
#include "absl/memory/memory.h"
+#include "absl/strings/numbers.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/layout_util.h"
#include "tensorflow/compiler/xla/map_util.h"
#include "tensorflow/compiler/xla/service/dfs_hlo_visitor_with_default.h"
@@ -38,12 +40,11 @@ limitations under the License.
#include "tensorflow/core/lib/core/status.h"
#include "tensorflow/core/lib/gtl/flatset.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/logging.h"
namespace xla {
-using ::tensorflow::strings::StrCat;
+using ::absl::StrCat;
std::unique_ptr<HloComputation> HloComputation::Builder::Build(
HloInstruction* root_instruction) {
@@ -136,7 +137,7 @@ string RenameFusionParameter(const string& original_name, int64 new_param_no) {
}
string after_param = original_name.substr(index + param_underscore.size());
int64 numeric_suffix;
- if (tensorflow::strings::safe_strto64(after_param, &numeric_suffix)) {
+ if (absl::SimpleAtoi(after_param, &numeric_suffix)) {
return StrCat(original_name.substr(0, index + param_underscore.size()),
new_param_no);
}
@@ -808,7 +809,7 @@ std::vector<HloInstruction*> HloComputation::CollectUnreachableRoots() const {
<< tensorflow::str_util::Join(
unreachable_roots, "\n\t",
[](string* out, const HloInstruction* hlo) {
- tensorflow::strings::StrAppend(out, hlo->ToString());
+ absl::StrAppend(out, hlo->ToString());
});
return unreachable_roots;
}
@@ -980,8 +981,7 @@ void HloComputation::UniquifyName(NameUniquer* name_uniquer) {
name_ = name_uniquer->GetUniqueName(name_);
}
-HloInstruction* HloComputation::GetInstructionWithName(
- tensorflow::StringPiece name) {
+HloInstruction* HloComputation::GetInstructionWithName(absl::string_view name) {
auto instructions_in_computation = instructions();
auto it = absl::c_find_if(
instructions_in_computation,
diff --git a/tensorflow/compiler/xla/service/hlo_computation.h b/tensorflow/compiler/xla/service/hlo_computation.h
index faa33f0f90..8d9b694977 100644
--- a/tensorflow/compiler/xla/service/hlo_computation.h
+++ b/tensorflow/compiler/xla/service/hlo_computation.h
@@ -367,7 +367,7 @@ class HloComputation {
// Returns the instruction in this computation that has name `name`. Returns
// null if there is no such computation.
- HloInstruction* GetInstructionWithName(tensorflow::StringPiece name);
+ HloInstruction* GetInstructionWithName(absl::string_view name);
int64 unique_id() const { return unique_id_; }
diff --git a/tensorflow/compiler/xla/service/hlo_constant_folding.h b/tensorflow/compiler/xla/service/hlo_constant_folding.h
index 331480bd02..4557983a9c 100644
--- a/tensorflow/compiler/xla/service/hlo_constant_folding.h
+++ b/tensorflow/compiler/xla/service/hlo_constant_folding.h
@@ -25,7 +25,7 @@ namespace xla {
// computation on constants.
class HloConstantFolding : public HloPassInterface {
public:
- tensorflow::StringPiece name() const override { return "constant_folding"; }
+ absl::string_view name() const override { return "constant_folding"; }
// Run constant folding operations on the given module. Returns whether the
// module was changed (constant expressions folded).
diff --git a/tensorflow/compiler/xla/service/hlo_creation_utils.cc b/tensorflow/compiler/xla/service/hlo_creation_utils.cc
index c4e27dc558..0ceb6a2968 100644
--- a/tensorflow/compiler/xla/service/hlo_creation_utils.cc
+++ b/tensorflow/compiler/xla/service/hlo_creation_utils.cc
@@ -16,14 +16,15 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/hlo_creation_utils.h"
#include "absl/algorithm/container.h"
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/literal.h"
#include "tensorflow/compiler/xla/literal_util.h"
#include "tensorflow/compiler/xla/service/shape_inference.h"
#include "tensorflow/compiler/xla/util.h"
namespace xla {
+using absl::StrCat;
using tensorflow::gtl::ArraySlice;
-using tensorflow::strings::StrCat;
StatusOr<HloInstruction*> MakeBinaryHlo(HloOpcode opcode, HloInstruction* lhs,
HloInstruction* rhs) {
@@ -336,7 +337,7 @@ StatusOr<HloInstruction*> BroadcastZeros(
StatusOr<std::unique_ptr<HloComputation>> CreateComputationWithSignature(
ArraySlice<const Shape*> domain, const Shape& range,
- tensorflow::StringPiece name) {
+ absl::string_view name) {
HloComputation::Builder b{std::string(name)};
int64 param_idx = 0;
for (const Shape* param_shape : domain) {
diff --git a/tensorflow/compiler/xla/service/hlo_creation_utils.h b/tensorflow/compiler/xla/service/hlo_creation_utils.h
index 5ff8946fb0..1bc6d09b45 100644
--- a/tensorflow/compiler/xla/service/hlo_creation_utils.h
+++ b/tensorflow/compiler/xla/service/hlo_creation_utils.h
@@ -177,7 +177,7 @@ StatusOr<HloInstruction*> BroadcastZeros(
// a value of type `range`.
StatusOr<std::unique_ptr<HloComputation>> CreateComputationWithSignature(
tensorflow::gtl::ArraySlice<const Shape*> domain, const Shape& range,
- tensorflow::StringPiece name);
+ absl::string_view name);
} // namespace xla
diff --git a/tensorflow/compiler/xla/service/hlo_cse.h b/tensorflow/compiler/xla/service/hlo_cse.h
index 5e2b348bdd..a28c03599a 100644
--- a/tensorflow/compiler/xla/service/hlo_cse.h
+++ b/tensorflow/compiler/xla/service/hlo_cse.h
@@ -34,7 +34,7 @@ class HloCSE : public HloPassInterface {
: is_layout_sensitive_(is_layout_sensitive),
only_fusion_computations_(only_fusion_computations) {}
~HloCSE() override = default;
- tensorflow::StringPiece name() const override { return "cse"; }
+ absl::string_view name() const override { return "cse"; }
// Run CSE on the given module. Returns whether the module was changed (common
// subexpressions were found and eliminated).
diff --git a/tensorflow/compiler/xla/service/hlo_dataflow_analysis.cc b/tensorflow/compiler/xla/service/hlo_dataflow_analysis.cc
index 01840a56e2..36d3bfc3a6 100644
--- a/tensorflow/compiler/xla/service/hlo_dataflow_analysis.cc
+++ b/tensorflow/compiler/xla/service/hlo_dataflow_analysis.cc
@@ -21,6 +21,7 @@ limitations under the License.
#include "absl/container/inlined_vector.h"
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/map_util.h"
#include "tensorflow/compiler/xla/service/hlo_computation.h"
#include "tensorflow/compiler/xla/service/hlo_instruction.h"
@@ -31,7 +32,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/util.h"
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/logging.h"
namespace xla {
@@ -79,8 +79,8 @@ bool MultiDynamicSliceUseShareSameIndices(
} // namespace
-using ::tensorflow::strings::StrAppend;
-using ::tensorflow::strings::StrCat;
+using ::absl::StrAppend;
+using ::absl::StrCat;
HloDataflowAnalysis::HloDataflowAnalysis(
const HloModule& module, bool ssa_form, bool bitcast_defines_value,
diff --git a/tensorflow/compiler/xla/service/hlo_dce.h b/tensorflow/compiler/xla/service/hlo_dce.h
index 4e244494d6..1fe69b1395 100644
--- a/tensorflow/compiler/xla/service/hlo_dce.h
+++ b/tensorflow/compiler/xla/service/hlo_dce.h
@@ -36,7 +36,7 @@ namespace xla {
class HloDCE : public HloPassInterface {
public:
~HloDCE() override {}
- tensorflow::StringPiece name() const override { return "dce"; }
+ absl::string_view name() const override { return "dce"; }
// Run the pass on the given module. Returns whether the module was changed
// (instructions were removed).
diff --git a/tensorflow/compiler/xla/service/hlo_domain_isolator.h b/tensorflow/compiler/xla/service/hlo_domain_isolator.h
index 844e948209..d36631fc2f 100644
--- a/tensorflow/compiler/xla/service/hlo_domain_isolator.h
+++ b/tensorflow/compiler/xla/service/hlo_domain_isolator.h
@@ -43,7 +43,7 @@ class HloDomainIsolator : public HloPassInterface {
explicit HloDomainIsolator(DomainCreator creator);
- tensorflow::StringPiece name() const override { return "domain_isolator"; }
+ absl::string_view name() const override { return "domain_isolator"; }
StatusOr<bool> Run(HloModule* module) override;
diff --git a/tensorflow/compiler/xla/service/hlo_domain_metadata.h b/tensorflow/compiler/xla/service/hlo_domain_metadata.h
index f855f2a1fc..575149c8b8 100644
--- a/tensorflow/compiler/xla/service/hlo_domain_metadata.h
+++ b/tensorflow/compiler/xla/service/hlo_domain_metadata.h
@@ -20,10 +20,10 @@ limitations under the License.
#include <string>
#include <vector>
+#include "absl/strings/string_view.h"
#include "tensorflow/compiler/xla/statusor.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/core/lib/core/status.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/gtl/flatset.h"
namespace xla {
@@ -63,7 +63,7 @@ class DomainMetadata {
// Returns the metadata type. A unique identifier which describes the real
// metadata type.
- virtual tensorflow::StringPiece Kind() const = 0;
+ virtual absl::string_view Kind() const = 0;
// Compares the metadata object with another one and returns true if the
// two matches.
diff --git a/tensorflow/compiler/xla/service/hlo_domain_remover.h b/tensorflow/compiler/xla/service/hlo_domain_remover.h
index c859e05f02..97bc8ef604 100644
--- a/tensorflow/compiler/xla/service/hlo_domain_remover.h
+++ b/tensorflow/compiler/xla/service/hlo_domain_remover.h
@@ -35,13 +35,13 @@ class HloDomainRemover : public HloPassInterface {
// instructions in it with the same attributes (ie, sharding), a normalizer
// function is tasked at applying attribute normalization on the instructions
// within such domain.
- HloDomainRemover(tensorflow::StringPiece kind,
+ HloDomainRemover(absl::string_view kind,
std::function<Status(const DomainMetadata::Domain&,
const DomainMetadata* metadata)>
normalizer)
- : kind_(kind.ToString()), normalizer_(std::move(normalizer)) {}
+ : kind_(kind), normalizer_(std::move(normalizer)) {}
- tensorflow::StringPiece name() const override { return "domain_remover"; }
+ absl::string_view name() const override { return "domain_remover"; }
StatusOr<bool> Run(HloModule* module) override;
diff --git a/tensorflow/compiler/xla/service/hlo_domain_test.cc b/tensorflow/compiler/xla/service/hlo_domain_test.cc
index 893273a4e1..648228b825 100644
--- a/tensorflow/compiler/xla/service/hlo_domain_test.cc
+++ b/tensorflow/compiler/xla/service/hlo_domain_test.cc
@@ -46,9 +46,8 @@ class HloDomainTest : public HloVerifiedTestBase {
// Checks whether there is a kDomain instruction in the edge between the
// instruction and the operand.
- bool HasDomainEdge(HloModule* module,
- tensorflow::StringPiece instruction_name,
- tensorflow::StringPiece operand_name) {
+ bool HasDomainEdge(HloModule* module, absl::string_view instruction_name,
+ absl::string_view operand_name) {
HloInstruction* instruction = FindInstruction(module, instruction_name);
HloInstruction* operand = FindInstruction(module, operand_name);
CHECK_NE(instruction, nullptr);
@@ -66,7 +65,7 @@ class HloDomainTest : public HloVerifiedTestBase {
return false;
}
- StatusOr<HloModule*> ParseModule(tensorflow::StringPiece hlo_string) {
+ StatusOr<HloModule*> ParseModule(absl::string_view hlo_string) {
HloModuleConfig config;
config.set_debug_options(legacy_flags::GetDebugOptionsFromFlags());
ParseAndVerifyModule(hlo_string, config);
@@ -84,7 +83,7 @@ class OpNameMetadata : public DomainMetadata {
return absl::make_unique<OpNameMetadata>(opname_);
}
- tensorflow::StringPiece Kind() const override { return KindName(); }
+ absl::string_view Kind() const override { return KindName(); }
bool Matches(const DomainMetadata& other) const override {
const OpNameMetadata* other_ptr =
@@ -98,7 +97,7 @@ class OpNameMetadata : public DomainMetadata {
string ToString() const override { return opname_; }
- static tensorflow::StringPiece KindName() { return "opname"; }
+ static absl::string_view KindName() { return "opname"; }
private:
string opname_;
diff --git a/tensorflow/compiler/xla/service/hlo_domain_verifier.cc b/tensorflow/compiler/xla/service/hlo_domain_verifier.cc
index 751fc677e2..dc514ae3e5 100644
--- a/tensorflow/compiler/xla/service/hlo_domain_verifier.cc
+++ b/tensorflow/compiler/xla/service/hlo_domain_verifier.cc
@@ -52,7 +52,7 @@ Status HloDomainVerifier::RunContext::PopulateDomainKinds() {
TF_RET_CHECK(instruction->user_side_metadata().Kind() ==
instruction->operand_side_metadata().Kind())
<< instruction->ToString();
- kinds.insert(instruction->user_side_metadata().Kind().ToString());
+ kinds.insert(string(instruction->user_side_metadata().Kind()));
}
}
}
diff --git a/tensorflow/compiler/xla/service/hlo_domain_verifier.h b/tensorflow/compiler/xla/service/hlo_domain_verifier.h
index 8e53cf97f8..81d6d69a8c 100644
--- a/tensorflow/compiler/xla/service/hlo_domain_verifier.h
+++ b/tensorflow/compiler/xla/service/hlo_domain_verifier.h
@@ -33,7 +33,7 @@ class HloDomainVerifier : public HloPassInterface {
public:
HloDomainVerifier(std::vector<string> kinds) : kinds_(std::move(kinds)) {}
- tensorflow::StringPiece name() const override { return "domain_verifier"; }
+ absl::string_view name() const override { return "domain_verifier"; }
StatusOr<bool> Run(HloModule* module) override;
diff --git a/tensorflow/compiler/xla/service/hlo_element_type_converter.h b/tensorflow/compiler/xla/service/hlo_element_type_converter.h
index 2b109225d0..44ded2c2fa 100644
--- a/tensorflow/compiler/xla/service/hlo_element_type_converter.h
+++ b/tensorflow/compiler/xla/service/hlo_element_type_converter.h
@@ -32,9 +32,7 @@ class HloElementTypeConverter : public HloPassInterface {
HloElementTypeConverter(PrimitiveType eliminate_type,
PrimitiveType replace_with_type);
- tensorflow::StringPiece name() const override {
- return "element_type_converter";
- }
+ absl::string_view name() const override { return "element_type_converter"; }
// Returns the pass on the module and returns whether the module was modified.
StatusOr<bool> Run(HloModule* module) override;
diff --git a/tensorflow/compiler/xla/service/hlo_evaluator.cc b/tensorflow/compiler/xla/service/hlo_evaluator.cc
index fb90049491..ca1c4dd0e9 100644
--- a/tensorflow/compiler/xla/service/hlo_evaluator.cc
+++ b/tensorflow/compiler/xla/service/hlo_evaluator.cc
@@ -25,6 +25,7 @@ limitations under the License.
#include "absl/algorithm/container.h"
#include "absl/memory/memory.h"
+#include "absl/strings/string_view.h"
#include "tensorflow/compiler/xla/index_util.h"
#include "tensorflow/compiler/xla/layout_util.h"
#include "tensorflow/compiler/xla/literal.h"
@@ -44,7 +45,6 @@ limitations under the License.
#include "tensorflow/core/lib/core/casts.h"
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/core/status.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/protobuf.h"
#include "tensorflow/core/platform/types.h"
diff --git a/tensorflow/compiler/xla/service/hlo_execution_profile_test.cc b/tensorflow/compiler/xla/service/hlo_execution_profile_test.cc
index eba80c0f19..460ae2b5ec 100644
--- a/tensorflow/compiler/xla/service/hlo_execution_profile_test.cc
+++ b/tensorflow/compiler/xla/service/hlo_execution_profile_test.cc
@@ -14,15 +14,15 @@ limitations under the License.
==============================================================================*/
#include "tensorflow/compiler/xla/service/hlo_execution_profile.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/service/hlo_cost_analysis.h"
#include "tensorflow/compiler/xla/service/hlo_parser.h"
#include "tensorflow/compiler/xla/tests/hlo_test_base.h"
-#include "tensorflow/core/lib/strings/strcat.h"
namespace xla {
namespace {
-using tensorflow::strings::StrCat;
+using absl::StrCat;
using ::testing::AllOf;
using ::testing::ContainsRegex;
diff --git a/tensorflow/compiler/xla/service/hlo_graph_dumper.cc b/tensorflow/compiler/xla/service/hlo_graph_dumper.cc
index f8ade39e8c..a9a8e97af3 100644
--- a/tensorflow/compiler/xla/service/hlo_graph_dumper.cc
+++ b/tensorflow/compiler/xla/service/hlo_graph_dumper.cc
@@ -26,6 +26,9 @@ limitations under the License.
#include <unordered_map>
#include <vector>
+#include "absl/strings/match.h"
+#include "absl/strings/str_cat.h"
+#include "absl/strings/str_replace.h"
#include "absl/types/optional.h"
#include "tensorflow/compiler/xla/layout_util.h"
#include "tensorflow/compiler/xla/literal.h"
@@ -41,7 +44,6 @@ limitations under the License.
#include "tensorflow/core/lib/io/path.h"
#include "tensorflow/core/lib/strings/numbers.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/lib/strings/stringprintf.h"
#include "tensorflow/core/platform/env.h"
#include "tensorflow/core/platform/protobuf.h"
@@ -49,13 +51,12 @@ limitations under the License.
using ::absl::nullopt;
using ::absl::optional;
+using ::absl::StrAppend;
+using ::absl::StrCat;
using ::tensorflow::Env;
using ::tensorflow::WriteStringToFile;
using ::tensorflow::io::JoinPath;
using ::tensorflow::str_util::Join;
-using ::tensorflow::str_util::StringReplace;
-using ::tensorflow::strings::StrAppend;
-using ::tensorflow::strings::StrCat;
namespace xla {
namespace hlo_graph_dumper {
@@ -217,9 +218,8 @@ string NodeColorAttributes(ColorScheme color) {
// Replaces <> with &lt;&gt;, so that this string is safe(er) for use in a
// graphviz HTML-like string.
-string HtmlLikeStringSanitize(tensorflow::StringPiece s) {
- return StringReplace(StringReplace(s, "<", "&lt;", /*replace_all=*/true), ">",
- "&gt;", /*replace_all=*/true);
+string HtmlLikeStringSanitize(absl::string_view s) {
+ return absl::StrReplaceAll(s, {{"<", "&lt;"}, {">", "&gt;"}});
}
// Tries to generates a human-readable one-word description of the given
@@ -322,7 +322,7 @@ optional<string> MatchTrivialComputation(const HloComputation* computation) {
// Encapsulates logic for dumping an HLO module to DOT (i.e. graphviz syntax).
class HloDotDumper {
public:
- HloDotDumper(const HloComputation* computation, tensorflow::StringPiece label,
+ HloDotDumper(const HloComputation* computation, absl::string_view label,
const DebugOptions& debug_options, bool show_backend_config,
const HloExecutionProfile* profile, NodeFilter filter)
: computation_(computation),
@@ -854,7 +854,7 @@ string HloDotDumper::GetInstructionNodeInlinedOperands(
// Otherwise, print e.g. "%constant.42 (s32[100])".
string constant_name;
- if (tensorflow::str_util::StartsWith(constant->name(), "constant")) {
+ if (absl::StartsWith(constant->name(), "constant")) {
constant_name = constant->name();
} else {
constant_name = StrCat("constant ", constant->name());
@@ -1084,8 +1084,7 @@ string HloDotDumper::GetInstructionNodeLabel(const HloInstruction* instr) {
// The HLO instruction name contains usually the opcode, e.g. "%add.42" is
// an add instruction. In this case we render just the name.
- if (tensorflow::str_util::StartsWith(instr->name(),
- HloOpcodeString(instr->opcode()))) {
+ if (absl::StartsWith(instr->name(), HloOpcodeString(instr->opcode()))) {
return Printf("<b>%s</b>", HtmlLikeStringSanitize(instr->name()));
}
string extended_opcode =
@@ -1160,8 +1159,7 @@ string HloDotDumper::GetInstructionNodeExtraInfo(const HloInstruction* instr) {
constexpr int kMaxShapeLen = 64;
if (instr_shape.length() > kMaxShapeLen) {
instr_shape = StrCat(
- tensorflow::StringPiece(instr_shape).substr(0, kMaxShapeLen - 3),
- "...");
+ absl::string_view(instr_shape).substr(0, kMaxShapeLen - 3), "...");
}
lines.push_back(instr_shape);
}
diff --git a/tensorflow/compiler/xla/service/hlo_graph_dumper_test.cc b/tensorflow/compiler/xla/service/hlo_graph_dumper_test.cc
index 1d7a062c55..4b7d25e2f4 100644
--- a/tensorflow/compiler/xla/service/hlo_graph_dumper_test.cc
+++ b/tensorflow/compiler/xla/service/hlo_graph_dumper_test.cc
@@ -15,6 +15,7 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/hlo_graph_dumper.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/literal_util.h"
#include "tensorflow/compiler/xla/service/hlo_computation.h"
#include "tensorflow/compiler/xla/service/hlo_instruction.h"
@@ -23,12 +24,11 @@ limitations under the License.
#include "tensorflow/compiler/xla/test.h"
#include "tensorflow/compiler/xla/tests/test_utils.h"
#include "tensorflow/compiler/xla/xla.pb.h"
-#include "tensorflow/core/lib/strings/strcat.h"
namespace xla {
namespace {
-using ::tensorflow::strings::StrCat;
+using ::absl::StrCat;
using ::testing::HasSubstr;
string TestName() {
diff --git a/tensorflow/compiler/xla/service/hlo_instruction.cc b/tensorflow/compiler/xla/service/hlo_instruction.cc
index 668ed9d6c3..c7322d0f97 100644
--- a/tensorflow/compiler/xla/service/hlo_instruction.cc
+++ b/tensorflow/compiler/xla/service/hlo_instruction.cc
@@ -24,6 +24,9 @@ limitations under the License.
#include "absl/algorithm/container.h"
#include "absl/container/inlined_vector.h"
#include "absl/memory/memory.h"
+#include "absl/strings/escaping.h"
+#include "absl/strings/numbers.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/layout_util.h"
#include "tensorflow/compiler/xla/literal.h"
#include "tensorflow/compiler/xla/protobuf_util.h"
@@ -42,16 +45,15 @@ limitations under the License.
#include "tensorflow/core/lib/gtl/flatset.h"
#include "tensorflow/core/lib/gtl/map_util.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/human_readable_json.h"
#include "tensorflow/core/platform/logging.h"
namespace xla {
-using tensorflow::str_util::CEscape;
+using absl::CEscape;
+using ::absl::StrAppend;
+using ::absl::StrCat;
using ::tensorflow::str_util::Join;
-using ::tensorflow::strings::StrAppend;
-using ::tensorflow::strings::StrCat;
/* static */
StatusOr<std::unique_ptr<HloInstruction>> HloInstruction::CreateFromProto(
@@ -664,8 +666,7 @@ HloInstruction::CreateReducePrecision(const Shape& shape,
HloInstruction::CreateCrossReplicaSum(
const Shape& shape, tensorflow::gtl::ArraySlice<HloInstruction*> operands,
HloComputation* reduce_computation,
- const std::vector<ReplicaGroup>& replica_groups,
- tensorflow::StringPiece barrier,
+ const std::vector<ReplicaGroup>& replica_groups, absl::string_view barrier,
const absl::optional<int64>& all_reduce_id) {
return absl::make_unique<HloAllReduceInstruction>(
shape, operands, reduce_computation, replica_groups, barrier,
@@ -688,7 +689,7 @@ HloInstruction::CreateCrossReplicaSum(
/* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateOutfeed(
const Shape& outfeed_shape, HloInstruction* operand,
- HloInstruction* token_operand, tensorflow::StringPiece outfeed_config) {
+ HloInstruction* token_operand, absl::string_view outfeed_config) {
return absl::make_unique<HloOutfeedInstruction>(
outfeed_shape, operand, token_operand, outfeed_config);
}
@@ -1066,7 +1067,7 @@ bool HloInstruction::HasSideEffect() const {
/* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateCustomCall(
const Shape& shape, tensorflow::gtl::ArraySlice<HloInstruction*> operands,
- tensorflow::StringPiece custom_call_target) {
+ absl::string_view custom_call_target) {
return absl::make_unique<HloCustomCallInstruction>(shape, operands,
custom_call_target);
}
@@ -1345,7 +1346,7 @@ std::unique_ptr<HloInstruction> HloInstruction::Clone(
// If names ends with .suffix[0-9]+ then replace with a suffix with the
// numeric value incremented.
int64 numeric_suffix;
- if (tensorflow::strings::safe_strto64(after_suffix, &numeric_suffix)) {
+ if (absl::SimpleAtoi(after_suffix, &numeric_suffix)) {
clone->name_ =
StrCat(name().substr(0, index), dot_suffix, numeric_suffix + 1);
} else {
diff --git a/tensorflow/compiler/xla/service/hlo_instruction.h b/tensorflow/compiler/xla/service/hlo_instruction.h
index 432bb464f3..566c1c449a 100644
--- a/tensorflow/compiler/xla/service/hlo_instruction.h
+++ b/tensorflow/compiler/xla/service/hlo_instruction.h
@@ -34,6 +34,8 @@ limitations under the License.
#include "absl/container/inlined_vector.h"
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
+#include "absl/strings/string_view.h"
#include "tensorflow/compiler/xla/iterator_util.h"
#include "tensorflow/compiler/xla/literal.h"
#include "tensorflow/compiler/xla/map_util.h"
@@ -47,7 +49,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
#include "tensorflow/core/lib/core/status.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/gtl/array_slice.h"
#include "tensorflow/core/lib/gtl/flatmap.h"
#include "tensorflow/core/lib/gtl/iterator_range.h"
@@ -222,7 +223,7 @@ class CanonicalNameMap {
return iter->second;
}
- string new_name = tensorflow::strings::StrCat("tmp_", index++);
+ string new_name = absl::StrCat("tmp_", index++);
canonical_name_map[old_name] = new_name;
return new_name;
}
@@ -450,8 +451,7 @@ class HloInstruction {
const Shape& shape, tensorflow::gtl::ArraySlice<HloInstruction*> operands,
HloComputation* reduce_computation,
const std::vector<ReplicaGroup>& replica_groups,
- tensorflow::StringPiece barrier,
- const absl::optional<int64>& all_reduce_id);
+ absl::string_view barrier, const absl::optional<int64>& all_reduce_id);
// This op handles the communication of an Alltoall operation. On each core,
// the operands are N ops in the same shape, where N is the number of cores
@@ -493,7 +493,7 @@ class HloInstruction {
// which is a TOKEN.
static std::unique_ptr<HloInstruction> CreateOutfeed(
const Shape& outfeed_shape, HloInstruction* operand,
- HloInstruction* token_operand, tensorflow::StringPiece outfeed_config);
+ HloInstruction* token_operand, absl::string_view outfeed_config);
// Creates an asynchronous send instruction with the given channel id, which
// initiates sending the operand data to a unique receive instruction in
@@ -706,7 +706,7 @@ class HloInstruction {
// to the given operands. "shape" is the resultant shape.
static std::unique_ptr<HloInstruction> CreateCustomCall(
const Shape& shape, tensorflow::gtl::ArraySlice<HloInstruction*> operands,
- tensorflow::StringPiece custom_call_target);
+ absl::string_view custom_call_target);
// Creates a tuple instruction with the given elements. This is a convenience
// wrapper around CreateVariadic.
diff --git a/tensorflow/compiler/xla/service/hlo_instructions.cc b/tensorflow/compiler/xla/service/hlo_instructions.cc
index 2a99d4d7c4..9a8ddb551b 100644
--- a/tensorflow/compiler/xla/service/hlo_instructions.cc
+++ b/tensorflow/compiler/xla/service/hlo_instructions.cc
@@ -19,6 +19,9 @@ limitations under the License.
#include "absl/algorithm/container.h"
#include "absl/memory/memory.h"
+#include "absl/strings/escaping.h"
+#include "absl/strings/str_cat.h"
+#include "absl/strings/str_split.h"
#include "tensorflow/compiler/xla/literal_util.h"
#include "tensorflow/compiler/xla/service/hlo_casting_utils.h"
#include "tensorflow/compiler/xla/service/hlo_computation.h"
@@ -29,10 +32,10 @@ limitations under the License.
namespace xla {
namespace {
-using ::tensorflow::str_util::CEscape;
+using ::absl::CEscape;
+using ::absl::StrAppend;
+using ::absl::StrCat;
using ::tensorflow::str_util::Join;
-using ::tensorflow::strings::StrAppend;
-using ::tensorflow::strings::StrCat;
bool IsInstructionElementwiseOnOperand(const HloInstruction* instruction,
const HloInstruction* operand) {
@@ -343,11 +346,11 @@ bool HloCollectiveInstruction::IdenticalSlowPath(
HloAllReduceInstruction::HloAllReduceInstruction(
const Shape& shape, tensorflow::gtl::ArraySlice<HloInstruction*> operands,
HloComputation* reduce_computation,
- const std::vector<ReplicaGroup>& replica_groups,
- tensorflow::StringPiece barrier, const absl::optional<int64>& all_reduce_id)
+ const std::vector<ReplicaGroup>& replica_groups, absl::string_view barrier,
+ const absl::optional<int64>& all_reduce_id)
: HloCollectiveInstruction(HloOpcode::kCrossReplicaSum, shape, operands,
replica_groups),
- cross_replica_sum_barrier_(barrier.begin(), barrier.end()),
+ cross_replica_sum_barrier_(barrier),
all_reduce_id_(all_reduce_id) {
AppendComputation(reduce_computation);
}
@@ -853,7 +856,7 @@ string HloConstantInstruction::OperandsToStringWithCanonicalNameMap(
// lines. Compact this into one line by stripping out white space.
string tmp = literal().ToString();
std::replace(tmp.begin(), tmp.end(), '\n', ' ');
- std::vector<string> v = tensorflow::str_util::Split(tmp, ' ');
+ std::vector<string> v = absl::StrSplit(tmp, ' ');
bool first = true;
// Concatenate elements in "v" with spaces separating them, but ignoring
// empty entries.
@@ -1554,12 +1557,13 @@ std::unique_ptr<HloInstruction> HloInfeedInstruction::CloneWithNewOperandsImpl(
infeed_shape(), new_operands[0], infeed_config());
}
-HloOutfeedInstruction::HloOutfeedInstruction(
- const Shape& outfeed_shape, HloInstruction* operand,
- HloInstruction* token_operand, tensorflow::StringPiece outfeed_config)
+HloOutfeedInstruction::HloOutfeedInstruction(const Shape& outfeed_shape,
+ HloInstruction* operand,
+ HloInstruction* token_operand,
+ absl::string_view outfeed_config)
: HloInstruction(HloOpcode::kOutfeed, ShapeUtil::MakeTokenShape()),
outfeed_shape_(outfeed_shape),
- outfeed_config_(outfeed_config.begin(), outfeed_config.end()) {
+ outfeed_config_(outfeed_config) {
CHECK(ShapeUtil::Compatible(operand->shape(), outfeed_shape))
<< "Outfeed shape " << outfeed_shape
<< " must be compatible with operand shape " << operand->shape();
@@ -1767,7 +1771,7 @@ HloSelectAndScatterInstruction::CloneWithNewOperandsImpl(
HloCustomCallInstruction::HloCustomCallInstruction(
const Shape& shape, tensorflow::gtl::ArraySlice<HloInstruction*> operands,
- tensorflow::StringPiece custom_call_target)
+ absl::string_view custom_call_target)
: HloInstruction(HloOpcode::kCustomCall, shape),
custom_call_target_(custom_call_target.begin(),
custom_call_target.end()) {
diff --git a/tensorflow/compiler/xla/service/hlo_instructions.h b/tensorflow/compiler/xla/service/hlo_instructions.h
index 19e98c6fb4..efdb9e9781 100644
--- a/tensorflow/compiler/xla/service/hlo_instructions.h
+++ b/tensorflow/compiler/xla/service/hlo_instructions.h
@@ -248,8 +248,7 @@ class HloAllReduceInstruction : public HloCollectiveInstruction {
const Shape& shape, tensorflow::gtl::ArraySlice<HloInstruction*> operands,
HloComputation* reduce_computation,
const std::vector<ReplicaGroup>& replica_groups,
- tensorflow::StringPiece barrier,
- const absl::optional<int64>& all_reduce_id);
+ absl::string_view barrier, const absl::optional<int64>& all_reduce_id);
// Returns the barrier config used for the CrossReplicaSum implementation of
// each backend.
@@ -908,7 +907,7 @@ class HloOutfeedInstruction : public HloInstruction {
explicit HloOutfeedInstruction(const Shape& outfeed_shape,
HloInstruction* operand,
HloInstruction* token_operand,
- tensorflow::StringPiece outfeed_config);
+ absl::string_view outfeed_config);
// Returns the shape for the Outfeed instruction.
const Shape& outfeed_shape() const {
TF_DCHECK_OK(ShapeUtil::ValidateShapeWithOptionalLayout(outfeed_shape_));
@@ -1061,7 +1060,7 @@ class HloCustomCallInstruction : public HloInstruction {
public:
explicit HloCustomCallInstruction(
const Shape& shape, tensorflow::gtl::ArraySlice<HloInstruction*> operands,
- tensorflow::StringPiece custom_call_target);
+ absl::string_view custom_call_target);
const Window& window() const override {
CHECK(window_ != nullptr);
return *window_;
diff --git a/tensorflow/compiler/xla/service/hlo_lexer.cc b/tensorflow/compiler/xla/service/hlo_lexer.cc
index 2e01b090be..e352f09540 100644
--- a/tensorflow/compiler/xla/service/hlo_lexer.cc
+++ b/tensorflow/compiler/xla/service/hlo_lexer.cc
@@ -17,6 +17,8 @@ limitations under the License.
#include <unordered_map>
+#include "absl/strings/escaping.h"
+#include "absl/strings/numbers.h"
#include "absl/types/optional.h"
#include "tensorflow/compiler/xla/shape_util.h"
#include "tensorflow/compiler/xla/statusor.h"
@@ -27,7 +29,7 @@ limitations under the License.
namespace xla {
-using ::tensorflow::StringPiece;
+using ::absl::string_view;
namespace {
@@ -66,12 +68,12 @@ bool HloLexer::CanDereference(const char* ptr) const {
return ptr < buf_.end() && ptr >= buf_.begin();
}
-tensorflow::StringPiece HloLexer::StringPieceFromPointers(
- const char* begin, const char* end) const {
+absl::string_view HloLexer::StringPieceFromPointers(const char* begin,
+ const char* end) const {
CHECK(begin <= end);
CHECK(begin == buf_.end() || CanDereference(begin));
CHECK(end == buf_.end() || CanDereference(end));
- return tensorflow::StringPiece(begin, end - begin);
+ return absl::string_view(begin, end - begin);
}
tensorflow::RegexpStringPiece HloLexer::RegexpStringPieceFromPointers(
@@ -235,7 +237,7 @@ TokKind HloLexer::LexIdentifier() {
return TokKind::kAttributeName;
}
- tensorflow::StringPiece identifier =
+ absl::string_view identifier =
StringPieceFromPointers(token_start_, current_ptr_);
// See if this is a keyword.
@@ -306,8 +308,8 @@ TokKind HloLexer::LexNumberOrPattern() {
R"([-]?((\d+|\d+[.]\d*|\d*[.]\d+)([eE][+-]?\d+))|[-]?(\d+[.]\d*|\d*[.]\d+))"};
if (RE2::Consume(&consumable, *float_pattern)) {
current_ptr_ = consumable.begin();
- tensorflow::strings::safe_strtod(string(token_start_, current_ptr_).c_str(),
- &decimal_val_);
+ CHECK(absl::SimpleAtod(string(token_start_, current_ptr_).c_str(),
+ &decimal_val_));
return TokKind::kDecimal;
}
@@ -339,7 +341,7 @@ TokKind HloLexer::LexNumberOrPattern() {
if (RE2::Consume(&consumable, *int_pattern)) {
current_ptr_ = consumable.begin();
auto slice = StringPieceFromPointers(token_start_, current_ptr_);
- if (tensorflow::strings::safe_strto64(slice, &int64_val_)) {
+ if (absl::SimpleAtoi(slice, &int64_val_)) {
return TokKind::kInt;
}
LOG(ERROR) << "Failed to parse int literal: " << slice;
@@ -375,24 +377,24 @@ std::pair<unsigned, unsigned> HloLexer::GetLineAndColumn(LocTy location) const {
line_no_cache_.last_query = ptr;
line_no_cache_.line_no_of_query = line_no;
size_t line_offset = StringPieceFromPointers(start, ptr).rfind('\n');
- if (line_offset == tensorflow::StringPiece::npos) {
+ if (line_offset == absl::string_view::npos) {
line_offset = 0;
}
return {line_no, ptr - start - line_offset};
}
-tensorflow::StringPiece HloLexer::GetLine(LocTy loc) const {
+absl::string_view HloLexer::GetLine(LocTy loc) const {
if (!CanDereference(loc)) {
return "LINE OUT OF RANGE";
}
size_t line_start =
StringPieceFromPointers(buf_.begin(), loc + 1).rfind('\n');
- const char* start = line_start == tensorflow::StringPiece::npos
+ const char* start = line_start == absl::string_view::npos
? buf_.begin()
: buf_.begin() + line_start + 1;
size_t line_end = StringPieceFromPointers(loc, buf_.end()).find('\n');
const char* end =
- line_end == tensorflow::StringPiece::npos ? buf_.end() : loc + line_end;
+ line_end == absl::string_view::npos ? buf_.end() : loc + line_end;
return StringPieceFromPointers(start, end);
}
@@ -404,10 +406,14 @@ TokKind HloLexer::LexString() {
static LazyRE2 escaping_pattern = {R"("([^"\\]|\\.)*")"};
if (RE2::Consume(&consumable, *escaping_pattern)) {
current_ptr_ = consumable.begin();
- tensorflow::StringPiece raw =
+ absl::string_view raw =
StringPieceFromPointers(token_start_ + 1, current_ptr_ - 1);
string error;
- if (!tensorflow::str_util::CUnescape(raw, &str_val_, &error)) {
+ // TODO(b/113077997): Change to absl::CUnescape once it works properly with
+ // copy-on-write std::string implementations.
+ if (!tensorflow::str_util::CUnescape(
+ tensorflow::StringPiece(raw.data(), raw.size()), &str_val_,
+ &error)) {
LOG(ERROR) << "Failed unescaping string: " << raw << ". error: " << error;
return TokKind::kError;
}
diff --git a/tensorflow/compiler/xla/service/hlo_lexer.h b/tensorflow/compiler/xla/service/hlo_lexer.h
index f9ecd9ccb9..3e2f8bcd52 100644
--- a/tensorflow/compiler/xla/service/hlo_lexer.h
+++ b/tensorflow/compiler/xla/service/hlo_lexer.h
@@ -18,10 +18,10 @@ limitations under the License.
#include <string>
+#include "absl/strings/string_view.h"
#include "tensorflow/compiler/xla/service/hlo_token.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/regexp.h"
#include "tensorflow/core/platform/types.h"
@@ -34,7 +34,7 @@ namespace xla {
// it directly.
class HloLexer {
public:
- explicit HloLexer(tensorflow::StringPiece buf) : buf_(buf) {
+ explicit HloLexer(absl::string_view buf) : buf_(buf) {
current_ptr_ = buf_.begin();
}
@@ -77,7 +77,7 @@ class HloLexer {
std::pair<unsigned, unsigned> GetLineAndColumn(LocTy location) const;
// Returns the whole line given the location.
- tensorflow::StringPiece GetLine(LocTy loc) const;
+ absl::string_view GetLine(LocTy loc) const;
private:
// Returns the current character. If it's neither the end of input buffer nor
@@ -89,8 +89,8 @@ class HloLexer {
// Creates StringPiece with the given begin and end. Exits if the begin > end,
// or it's out of the range of the current buffer.
- tensorflow::StringPiece StringPieceFromPointers(const char* begin,
- const char* end) const;
+ absl::string_view StringPieceFromPointers(const char* begin,
+ const char* end) const;
tensorflow::RegexpStringPiece RegexpStringPieceFromPointers(
const char* begin, const char* end) const;
@@ -107,7 +107,7 @@ class HloLexer {
TokKind LexNumberOrPattern();
TokKind LexString();
- const tensorflow::StringPiece buf_;
+ const absl::string_view buf_;
const char* current_ptr_;
// Information about the current token.
diff --git a/tensorflow/compiler/xla/service/hlo_liveness_analysis.cc b/tensorflow/compiler/xla/service/hlo_liveness_analysis.cc
index 18f17b75ae..b4fc658d5b 100644
--- a/tensorflow/compiler/xla/service/hlo_liveness_analysis.cc
+++ b/tensorflow/compiler/xla/service/hlo_liveness_analysis.cc
@@ -18,6 +18,7 @@ limitations under the License.
#include <deque>
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/map_util.h"
#include "tensorflow/compiler/xla/service/call_graph.h"
#include "tensorflow/compiler/xla/service/hlo_computation.h"
@@ -30,7 +31,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/util.h"
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/logging.h"
namespace xla {
diff --git a/tensorflow/compiler/xla/service/hlo_matchers.h b/tensorflow/compiler/xla/service/hlo_matchers.h
index 0a442e77f0..9ace0d76e0 100644
--- a/tensorflow/compiler/xla/service/hlo_matchers.h
+++ b/tensorflow/compiler/xla/service/hlo_matchers.h
@@ -306,7 +306,7 @@ inline ::testing::Matcher<const ::xla::HloInstruction*> Shape(
return ::testing::MakeMatcher(new ::xla::testing::HloShapeMatcher(shape));
}
inline ::testing::Matcher<const ::xla::HloInstruction*> Shape(
- tensorflow::StringPiece shape) {
+ absl::string_view shape) {
return ::testing::MakeMatcher(new ::xla::testing::HloShapeMatcher(
ShapeUtil::ParseShapeString(shape).ValueOrDie()));
}
@@ -316,7 +316,7 @@ inline ::testing::Matcher<const ::xla::HloInstruction*> ShapeWithLayout(
new ::xla::testing::HloShapeAndLayoutMatcher(shape));
}
inline ::testing::Matcher<const ::xla::HloInstruction*> ShapeWithLayout(
- tensorflow::StringPiece shape) {
+ absl::string_view shape) {
return ::testing::MakeMatcher(new ::xla::testing::HloShapeAndLayoutMatcher(
ShapeUtil::ParseShapeString(shape).ValueOrDie()));
}
@@ -329,7 +329,7 @@ inline ::testing::Matcher<const ::xla::HloInstruction*> Sharding(
}
// Matcher for Sharding from sharding string
inline ::testing::Matcher<const ::xla::HloInstruction*> Sharding(
- tensorflow::StringPiece sharding) {
+ absl::string_view sharding) {
return ::testing::MakeMatcher(new ::xla::testing::HloShardingMatcher(
ParseSharding(sharding).ValueOrDie()));
}
diff --git a/tensorflow/compiler/xla/service/hlo_module.cc b/tensorflow/compiler/xla/service/hlo_module.cc
index d60b76d63f..78167335c8 100644
--- a/tensorflow/compiler/xla/service/hlo_module.cc
+++ b/tensorflow/compiler/xla/service/hlo_module.cc
@@ -24,11 +24,11 @@ limitations under the License.
#include "absl/algorithm/container.h"
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/map_util.h"
#include "tensorflow/compiler/xla/shape_util.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/core/lib/gtl/map_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/types.h"
namespace xla {
@@ -410,7 +410,7 @@ HloInstruction* HloModule::OutlineExpressionFromComputation(
string error_message =
"The subcomputation to outline has multiple outputs:\n";
for (HloInstruction* output : outputs) {
- tensorflow::strings::StrAppend(&error_message, output->ToString(), "\n");
+ absl::StrAppend(&error_message, output->ToString(), "\n");
}
LOG(FATAL) << error_message;
}
@@ -536,8 +536,7 @@ uint64 HloModule::RandomNew64() const {
return rng_();
}
-HloComputation* HloModule::GetComputationWithName(
- tensorflow::StringPiece name) {
+HloComputation* HloModule::GetComputationWithName(absl::string_view name) {
auto computations_in_module = computations();
auto it = absl::c_find_if(
computations_in_module,
diff --git a/tensorflow/compiler/xla/service/hlo_module.h b/tensorflow/compiler/xla/service/hlo_module.h
index d2e726a0db..cf129b835d 100644
--- a/tensorflow/compiler/xla/service/hlo_module.h
+++ b/tensorflow/compiler/xla/service/hlo_module.h
@@ -24,6 +24,7 @@ limitations under the License.
#include <unordered_map>
#include <vector>
+#include "absl/strings/string_view.h"
#include "tensorflow/compiler/xla/iterator_util.h"
#include "tensorflow/compiler/xla/service/hlo.pb.h"
#include "tensorflow/compiler/xla/service/hlo_clone_context.h"
@@ -32,7 +33,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/hlo_module_config.h"
#include "tensorflow/compiler/xla/service/name_uniquer.h"
#include "tensorflow/compiler/xla/types.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/gtl/array_slice.h"
#include "tensorflow/core/lib/gtl/iterator_range.h"
#include "tensorflow/core/platform/logging.h"
@@ -142,7 +142,7 @@ class HloModule {
// Returns the computation in this module that has the name `name`. Returns
// null if there is no such computation.
- HloComputation* GetComputationWithName(tensorflow::StringPiece name);
+ HloComputation* GetComputationWithName(absl::string_view name);
// Gets the number of computations in this module.
int64 computation_count() const { return computations_.size(); }
diff --git a/tensorflow/compiler/xla/service/hlo_module_config.cc b/tensorflow/compiler/xla/service/hlo_module_config.cc
index f9708283eb..0d5ac9adbe 100644
--- a/tensorflow/compiler/xla/service/hlo_module_config.cc
+++ b/tensorflow/compiler/xla/service/hlo_module_config.cc
@@ -19,14 +19,14 @@ limitations under the License.
#include <vector>
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/shape_layout.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
namespace xla {
-using tensorflow::strings::StrAppend;
+using absl::StrAppend;
HloModuleConfig::HloModuleConfig(const ProgramShape& program_shape,
bool ignore_layouts)
@@ -39,8 +39,7 @@ void HloModuleConfig::SetDefaultComputationLayout(
}
string HloModuleConfig::compilation_cache_key() const {
- string key =
- tensorflow::strings::StrCat("profiling=", hlo_profiling_enabled());
+ string key = absl::StrCat("profiling=", hlo_profiling_enabled());
StrAppend(&key, "::(");
std::vector<string> params;
for (const ShapeLayout& param_layout :
diff --git a/tensorflow/compiler/xla/service/hlo_module_dce.h b/tensorflow/compiler/xla/service/hlo_module_dce.h
index 29024085c1..12ca2340a6 100644
--- a/tensorflow/compiler/xla/service/hlo_module_dce.h
+++ b/tensorflow/compiler/xla/service/hlo_module_dce.h
@@ -31,7 +31,7 @@ namespace xla {
class HloModuleDCE : public HloPassInterface {
public:
~HloModuleDCE() override {}
- tensorflow::StringPiece name() const override { return "hlo-module-dce"; }
+ absl::string_view name() const override { return "hlo-module-dce"; }
// Run the pass on the given module. Returns whether the module was changed
// (instructions were removed).
diff --git a/tensorflow/compiler/xla/service/hlo_module_group_util.cc b/tensorflow/compiler/xla/service/hlo_module_group_util.cc
index 1a4da388e4..b5c7681edd 100644
--- a/tensorflow/compiler/xla/service/hlo_module_group_util.cc
+++ b/tensorflow/compiler/xla/service/hlo_module_group_util.cc
@@ -23,6 +23,7 @@ limitations under the License.
#include <utility>
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/service/hlo_casting_utils.h"
#include "tensorflow/compiler/xla/service/hlo_instructions.h"
#include "tensorflow/compiler/xla/service/hlo_opcode.h"
@@ -32,7 +33,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/util.h"
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/gtl/flatset.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/types.h"
@@ -270,8 +270,8 @@ Status HloModuleGroupUtil::VisitTopologicalOrder(
string cyclic_instructions;
for (const auto& state : *visit_state) {
if (state.second == VisitState::kVisiting) {
- tensorflow::strings::StrAppend(&cyclic_instructions,
- state.first->ToString(), "\n");
+ absl::StrAppend(&cyclic_instructions, state.first->ToString(),
+ "\n");
}
}
// TODO(b/64305524): Improve the error message to print out the
diff --git a/tensorflow/compiler/xla/service/hlo_parser.cc b/tensorflow/compiler/xla/service/hlo_parser.cc
index 90a493d29f..b4425338ef 100644
--- a/tensorflow/compiler/xla/service/hlo_parser.cc
+++ b/tensorflow/compiler/xla/service/hlo_parser.cc
@@ -17,6 +17,8 @@ limitations under the License.
#include "absl/algorithm/container.h"
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
+#include "absl/strings/str_split.h"
#include "tensorflow/compiler/xla/literal.h"
#include "tensorflow/compiler/xla/literal_util.h"
#include "tensorflow/compiler/xla/service/hlo_domain_metadata.h"
@@ -26,7 +28,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/shape_util.h"
#include "tensorflow/compiler/xla/util.h"
#include "tensorflow/core/lib/gtl/map_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/lib/strings/stringprintf.h"
namespace xla {
@@ -35,13 +36,12 @@ namespace {
using ::absl::nullopt;
using ::absl::optional;
-using ::tensorflow::StringPiece;
+using ::absl::StrAppend;
+using ::absl::StrCat;
using ::tensorflow::str_util::Join;
using ::tensorflow::str_util::Split;
using ::tensorflow::str_util::SplitAndParseAsInts;
using ::tensorflow::strings::Printf;
-using ::tensorflow::strings::StrAppend;
-using ::tensorflow::strings::StrCat;
const double kF16max = 65504;
@@ -50,7 +50,7 @@ class HloParser {
public:
using LocTy = HloLexer::LocTy;
- explicit HloParser(StringPiece str, const HloModuleConfig& config)
+ explicit HloParser(absl::string_view str, const HloModuleConfig& config)
: lexer_(str), config_(config) {}
// Runs the parser. Returns false if an error occurred.
@@ -253,8 +253,8 @@ class HloParser {
bool CanBeParamListToShape();
// Logs the current parsing line and the given message. Always returns false.
- bool TokenError(StringPiece msg);
- bool Error(LocTy loc, StringPiece msg);
+ bool TokenError(absl::string_view msg);
+ bool Error(LocTy loc, absl::string_view msg);
// If the current token is 'kind', eats it (i.e. lexes the next token) and
// returns true.
@@ -307,7 +307,7 @@ std::vector<ReplicaGroup> CreateReplicaGroups(
return replica_groups;
}
-bool HloParser::Error(LocTy loc, StringPiece msg) {
+bool HloParser::Error(LocTy loc, absl::string_view msg) {
auto line_col = lexer_.GetLineAndColumn(loc);
const unsigned line = line_col.first;
const unsigned col = line_col.second;
@@ -322,7 +322,7 @@ bool HloParser::Error(LocTy loc, StringPiece msg) {
return false;
}
-bool HloParser::TokenError(StringPiece msg) {
+bool HloParser::TokenError(absl::string_view msg) {
return Error(lexer_.GetLoc(), msg);
}
@@ -2489,20 +2489,24 @@ bool HloParser::ParseConvolutionDimensionNumbers(
}
string str = lexer_.GetStrVal();
- // The str is expected to have 3 items, lhs, rhs, out, and it must looks like
+ // The str is expected to have 3 items, lhs, rhs, out, and it must look like
// lhs_rhs->out, that is, the first separator is "_" and the second is "->".
- // So we replace the "->" with "_" and then split on "_".
- str = tensorflow::str_util::StringReplace(str, /*oldsub=*/"->",
- /*newsub=*/"_",
- /*replace_all=*/false);
- std::vector<string> lhs_rhs_out = Split(str, "_");
- if (lhs_rhs_out.size() != 3) {
+ std::vector<string> split1 = absl::StrSplit(str, "_");
+ if (split1.size() != 2) {
LOG(FATAL) << "expects 3 items: lhs, rhs, and output dims, but sees "
<< str;
}
+ std::vector<string> split2 = absl::StrSplit(split1[1], "->");
+ if (split2.size() != 2) {
+ LOG(FATAL) << "expects 3 items: lhs, rhs, and output dims, but sees "
+ << str;
+ }
+ absl::string_view lhs = split1[0];
+ absl::string_view rhs = split2[0];
+ absl::string_view out = split2[1];
- const tensorflow::int64 rank = lhs_rhs_out[0].length();
- if (rank != lhs_rhs_out[1].length() || rank != lhs_rhs_out[2].length()) {
+ const tensorflow::int64 rank = lhs.length();
+ if (rank != rhs.length() || rank != out.length()) {
return TokenError(
"convolution lhs, rhs, and output must have the same rank");
}
@@ -2517,8 +2521,7 @@ bool HloParser::ParseConvolutionDimensionNumbers(
// lhs
{
- const string& lhs = lhs_rhs_out[0];
- if (!is_unique(lhs)) {
+ if (!is_unique(string(lhs))) {
return TokenError(
StrCat("expects unique lhs dimension numbers, but sees ", lhs));
}
@@ -2541,8 +2544,7 @@ bool HloParser::ParseConvolutionDimensionNumbers(
}
// rhs
{
- const string& rhs = lhs_rhs_out[1];
- if (!is_unique(rhs)) {
+ if (!is_unique(string(rhs))) {
return TokenError(
StrCat("expects unique rhs dimension numbers, but sees ", rhs));
}
@@ -2565,8 +2567,7 @@ bool HloParser::ParseConvolutionDimensionNumbers(
}
// output
{
- const string& out = lhs_rhs_out[2];
- if (!is_unique(out)) {
+ if (!is_unique(string(out))) {
return TokenError(
StrCat("expects unique output dimension numbers, but sees ", out));
}
@@ -3162,7 +3163,7 @@ Status HloParser::ParseSingleInstruction(HloComputation::Builder* builder,
} // namespace
StatusOr<std::unique_ptr<HloModule>> ParseHloString(
- tensorflow::StringPiece str, const HloModuleConfig& config) {
+ absl::string_view str, const HloModuleConfig& config) {
HloParser parser(str, config);
if (!parser.Run()) {
return InvalidArgument("Syntax error:\n%s", parser.GetError().c_str());
@@ -3170,39 +3171,38 @@ StatusOr<std::unique_ptr<HloModule>> ParseHloString(
return parser.ConsumeHloModule();
}
-StatusOr<std::unique_ptr<HloModule>> ParseHloString(
- tensorflow::StringPiece str) {
+StatusOr<std::unique_ptr<HloModule>> ParseHloString(absl::string_view str) {
HloModuleConfig config;
return ParseHloString(str, config);
}
StatusOr<std::unique_ptr<HloModule>> ParseHloOpToModule(
- tensorflow::StringPiece str, tensorflow::StringPiece name) {
+ absl::string_view str, absl::string_view name) {
HloModuleConfig config;
HloParser parser(str, config);
- auto builder = absl::make_unique<HloComputation::Builder>(name.ToString());
+ auto builder = absl::make_unique<HloComputation::Builder>(string(name));
string root_name;
TF_RETURN_IF_ERROR(parser.ParseSingleInstruction(builder.get(), &root_name));
std::unique_ptr<HloComputation> computation = builder->Build();
- auto module = absl::make_unique<HloModule>(name.ToString(), config);
+ auto module = absl::make_unique<HloModule>(string(name), config);
module->AddEntryComputation(std::move(computation));
return std::move(module);
}
-StatusOr<HloSharding> ParseSharding(tensorflow::StringPiece str) {
+StatusOr<HloSharding> ParseSharding(absl::string_view str) {
HloModuleConfig config;
HloParser parser(str, config);
return parser.ParseShardingOnly();
}
-StatusOr<Window> ParseWindow(tensorflow::StringPiece str) {
+StatusOr<Window> ParseWindow(absl::string_view str) {
HloModuleConfig config;
HloParser parser(str, config);
return parser.ParseWindowOnly();
}
StatusOr<ConvolutionDimensionNumbers> ParseConvolutionDimensionNumbers(
- tensorflow::StringPiece str) {
+ absl::string_view str) {
HloModuleConfig config;
HloParser parser(str, config);
return parser.ParseConvolutionDimensionNumbersOnly();
diff --git a/tensorflow/compiler/xla/service/hlo_parser.h b/tensorflow/compiler/xla/service/hlo_parser.h
index 6c184bfe9a..0c64b50481 100644
--- a/tensorflow/compiler/xla/service/hlo_parser.h
+++ b/tensorflow/compiler/xla/service/hlo_parser.h
@@ -17,6 +17,7 @@ limitations under the License.
#define TENSORFLOW_COMPILER_XLA_SERVICE_HLO_PARSER_H_
#include "absl/memory/memory.h"
+#include "absl/strings/string_view.h"
#include "tensorflow/compiler/xla/service/hlo_computation.h"
#include "tensorflow/compiler/xla/service/hlo_instruction.h"
#include "tensorflow/compiler/xla/service/hlo_lexer.h"
@@ -32,32 +33,31 @@ namespace xla {
// The api of the hlo parser. Given a string in the HloModule::ToString()
// format, parses the string and creates a HloModule with the given config.
StatusOr<std::unique_ptr<HloModule>> ParseHloString(
- tensorflow::StringPiece str, const HloModuleConfig& config);
+ absl::string_view str, const HloModuleConfig& config);
// Parses the text for a single HLO operation into an HLO module with a function
// that runs that operation (with the same parameters) as its entry computation.
StatusOr<std::unique_ptr<HloModule>> ParseHloOpToModule(
- tensorflow::StringPiece str, tensorflow::StringPiece name = "single_op");
+ absl::string_view str, absl::string_view name = "single_op");
// The api of the hlo parser. Given a string in the HloModule::ToString()
// format, parses the string and creates a HloModule with default config.
-StatusOr<std::unique_ptr<HloModule>> ParseHloString(
- tensorflow::StringPiece str);
+StatusOr<std::unique_ptr<HloModule>> ParseHloString(absl::string_view str);
// Parses the result of HloSharding::ToString(), e.g. "{replicated}".
-StatusOr<HloSharding> ParseSharding(tensorflow::StringPiece str);
+StatusOr<HloSharding> ParseSharding(absl::string_view str);
// Parses the result of window_util::ToString(const Window&).
-StatusOr<Window> ParseWindow(tensorflow::StringPiece str);
+StatusOr<Window> ParseWindow(absl::string_view str);
// Parses the result of ConvolutionDimensionNumbersToString(), e.g.
// "b0f_0io->b0f".
StatusOr<ConvolutionDimensionNumbers> ParseConvolutionDimensionNumbers(
- tensorflow::StringPiece str);
+ absl::string_view str);
// ParseHloString sharding from str. str is supposed to contain the body of the
// sharding, i.e. just the rhs of the "sharding={...}" attribute string.
-StatusOr<HloSharding> ParseSharding(tensorflow::StringPiece str);
+StatusOr<HloSharding> ParseSharding(absl::string_view str);
} // namespace xla
diff --git a/tensorflow/compiler/xla/service/hlo_parser_test.cc b/tensorflow/compiler/xla/service/hlo_parser_test.cc
index f310b36bfb..a077f38c11 100644
--- a/tensorflow/compiler/xla/service/hlo_parser_test.cc
+++ b/tensorflow/compiler/xla/service/hlo_parser_test.cc
@@ -16,10 +16,12 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/hlo_parser.h"
#include <string>
+#include "absl/strings/match.h"
+#include "absl/strings/str_cat.h"
+#include "absl/strings/string_view.h"
#include "tensorflow/compiler/xla/service/hlo_matchers.h"
#include "tensorflow/compiler/xla/window_util.h"
#include "tensorflow/core/lib/core/status_test_util.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/strings/str_util.h"
#include "tensorflow/core/platform/test.h"
@@ -29,7 +31,7 @@ namespace xla {
namespace {
-using ::tensorflow::StringPiece;
+using ::absl::string_view;
struct TestData {
string test_name;
@@ -1128,8 +1130,8 @@ ENTRY Computation {
class HloParserTest : public ::testing::Test,
public ::testing::WithParamInterface<TestData> {
protected:
- static void ExpectHasSubstr(StringPiece s, StringPiece expected) {
- EXPECT_TRUE(tensorflow::str_util::StrContains(s, expected))
+ static void ExpectHasSubstr(string_view s, string_view expected) {
+ EXPECT_TRUE(absl::StrContains(s, expected))
<< "'" << s << "' does not contain '" << expected << "'";
}
@@ -1393,15 +1395,14 @@ ENTRY %Convolve1D1Window_0.v3 (input: f32[1,2,1], filter: f32[1,1,1]) -> f32[1,2
)";
- ExpectHasSubstr(ParseHloString(tensorflow::strings::StrCat(
- prefix, ",dim_labels=00_01_10", suffix))
- .status()
- .error_message(),
- "expects dim labels pattern");
+ ExpectHasSubstr(
+ ParseHloString(absl::StrCat(prefix, ",dim_labels=00_01_10", suffix))
+ .status()
+ .error_message(),
+ "expects dim labels pattern");
ExpectHasSubstr(
- ParseHloString(tensorflow::strings::StrCat(
- prefix, ",dim_labels=010_1100->010", suffix))
+ ParseHloString(absl::StrCat(prefix, ",dim_labels=010_1100->010", suffix))
.status()
.error_message(),
"must have the same rank");
diff --git a/tensorflow/compiler/xla/service/hlo_pass_interface.h b/tensorflow/compiler/xla/service/hlo_pass_interface.h
index 0cddf8fb8f..f1ad0f9b01 100644
--- a/tensorflow/compiler/xla/service/hlo_pass_interface.h
+++ b/tensorflow/compiler/xla/service/hlo_pass_interface.h
@@ -29,7 +29,7 @@ namespace xla {
class HloPassInterface {
public:
virtual ~HloPassInterface() = default;
- virtual tensorflow::StringPiece name() const = 0;
+ virtual absl::string_view name() const = 0;
// Run the pass on the given HLO module. Return whether it modified the
// module.
diff --git a/tensorflow/compiler/xla/service/hlo_pass_pipeline.cc b/tensorflow/compiler/xla/service/hlo_pass_pipeline.cc
index d8f1ab916b..7e9cd4b2ed 100644
--- a/tensorflow/compiler/xla/service/hlo_pass_pipeline.cc
+++ b/tensorflow/compiler/xla/service/hlo_pass_pipeline.cc
@@ -17,6 +17,7 @@ limitations under the License.
#include <functional>
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/service/hlo_graph_dumper.h"
#include "tensorflow/compiler/xla/service/hlo_proto_util.h"
#include "tensorflow/compiler/xla/status_macros.h"
@@ -24,11 +25,10 @@ limitations under the License.
#include "tensorflow/compiler/xla/util.h"
#include "tensorflow/core/lib/gtl/flatset.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/logging.h"
-using ::tensorflow::strings::StrAppend;
-using ::tensorflow::strings::StrCat;
+using ::absl::StrAppend;
+using ::absl::StrCat;
namespace xla {
diff --git a/tensorflow/compiler/xla/service/hlo_pass_pipeline.h b/tensorflow/compiler/xla/service/hlo_pass_pipeline.h
index 3bb1342aa3..1d41a4dac1 100644
--- a/tensorflow/compiler/xla/service/hlo_pass_pipeline.h
+++ b/tensorflow/compiler/xla/service/hlo_pass_pipeline.h
@@ -34,7 +34,7 @@ namespace xla {
class HloPassPipeline : public HloPassInterface {
public:
explicit HloPassPipeline(const string& name) : name_(name) {}
- tensorflow::StringPiece name() const override { return name_; }
+ absl::string_view name() const override { return name_; }
// Add a pass to the pipeline. It should be called with the arguments for the
// pass constructor:
diff --git a/tensorflow/compiler/xla/service/hlo_rematerialization.cc b/tensorflow/compiler/xla/service/hlo_rematerialization.cc
index 04e4a29359..367c2d6d32 100644
--- a/tensorflow/compiler/xla/service/hlo_rematerialization.cc
+++ b/tensorflow/compiler/xla/service/hlo_rematerialization.cc
@@ -21,6 +21,7 @@ limitations under the License.
#include <string>
#include "absl/container/inlined_vector.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/map_util.h"
#include "tensorflow/compiler/xla/primitive_util.h"
#include "tensorflow/compiler/xla/service/buffer_value.h"
@@ -39,7 +40,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/compiler/xla/util.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/lib/strings/stringprintf.h"
#include "tensorflow/core/platform/logging.h"
@@ -209,7 +209,7 @@ class InstructionList {
<< " before {"
<< tensorflow::str_util::Join(before_instructions, ", ",
[](string* out, Item* item) {
- tensorflow::strings::StrAppend(
+ absl::StrAppend(
out, item->instruction->name());
})
<< "}";
@@ -394,10 +394,9 @@ class MemoryUsageTracker {
int64 unfinished_user_count;
string ToString() const {
- return tensorflow::strings::StrCat(
- "Buffer ", id, " (defined by ",
- defining_instruction->instruction->name(), ", size ", size,
- " bytes)");
+ return absl::StrCat("Buffer ", id, " (defined by ",
+ defining_instruction->instruction->name(), ", size ",
+ size, " bytes)");
}
};
@@ -741,29 +740,27 @@ Status MemoryUsageTracker::AddRematerializedInstruction(Item* original_item,
}
string MemoryUsageTracker::ToString() const {
- string output = tensorflow::strings::StrCat("MemoryUsageTracker for ",
- computation_->name(), "\n");
- tensorflow::strings::StrAppend(
- &output, "Memory usage: ", HumanReadableNumBytes(memory_usage()), " (",
- memory_usage(), " bytes)");
+ string output =
+ absl::StrCat("MemoryUsageTracker for ", computation_->name(), "\n");
+ absl::StrAppend(&output,
+ "Memory usage: ", HumanReadableNumBytes(memory_usage()), " (",
+ memory_usage(), " bytes)");
for (auto* item = instruction_list_.first(); item != nullptr;
item = instruction_list_.next(item)) {
const HloInstruction* instruction = item->instruction;
string inprogress = item == in_progress_item_ ? " in-progress" : "";
string placed = item->placed ? " placed" : "";
- tensorflow::strings::StrAppend(&output, " ", instruction->name(),
- inprogress, placed, "\n Defines:\n");
+ absl::StrAppend(&output, " ", instruction->name(), inprogress, placed,
+ "\n Defines:\n");
for (BufferId buffer_id : item->buffers_defined) {
const Buffer& buffer = buffers_[buffer_id];
string live = IsCurrentlyLive(buffer_id) ? " live" : "";
- tensorflow::strings::StrAppend(&output, " ", buffer.ToString(), live,
- ", ", buffer.unfinished_user_count,
- " unfinished uses\n");
+ absl::StrAppend(&output, " ", buffer.ToString(), live, ", ",
+ buffer.unfinished_user_count, " unfinished uses\n");
}
- tensorflow::strings::StrAppend(&output, " Uses:\n");
+ absl::StrAppend(&output, " Uses:\n");
for (BufferId buffer_id : item->buffers_used) {
- tensorflow::strings::StrAppend(&output, " ",
- buffers_[buffer_id].ToString(), "\n");
+ absl::StrAppend(&output, " ", buffers_[buffer_id].ToString(), "\n");
}
}
return output;
@@ -783,8 +780,7 @@ bool MemoryUsageTracker::Check() const {
<< " does not have unique defined buffers: "
<< tensorflow::str_util::Join(
defined_buffers, ", ", [this](string* out, BufferId buffer_id) {
- tensorflow::strings::StrAppend(
- out, buffers_.at(buffer_id).ToString());
+ absl::StrAppend(out, buffers_.at(buffer_id).ToString());
});
for (const Buffer& buffer : buffers_) {
@@ -806,8 +802,7 @@ bool MemoryUsageTracker::Check() const {
<< " does not have unique used buffers: "
<< tensorflow::str_util::Join(
used_buffers, ", ", [this](string* out, BufferId buffer_id) {
- tensorflow::strings::StrAppend(
- out, buffers_.at(buffer_id).ToString());
+ absl::StrAppend(out, buffers_.at(buffer_id).ToString());
});
}
for (const Buffer& buffer : buffers_) {
diff --git a/tensorflow/compiler/xla/service/hlo_runner.cc b/tensorflow/compiler/xla/service/hlo_runner.cc
index 8f3ae9c621..7bd8a4a544 100644
--- a/tensorflow/compiler/xla/service/hlo_runner.cc
+++ b/tensorflow/compiler/xla/service/hlo_runner.cc
@@ -32,7 +32,7 @@ limitations under the License.
namespace xla {
/*static*/ StatusOr<std::unique_ptr<HloModule>>
-HloRunner::CreateModuleFromString(const tensorflow::StringPiece hlo_string,
+HloRunner::CreateModuleFromString(const absl::string_view hlo_string,
const DebugOptions& debug_options) {
HloModuleConfig config;
config.set_debug_options(debug_options);
diff --git a/tensorflow/compiler/xla/service/hlo_runner.h b/tensorflow/compiler/xla/service/hlo_runner.h
index 65537f07f5..cfc519063e 100644
--- a/tensorflow/compiler/xla/service/hlo_runner.h
+++ b/tensorflow/compiler/xla/service/hlo_runner.h
@@ -87,8 +87,7 @@ class HloRunner {
// Converts an HloModule from the given hlo textual IR string (in
// HloModule::ToString format).
static StatusOr<std::unique_ptr<HloModule>> CreateModuleFromString(
- const tensorflow::StringPiece hlo_string,
- const DebugOptions& debug_options);
+ const absl::string_view hlo_string, const DebugOptions& debug_options);
// Reads the proto file in xla.HloProto format, creates and returns the
// HloModule.
diff --git a/tensorflow/compiler/xla/service/hlo_sharding.cc b/tensorflow/compiler/xla/service/hlo_sharding.cc
index 903fbbec1a..cc8ee94e22 100644
--- a/tensorflow/compiler/xla/service/hlo_sharding.cc
+++ b/tensorflow/compiler/xla/service/hlo_sharding.cc
@@ -15,13 +15,14 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/hlo_sharding.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/strings/str_util.h"
namespace xla {
+using ::absl::StrCat;
using ::tensorflow::str_util::Join;
-using ::tensorflow::strings::StrCat;
HloSharding HloSharding::AssignDevice(int64 device_id) {
return HloSharding(device_id);
diff --git a/tensorflow/compiler/xla/service/hlo_sharding_metadata.h b/tensorflow/compiler/xla/service/hlo_sharding_metadata.h
index abd0a31e61..7a6b0d9abc 100644
--- a/tensorflow/compiler/xla/service/hlo_sharding_metadata.h
+++ b/tensorflow/compiler/xla/service/hlo_sharding_metadata.h
@@ -32,7 +32,7 @@ class ShardingMetadata : public DomainMetadata {
std::unique_ptr<DomainMetadata> Clone() const override;
- tensorflow::StringPiece Kind() const override { return KindName(); }
+ absl::string_view Kind() const override { return KindName(); }
bool Matches(const DomainMetadata& other) const override;
@@ -40,7 +40,7 @@ class ShardingMetadata : public DomainMetadata {
const HloSharding* sharding() const { return sharding_.get(); }
- static tensorflow::StringPiece KindName() { return "sharding"; }
+ static absl::string_view KindName() { return "sharding"; }
static StatusOr<const ShardingMetadata*> ToShardingMetadata(
const DomainMetadata* metadata);
diff --git a/tensorflow/compiler/xla/service/hlo_subcomputation_unification.h b/tensorflow/compiler/xla/service/hlo_subcomputation_unification.h
index 2ef38821af..d1cf644f82 100644
--- a/tensorflow/compiler/xla/service/hlo_subcomputation_unification.h
+++ b/tensorflow/compiler/xla/service/hlo_subcomputation_unification.h
@@ -24,7 +24,7 @@ namespace xla {
// one arbitrarily to use and delete the others.
class HloSubcomputationUnification : public HloPassInterface {
public:
- tensorflow::StringPiece name() const override {
+ absl::string_view name() const override {
return "subcomputation-unification";
}
diff --git a/tensorflow/compiler/xla/service/hlo_tfgraph_builder.cc b/tensorflow/compiler/xla/service/hlo_tfgraph_builder.cc
index b78bfa0cdf..7a8fa25cfa 100644
--- a/tensorflow/compiler/xla/service/hlo_tfgraph_builder.cc
+++ b/tensorflow/compiler/xla/service/hlo_tfgraph_builder.cc
@@ -14,6 +14,7 @@ limitations under the License.
==============================================================================*/
#include "tensorflow/compiler/xla/service/hlo_tfgraph_builder.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/layout_util.h"
#include "tensorflow/compiler/xla/literal.h"
#include "tensorflow/compiler/xla/service/hlo_opcode.h"
@@ -22,13 +23,12 @@ limitations under the License.
#include "tensorflow/core/framework/op.h"
#include "tensorflow/core/framework/tensor_shape.pb.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
+using ::absl::StrAppend;
+using ::absl::StrCat;
using ::tensorflow::GraphDef;
using ::tensorflow::NodeDef;
using ::tensorflow::TensorShapeProto;
-using ::tensorflow::strings::StrAppend;
-using ::tensorflow::strings::StrCat;
using ::tensorflow::str_util::Join;
namespace xla {
@@ -42,7 +42,7 @@ string GetOpDefName(const HloInstruction* instruction) {
if (instruction->opcode() == HloOpcode::kFusion) {
string fusion_name = ToString(instruction->fusion_kind());
- StrAppend(&name, tensorflow::StringPiece(fusion_name).substr(1));
+ StrAppend(&name, absl::string_view(fusion_name).substr(1));
}
return name;
}
diff --git a/tensorflow/compiler/xla/service/hlo_value.cc b/tensorflow/compiler/xla/service/hlo_value.cc
index 14703aaf64..d41614be50 100644
--- a/tensorflow/compiler/xla/service/hlo_value.cc
+++ b/tensorflow/compiler/xla/service/hlo_value.cc
@@ -19,6 +19,7 @@ limitations under the License.
#include <utility>
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/map_util.h"
#include "tensorflow/compiler/xla/service/hlo_computation.h"
#include "tensorflow/compiler/xla/service/hlo_instruction.h"
@@ -31,15 +32,14 @@ limitations under the License.
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/gtl/flatset.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/types.h"
namespace xla {
+using ::absl::StrAppend;
+using ::absl::StrCat;
using ::tensorflow::str_util::Join;
-using ::tensorflow::strings::StrAppend;
-using ::tensorflow::strings::StrCat;
const Shape& HloPosition::shape() const {
return ShapeUtil::GetSubshape(instruction->shape(), index);
diff --git a/tensorflow/compiler/xla/service/hlo_verifier.h b/tensorflow/compiler/xla/service/hlo_verifier.h
index 523bf4d70c..83b77c84eb 100644
--- a/tensorflow/compiler/xla/service/hlo_verifier.h
+++ b/tensorflow/compiler/xla/service/hlo_verifier.h
@@ -140,7 +140,7 @@ class HloVerifier : public HloPassInterface {
: shape_verifier_factory_(std::move(shape_verifier_factory)) {}
~HloVerifier() override = default;
- tensorflow::StringPiece name() const override { return "verifier"; }
+ absl::string_view name() const override { return "verifier"; }
// Note: always returns false (no instructions are ever modified by this
// pass).
diff --git a/tensorflow/compiler/xla/service/human_readable_profile_builder.cc b/tensorflow/compiler/xla/service/human_readable_profile_builder.cc
index bb5b40a8a8..581b3ce1e0 100644
--- a/tensorflow/compiler/xla/service/human_readable_profile_builder.cc
+++ b/tensorflow/compiler/xla/service/human_readable_profile_builder.cc
@@ -14,20 +14,20 @@ limitations under the License.
==============================================================================*/
#include "tensorflow/compiler/xla/service/human_readable_profile_builder.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/metric_table_report.h"
#include "tensorflow/compiler/xla/util.h"
#include "tensorflow/core/lib/strings/numbers.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/lib/strings/stringprintf.h"
namespace xla {
+using absl::StrAppend;
+using absl::StrCat;
using tensorflow::strings::Appendf;
using tensorflow::strings::HumanReadableElapsedTime;
using tensorflow::strings::HumanReadableNumBytes;
using tensorflow::strings::Printf;
-using tensorflow::strings::StrAppend;
-using tensorflow::strings::StrCat;
string HumanReadableProfileBuilder::ToString() const {
string s;
diff --git a/tensorflow/compiler/xla/service/human_readable_profile_builder.h b/tensorflow/compiler/xla/service/human_readable_profile_builder.h
index 6f56c3aa82..b99624460e 100644
--- a/tensorflow/compiler/xla/service/human_readable_profile_builder.h
+++ b/tensorflow/compiler/xla/service/human_readable_profile_builder.h
@@ -18,8 +18,8 @@ limitations under the License.
#include <vector>
+#include "absl/strings/string_view.h"
#include "tensorflow/compiler/xla/types.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/types.h"
@@ -29,7 +29,7 @@ namespace xla {
// computation, suitable for consumption by humans.
class HumanReadableProfileBuilder {
public:
- explicit HumanReadableProfileBuilder(tensorflow::StringPiece computation_name,
+ explicit HumanReadableProfileBuilder(absl::string_view computation_name,
int64 total_cycles,
double clock_rate_ghz)
: computation_name_(std::string(computation_name)),
@@ -43,9 +43,8 @@ class HumanReadableProfileBuilder {
// Adds an operation to the profile. If you don't know the number of
// floating-point ops or bytes touched by the op, or if you don't know how
// fast it would run optimally, pass -1 for that param.
- void AddOp(tensorflow::StringPiece op_name,
- tensorflow::StringPiece short_name,
- tensorflow::StringPiece category, int64 cycles, int64 flop_count,
+ void AddOp(absl::string_view op_name, absl::string_view short_name,
+ absl::string_view category, int64 cycles, int64 flop_count,
int64 transcendental_count, int64 bytes_accessed,
float optimal_seconds) {
op_infos_.push_back({std::string(op_name), std::string(short_name),
diff --git a/tensorflow/compiler/xla/service/implicit_broadcast_remover.h b/tensorflow/compiler/xla/service/implicit_broadcast_remover.h
index aa325dc8a3..85bb4a8b24 100644
--- a/tensorflow/compiler/xla/service/implicit_broadcast_remover.h
+++ b/tensorflow/compiler/xla/service/implicit_broadcast_remover.h
@@ -30,7 +30,7 @@ class ImplicitBroadcastRemover : public HloPassInterface {
ImplicitBroadcastRemover() {}
~ImplicitBroadcastRemover() override {}
- tensorflow::StringPiece name() const override {
+ absl::string_view name() const override {
return "implicit-broadcast-remover";
}
diff --git a/tensorflow/compiler/xla/service/indexed_array_analysis.cc b/tensorflow/compiler/xla/service/indexed_array_analysis.cc
index 256c8e5573..e984651249 100644
--- a/tensorflow/compiler/xla/service/indexed_array_analysis.cc
+++ b/tensorflow/compiler/xla/service/indexed_array_analysis.cc
@@ -17,12 +17,12 @@ limitations under the License.
#include "absl/algorithm/container.h"
#include "absl/container/inlined_vector.h"
+#include "absl/strings/str_cat.h"
#include "absl/types/optional.h"
#include "tensorflow/compiler/xla/map_util.h"
#include "tensorflow/compiler/xla/service/hlo_evaluator.h"
#include "tensorflow/compiler/xla/util.h"
#include "tensorflow/core/lib/gtl/flatset.h"
-#include "tensorflow/core/lib/strings/strcat.h"
namespace xla {
namespace gtl = ::tensorflow::gtl;
@@ -41,24 +41,22 @@ string IndexedArrayAnalysis::ToString(Array* root, bool print_constants) {
switch (root->kind()) {
case Array::kUnknown: {
auto* unknown_tensor = root->as<UnknownArray>();
- return tensorflow::strings::StrCat("%",
- unknown_tensor->instruction().name());
+ return absl::StrCat("%", unknown_tensor->instruction().name());
}
case Array::kConstant: {
if (print_constants) {
string contents = root->as<ConstantArray>()->literal()->ToString();
- return tensorflow::strings::StrCat(
- "(constant ", ShapeUtil::HumanString(root->shape()), " ", contents,
- ")");
+ return absl::StrCat("(constant ", ShapeUtil::HumanString(root->shape()),
+ " ", contents, ")");
}
- return tensorflow::strings::StrCat(
- "(constant ", ShapeUtil::HumanString(root->shape()), ")");
+ return absl::StrCat("(constant ", ShapeUtil::HumanString(root->shape()),
+ ")");
}
case Array::kReshaped: {
ReshapedArray* reshaped_array = root->as<ReshapedArray>();
- return tensorflow::strings::StrCat(
+ return absl::StrCat(
"(reshape ", ToString(reshaped_array->operand(), print_constants),
" to ", ShapeUtil::HumanString(reshaped_array->shape()), ")");
}
@@ -69,7 +67,7 @@ string IndexedArrayAnalysis::ToString(Array* root, bool print_constants) {
string name = root->kind() == Array::kScalarIndexedConstant
? "scalar-indexed-const"
: "scalar-indexed";
- return tensorflow::strings::StrCat(
+ return absl::StrCat(
"(", name, " ", ToString(indexed_array->source(), print_constants),
" ", ToString(indexed_array->indices(), print_constants), " ",
indexed_array->source_dim(), "->[",
@@ -396,8 +394,8 @@ std::vector<ReshapePassthroughDimPair> ComputeReshapePassthroughDimPairs(
std::vector<string> result_strings;
absl::c_transform(result, std::back_inserter(result_strings),
[](ReshapePassthroughDimPair value) {
- return tensorflow::strings::StrCat(
- value.result_dim, "->", value.operand_dim);
+ return absl::StrCat(value.result_dim, "->",
+ value.operand_dim);
});
VLOG(3) << "For a reshape from [" << Join(operand_shape, ",") << "] to ["
<< Join(result_shape, ",") << "] passthrough indices are ["
@@ -997,8 +995,7 @@ absl::optional<int64> GetOnlyNonContractingNonBatchDim(
// `contracting_dims` and `batch_dims` are the contracting and batch dimensions
// of whatever operand `indexed_array` is to the dot (LHS or RHS).
bool CanFoldDotIntoIndexedArray(
- tensorflow::StringPiece tag,
- Analysis::ScalarIndexedConstantArray* indexed_array,
+ absl::string_view tag, Analysis::ScalarIndexedConstantArray* indexed_array,
ArraySlice<int64> contracting_dims, ArraySlice<int64> batch_dims) {
absl::optional<int64> non_contracting_non_batch_dim =
GetOnlyNonContractingNonBatchDim(ShapeUtil::Rank(indexed_array->shape()),
@@ -1135,7 +1132,7 @@ StatusOr<Analysis::Array*> IndexedArrayAnalysis::ComputeArrayForDot(
return nullptr;
}
-tensorflow::StringPiece IndexedArrayAnalysisPrinterPass::name() const {
+absl::string_view IndexedArrayAnalysisPrinterPass::name() const {
return "indexed-array-analysis-printer-pass";
}
diff --git a/tensorflow/compiler/xla/service/indexed_array_analysis.h b/tensorflow/compiler/xla/service/indexed_array_analysis.h
index 675eb31d26..3fa7d749e1 100644
--- a/tensorflow/compiler/xla/service/indexed_array_analysis.h
+++ b/tensorflow/compiler/xla/service/indexed_array_analysis.h
@@ -371,7 +371,7 @@ class IndexedArrayAnalysis {
// unconditionally add to the regular HLO pass pipeline.
class IndexedArrayAnalysisPrinterPass : public HloPassInterface {
public:
- tensorflow::StringPiece name() const override;
+ absl::string_view name() const override;
StatusOr<bool> Run(HloModule* module) override;
};
diff --git a/tensorflow/compiler/xla/service/indexed_array_analysis_test.cc b/tensorflow/compiler/xla/service/indexed_array_analysis_test.cc
index 97052edf7d..2d03aebc1a 100644
--- a/tensorflow/compiler/xla/service/indexed_array_analysis_test.cc
+++ b/tensorflow/compiler/xla/service/indexed_array_analysis_test.cc
@@ -634,9 +634,9 @@ ENTRY main {
AssertArrayWithConstantsForRootExpressionIs(hlo_text, 1 + R"(
(scalar-indexed-const (constant f32[3,4] f32[3,4] {
- { 0.761594176, 0.964027584, 0.995054781, 0.999329329 },
- { 0.761594176, 0.995054781, 0.964027584, 0.999329329 },
- { 0.999329329, 0.995054781, 0.964027584, 0.761594176 }
+ { 0.761594, 0.964028, 0.995055, 0.999329 },
+ { 0.761594, 0.995055, 0.964028, 0.999329 },
+ { 0.999329, 0.995055, 0.964028, 0.761594 }
}) %indices 0->[0]))");
}
diff --git a/tensorflow/compiler/xla/service/inliner.h b/tensorflow/compiler/xla/service/inliner.h
index a523811f6c..efa8ed3abc 100644
--- a/tensorflow/compiler/xla/service/inliner.h
+++ b/tensorflow/compiler/xla/service/inliner.h
@@ -27,7 +27,7 @@ namespace xla {
class Inliner : public HloPassInterface {
public:
~Inliner() override = default;
- tensorflow::StringPiece name() const override { return "inline"; }
+ absl::string_view name() const override { return "inline"; }
// Run inlining on the given computation. Returns whether the computation was
// changed.
diff --git a/tensorflow/compiler/xla/service/instruction_fusion.h b/tensorflow/compiler/xla/service/instruction_fusion.h
index f73ca9adf7..8489c3d9ad 100644
--- a/tensorflow/compiler/xla/service/instruction_fusion.h
+++ b/tensorflow/compiler/xla/service/instruction_fusion.h
@@ -36,7 +36,7 @@ class InstructionFusion : public HloPassInterface {
bool may_duplicate = true)
: is_expensive_(is_expensive), may_duplicate_(may_duplicate) {}
~InstructionFusion() override = default;
- tensorflow::StringPiece name() const override { return "fusion"; }
+ absl::string_view name() const override { return "fusion"; }
// Run instruction fusion on the given computation. Returns whether the
// computation was changed (instructions were fused).
diff --git a/tensorflow/compiler/xla/service/layout_assignment.cc b/tensorflow/compiler/xla/service/layout_assignment.cc
index c75bffc63d..6b1802c5d1 100644
--- a/tensorflow/compiler/xla/service/layout_assignment.cc
+++ b/tensorflow/compiler/xla/service/layout_assignment.cc
@@ -27,6 +27,7 @@ limitations under the License.
#include <tuple>
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/layout_util.h"
#include "tensorflow/compiler/xla/map_util.h"
#include "tensorflow/compiler/xla/service/computation_layout.h"
@@ -50,7 +51,6 @@ limitations under the License.
#include "tensorflow/core/lib/core/status.h"
#include "tensorflow/core/lib/gtl/array_slice.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/lib/strings/stringprintf.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/protobuf.h"
@@ -368,31 +368,27 @@ const ShapeLayout* LayoutConstraints::ResultLayout() const {
string LayoutConstraints::ToString() const {
string output;
- tensorflow::strings::StrAppend(&output, "LayoutConstraints for computation ",
- computation_->name(), ":\n");
+ absl::StrAppend(&output, "LayoutConstraints for computation ",
+ computation_->name(), ":\n");
for (auto* instruction : computation_->MakeInstructionPostOrder()) {
- tensorflow::strings::StrAppend(&output, " ", instruction->ToShortString(),
- "\n");
+ absl::StrAppend(&output, " ", instruction->ToShortString(), "\n");
for (int64 i = 0; i < instruction->operand_count(); ++i) {
if (OperandLayout(instruction, i) != nullptr) {
- tensorflow::strings::StrAppend(
- &output, " operand (", i,
- "): ", OperandLayout(instruction, i)->ToString(), "\n");
+ absl::StrAppend(&output, " operand (", i,
+ "): ", OperandLayout(instruction, i)->ToString(), "\n");
}
}
for (const LogicalBuffer* buffer :
points_to_analysis_.GetBuffersDefinedByInstruction(instruction)) {
if (BufferLayout(*buffer) != nullptr) {
- tensorflow::strings::StrAppend(
- &output, " ", buffer->ToString(), " : ",
- LayoutUtil::HumanString(*BufferLayout(*buffer)), "\n");
+ absl::StrAppend(&output, " ", buffer->ToString(), " : ",
+ LayoutUtil::HumanString(*BufferLayout(*buffer)), "\n");
}
}
}
if (ResultLayout() != nullptr) {
- tensorflow::strings::StrAppend(&output, " => ", ResultLayout()->ToString(),
- "\n");
+ absl::StrAppend(&output, " => ", ResultLayout()->ToString(), "\n");
}
return output;
}
diff --git a/tensorflow/compiler/xla/service/layout_assignment.h b/tensorflow/compiler/xla/service/layout_assignment.h
index f9e8dbea2f..3e000ec2df 100644
--- a/tensorflow/compiler/xla/service/layout_assignment.h
+++ b/tensorflow/compiler/xla/service/layout_assignment.h
@@ -297,7 +297,7 @@ class LayoutAssignment : public HloPassInterface {
ComputationLayout* entry_computation_layout,
ChannelLayoutConstraints* channel_constraints = nullptr);
~LayoutAssignment() override {}
- tensorflow::StringPiece name() const override { return "layout-assignment"; }
+ absl::string_view name() const override { return "layout-assignment"; }
// Assign layouts to the given module. Returns whether the module was changed
// (any layouts were changed).
diff --git a/tensorflow/compiler/xla/service/layout_assignment_test.cc b/tensorflow/compiler/xla/service/layout_assignment_test.cc
index a16fa75e30..6d05fa5fe2 100644
--- a/tensorflow/compiler/xla/service/layout_assignment_test.cc
+++ b/tensorflow/compiler/xla/service/layout_assignment_test.cc
@@ -59,7 +59,7 @@ class LayoutAssignmentTest : public HloTestBase {
EXPECT_IS_OK(layout_assignment.Run(module).status());
}
- std::vector<int64> LayoutOf(HloModule* module, tensorflow::StringPiece name) {
+ std::vector<int64> LayoutOf(HloModule* module, absl::string_view name) {
auto minor_to_major =
FindInstruction(module, name)->shape().layout().minor_to_major();
return std::vector<int64>(minor_to_major.begin(), minor_to_major.end());
diff --git a/tensorflow/compiler/xla/service/llvm_ir/BUILD b/tensorflow/compiler/xla/service/llvm_ir/BUILD
index 539a9522c1..fc3289f30d 100644
--- a/tensorflow/compiler/xla/service/llvm_ir/BUILD
+++ b/tensorflow/compiler/xla/service/llvm_ir/BUILD
@@ -38,6 +38,7 @@ cc_library(
"//tensorflow/compiler/xla/service:hlo",
"//tensorflow/compiler/xla/service:logical_buffer",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
"@llvm//:core",
],
)
@@ -69,6 +70,7 @@ cc_library(
"//tensorflow/compiler/xla/service:hlo_module_config",
"//tensorflow/compiler/xla/service:name_uniquer",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
"@llvm//:core",
"@llvm//:support",
"@llvm//:target",
@@ -89,6 +91,7 @@ cc_library(
"//tensorflow/compiler/xla:xla_data_proto",
"//tensorflow/core:lib",
"@com_google_absl//absl/algorithm:container",
+ "@com_google_absl//absl/strings",
"@llvm//:core",
],
)
@@ -104,6 +107,7 @@ cc_library(
"//tensorflow/compiler/xla:types",
"//tensorflow/compiler/xla:xla_data_proto",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
"@llvm//:core",
],
)
@@ -192,6 +196,7 @@ cc_library(
"//tensorflow/compiler/xla/service/gpu:parallel_loop_emitter",
"//tensorflow/compiler/xla/service/gpu:partition_assignment",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
"@com_google_absl//absl/types:optional",
"@llvm//:core",
],
@@ -219,7 +224,7 @@ cc_library(
deps = [
":llvm_loop",
"//tensorflow/compiler/xla/service/llvm_ir:llvm_util",
- "//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
"@llvm//:core",
],
)
@@ -230,6 +235,7 @@ cc_library(
hdrs = ["buffer_assignment_util.h"],
deps = [
"//tensorflow/compiler/xla/service:buffer_assignment",
+ "@com_google_absl//absl/strings",
],
)
diff --git a/tensorflow/compiler/xla/service/llvm_ir/alias_analysis.h b/tensorflow/compiler/xla/service/llvm_ir/alias_analysis.h
index fe9eab93aa..8d9fa99d82 100644
--- a/tensorflow/compiler/xla/service/llvm_ir/alias_analysis.h
+++ b/tensorflow/compiler/xla/service/llvm_ir/alias_analysis.h
@@ -16,6 +16,7 @@ limitations under the License.
#ifndef TENSORFLOW_COMPILER_XLA_SERVICE_LLVM_IR_ALIAS_ANALYSIS_H_
#define TENSORFLOW_COMPILER_XLA_SERVICE_LLVM_IR_ALIAS_ANALYSIS_H_
+#include "absl/strings/str_cat.h"
#include "llvm/IR/Module.h"
#include "tensorflow/compiler/xla/service/buffer_assignment.h"
#include "tensorflow/compiler/xla/service/hlo_instruction.h"
@@ -23,7 +24,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/core/lib/gtl/flatmap.h"
#include "tensorflow/core/lib/gtl/flatset.h"
-#include "tensorflow/core/lib/strings/strcat.h"
namespace xla {
namespace llvm_ir {
diff --git a/tensorflow/compiler/xla/service/llvm_ir/buffer_assignment_util.cc b/tensorflow/compiler/xla/service/llvm_ir/buffer_assignment_util.cc
index 4eb5d9fb47..bdce4a171b 100644
--- a/tensorflow/compiler/xla/service/llvm_ir/buffer_assignment_util.cc
+++ b/tensorflow/compiler/xla/service/llvm_ir/buffer_assignment_util.cc
@@ -14,6 +14,7 @@ limitations under the License.
==============================================================================*/
#include "tensorflow/compiler/xla/service/llvm_ir/buffer_assignment_util.h"
+#include "absl/strings/str_cat.h"
namespace xla {
namespace llvm_ir {
@@ -48,7 +49,7 @@ string ConstantBufferAllocationToGlobalName(
c = '_';
}
}
- return tensorflow::strings::StrCat("buffer_for_", instr_name);
+ return absl::StrCat("buffer_for_", instr_name);
}
const Literal& LiteralForConstantAllocation(
diff --git a/tensorflow/compiler/xla/service/llvm_ir/dynamic_update_slice_util.cc b/tensorflow/compiler/xla/service/llvm_ir/dynamic_update_slice_util.cc
index 27fbb11e2e..ad350613dd 100644
--- a/tensorflow/compiler/xla/service/llvm_ir/dynamic_update_slice_util.cc
+++ b/tensorflow/compiler/xla/service/llvm_ir/dynamic_update_slice_util.cc
@@ -40,7 +40,7 @@ static Status EmitDynamicUpdateSliceInPlaceImpl(
const Shape& update_shape, const ElementGenerator& start_indices_generator,
bool is_signed, ElementGenerator update_array_generator,
const IrArray& output_array, const gpu::LaunchDimensions* launch_dimensions,
- tensorflow::StringPiece name, llvm::IRBuilder<>* b) {
+ absl::string_view name, llvm::IRBuilder<>* b) {
const Shape& output_shape = output_array.GetShape();
// Read start indices from start_indices_generator.
@@ -101,8 +101,7 @@ static Status EmitDynamicUpdateSliceInPlaceImpl(
Status EmitDynamicUpdateSliceInPlace(
tensorflow::gtl::ArraySlice<IrArray> operand_arrays,
- const IrArray& output_array, tensorflow::StringPiece name,
- llvm::IRBuilder<>* b) {
+ const IrArray& output_array, absl::string_view name, llvm::IRBuilder<>* b) {
VLOG(2) << "EmitDynamicUpdateSliceInPlace for " << name;
// No need to use operand_arrays[0], the input array of the
diff --git a/tensorflow/compiler/xla/service/llvm_ir/dynamic_update_slice_util.h b/tensorflow/compiler/xla/service/llvm_ir/dynamic_update_slice_util.h
index 3502577d23..e1631a62ae 100644
--- a/tensorflow/compiler/xla/service/llvm_ir/dynamic_update_slice_util.h
+++ b/tensorflow/compiler/xla/service/llvm_ir/dynamic_update_slice_util.h
@@ -65,8 +65,7 @@ inline bool CanEmitFusedDynamicUpdateSliceInPlace(
// modify the input/output buffer without touching any of the other elements.
Status EmitDynamicUpdateSliceInPlace(
tensorflow::gtl::ArraySlice<IrArray> operand_arrays,
- const IrArray& output_array, tensorflow::StringPiece name,
- llvm::IRBuilder<>* b);
+ const IrArray& output_array, absl::string_view name, llvm::IRBuilder<>* b);
// Given a loop-fusion node whose root is a dynamic-update-slice op whose
// array-to-be-updated and output share the same buffer slice, emits
diff --git a/tensorflow/compiler/xla/service/llvm_ir/ir_array.cc b/tensorflow/compiler/xla/service/llvm_ir/ir_array.cc
index 2b6caee6aa..6971220022 100644
--- a/tensorflow/compiler/xla/service/llvm_ir/ir_array.cc
+++ b/tensorflow/compiler/xla/service/llvm_ir/ir_array.cc
@@ -342,9 +342,9 @@ llvm::Value* IrArray::Index::Linearize(
return logical_linear_index;
}
-llvm::Value* IrArray::EmitArrayElementAddress(
- const IrArray::Index& index, llvm::IRBuilder<>* b,
- tensorflow::StringPiece name) const {
+llvm::Value* IrArray::EmitArrayElementAddress(const IrArray::Index& index,
+ llvm::IRBuilder<>* b,
+ absl::string_view name) const {
if (ShapeUtil::IsScalar(*shape_)) {
// Special handling of scalars: a scalar pretends to have the same value for
// every index, thus effectively implementing broadcasting of its value
@@ -402,7 +402,7 @@ void IrArray::AnnotateLoadStoreInstructionWithMetadata(
llvm::Value* IrArray::EmitReadArrayElement(const Index& index,
llvm::IRBuilder<>* b,
- tensorflow::StringPiece name) const {
+ absl::string_view name) const {
llvm::Value* element_address = EmitArrayElementAddress(index, b, name);
llvm::LoadInst* load = b->CreateLoad(element_address);
AnnotateLoadStoreInstructionWithMetadata(load);
diff --git a/tensorflow/compiler/xla/service/llvm_ir/ir_array.h b/tensorflow/compiler/xla/service/llvm_ir/ir_array.h
index cbfd2e7012..e913c109b3 100644
--- a/tensorflow/compiler/xla/service/llvm_ir/ir_array.h
+++ b/tensorflow/compiler/xla/service/llvm_ir/ir_array.h
@@ -20,12 +20,12 @@ limitations under the License.
#include <vector>
#include "absl/algorithm/container.h"
+#include "absl/strings/string_view.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Value.h"
#include "tensorflow/compiler/xla/map_util.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/gtl/array_slice.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/types.h"
@@ -241,7 +241,7 @@ class IrArray {
// The optional name is useful for debugging when looking at
// the emitted LLVM IR.
llvm::Value* EmitArrayElementAddress(const Index& index, llvm::IRBuilder<>* b,
- tensorflow::StringPiece name = "") const;
+ absl::string_view name = "") const;
// Attach metadata this IrArray instance knows about to "instruction".
void AnnotateLoadStoreInstructionWithMetadata(
@@ -255,7 +255,7 @@ class IrArray {
// The optional name is useful for debugging when looking at
// the emitted LLVM IR.
llvm::Value* EmitReadArrayElement(const Index& index, llvm::IRBuilder<>* b,
- tensorflow::StringPiece name = "") const;
+ absl::string_view name = "") const;
// Emit IR to write the given value to the array element at the given index.
void EmitWriteArrayElement(const Index& index, llvm::Value* value,
diff --git a/tensorflow/compiler/xla/service/llvm_ir/kernel_support_library.cc b/tensorflow/compiler/xla/service/llvm_ir/kernel_support_library.cc
index b79567369a..bd0139f85b 100644
--- a/tensorflow/compiler/xla/service/llvm_ir/kernel_support_library.cc
+++ b/tensorflow/compiler/xla/service/llvm_ir/kernel_support_library.cc
@@ -19,7 +19,7 @@ limitations under the License.
namespace xla {
Status KernelSupportLibrary::For(
- tensorflow::StringPiece name, llvm::Value* start, llvm::Value* end,
+ absl::string_view name, llvm::Value* start, llvm::Value* end,
llvm::Value* step,
const std::function<Status(llvm::Value*, bool)>& for_body_generator) {
return If(b_->CreateICmpSLT(start, end), [&]() -> Status {
@@ -30,7 +30,7 @@ Status KernelSupportLibrary::For(
}
Status KernelSupportLibrary::For(
- tensorflow::StringPiece name, llvm::Value* start, llvm::Value* end,
+ absl::string_view name, llvm::Value* start, llvm::Value* end,
llvm::Value* step, bool peel_first_iteration,
const std::function<Status(llvm::Value*, llvm::Value*)>&
for_body_generator) {
@@ -56,7 +56,7 @@ Status KernelSupportLibrary::For(
}
Status KernelSupportLibrary::If(
- tensorflow::StringPiece name, llvm::Value* condition,
+ absl::string_view name, llvm::Value* condition,
const std::function<Status()>& true_block_generator,
const std::function<Status()>& false_block_generator) {
llvm_ir::LlvmIfData if_data = llvm_ir::EmitIfThenElse(condition, name, b_);
@@ -70,7 +70,7 @@ Status KernelSupportLibrary::If(
void KernelSupportLibrary::EmitAndCallOutlinedKernel(
bool enable_fast_math, bool optimize_for_size, llvm::IRBuilder<>* b,
- tensorflow::StringPiece kernel_name,
+ absl::string_view kernel_name,
KernelSupportLibrary::ArgumentVector arguments,
const std::function<void(KernelSupportLibrary::ArgumentVector)>&
kernel_body_generator) {
diff --git a/tensorflow/compiler/xla/service/llvm_ir/kernel_support_library.h b/tensorflow/compiler/xla/service/llvm_ir/kernel_support_library.h
index c5354a8c42..b152cf9275 100644
--- a/tensorflow/compiler/xla/service/llvm_ir/kernel_support_library.h
+++ b/tensorflow/compiler/xla/service/llvm_ir/kernel_support_library.h
@@ -18,12 +18,12 @@ limitations under the License.
#include <string>
+#include "absl/strings/string_view.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Value.h"
#include "tensorflow/compiler/xla/service/llvm_ir/llvm_loop.h"
#include "tensorflow/compiler/xla/service/llvm_ir/llvm_util.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
namespace xla {
// A thin wrapper around llvm_loop.h to make code generating structured control
@@ -49,13 +49,13 @@ class KernelSupportLibrary {
// `for_body_generator(/*ind_var=*/,i, /*is_first_iteration=*/false)`;
// }
Status For(
- tensorflow::StringPiece name, llvm::Value* start, llvm::Value* end,
+ absl::string_view name, llvm::Value* start, llvm::Value* end,
llvm::Value* step,
const std::function<Status(llvm::Value* ind_var,
bool is_first_iteration)>& for_body_generator);
void ForReturnVoid(
- tensorflow::StringPiece name, llvm::Value* start, llvm::Value* end,
+ absl::string_view name, llvm::Value* start, llvm::Value* end,
llvm::Value* step,
const std::function<void(llvm::Value* ind_var, bool is_first_iteration)>&
for_body_generator) {
@@ -67,7 +67,7 @@ class KernelSupportLibrary {
}));
}
- Status For(tensorflow::StringPiece name, int64 start, int64 end, int64 step,
+ Status For(absl::string_view name, int64 start, int64 end, int64 step,
const std::function<Status(llvm::Value* ind_var,
bool is_first_iteration)>&
for_body_generator) {
@@ -77,7 +77,7 @@ class KernelSupportLibrary {
}
void ForReturnVoid(
- tensorflow::StringPiece name, int64 start, int64 end, int64 step,
+ absl::string_view name, int64 start, int64 end, int64 step,
const std::function<void(llvm::Value* ind_var, bool is_first_iteration)>&
for_body_generator) {
ForReturnVoid(name, /*start=*/b_->getInt64(start),
@@ -99,13 +99,13 @@ class KernelSupportLibrary {
// for (i64 i = `start`; i s< `end`; i += `step`)
// `for_body_generator(/*ind_var=*/,i,
// /*is_first_iteration=*/,(i != `start`))`;
- Status For(tensorflow::StringPiece name, llvm::Value* start, llvm::Value* end,
+ Status For(absl::string_view name, llvm::Value* start, llvm::Value* end,
llvm::Value* step, bool peel_first_iteration,
const std::function<Status(llvm::Value* ind_var,
llvm::Value* is_first_iteration)>&
for_body_generator);
- void ForReturnVoid(tensorflow::StringPiece name, llvm::Value* start,
+ void ForReturnVoid(absl::string_view name, llvm::Value* start,
llvm::Value* end, llvm::Value* step,
bool peel_first_iteration,
const std::function<void(llvm::Value* ind_var,
@@ -119,7 +119,7 @@ class KernelSupportLibrary {
}));
}
- Status For(tensorflow::StringPiece name, llvm::Value* start, llvm::Value* end,
+ Status For(absl::string_view name, llvm::Value* start, llvm::Value* end,
int64 step, bool peel_first_iteration,
const std::function<Status(llvm::Value* ind_var,
llvm::Value* is_first_iteration)>&
@@ -129,7 +129,7 @@ class KernelSupportLibrary {
peel_first_iteration, for_body_generator);
}
- void ForReturnVoid(tensorflow::StringPiece name, llvm::Value* start,
+ void ForReturnVoid(absl::string_view name, llvm::Value* start,
llvm::Value* end, int64 step, bool peel_first_iteration,
const std::function<void(llvm::Value* ind_var,
llvm::Value* is_first_iteration)>&
@@ -140,7 +140,7 @@ class KernelSupportLibrary {
}
Status For(
- tensorflow::StringPiece name, llvm::Value* start, llvm::Value* end,
+ absl::string_view name, llvm::Value* start, llvm::Value* end,
llvm::Value* step,
const std::function<Status(llvm::Value* ind_var)>& for_body_generator) {
return For(name, start, end, step,
@@ -151,7 +151,7 @@ class KernelSupportLibrary {
}
void ForReturnVoid(
- tensorflow::StringPiece name, llvm::Value* start, llvm::Value* end,
+ absl::string_view name, llvm::Value* start, llvm::Value* end,
llvm::Value* step,
const std::function<void(llvm::Value* ind_var)>& for_body_generator) {
ForReturnVoid(name, start, end, step,
@@ -162,8 +162,7 @@ class KernelSupportLibrary {
}
Status For(
- tensorflow::StringPiece name, llvm::Value* start, llvm::Value* end,
- int64 step,
+ absl::string_view name, llvm::Value* start, llvm::Value* end, int64 step,
const std::function<Status(llvm::Value* ind_var)>& for_body_generator) {
return For(name, start, end, llvm::ConstantInt::get(start->getType(), step),
/*peel_first_iteration=*/false,
@@ -173,8 +172,7 @@ class KernelSupportLibrary {
}
void ForReturnVoid(
- tensorflow::StringPiece name, llvm::Value* start, llvm::Value* end,
- int64 step,
+ absl::string_view name, llvm::Value* start, llvm::Value* end, int64 step,
const std::function<void(llvm::Value* ind_var)>& for_body_generator) {
ForReturnVoid(name, start, end,
llvm::ConstantInt::get(start->getType(), step),
@@ -182,7 +180,7 @@ class KernelSupportLibrary {
}
Status For(
- tensorflow::StringPiece name, int64 start, int64 end, int64 step,
+ absl::string_view name, int64 start, int64 end, int64 step,
const std::function<Status(llvm::Value* ind_var)>& for_body_generator) {
return For(name, /*start=*/b_->getInt64(start),
/*end=*/b_->getInt64(end),
@@ -190,7 +188,7 @@ class KernelSupportLibrary {
}
void ForReturnVoid(
- tensorflow::StringPiece name, int64 start, int64 end, int64 step,
+ absl::string_view name, int64 start, int64 end, int64 step,
const std::function<void(llvm::Value* ind_var)>& for_body_generator) {
ForReturnVoid(name, /*start=*/b_->getInt64(start),
/*end=*/b_->getInt64(end),
@@ -203,7 +201,7 @@ class KernelSupportLibrary {
// `true_block_generator()`;
// else
// `false_block_generator()`;
- Status If(tensorflow::StringPiece name, llvm::Value* condition,
+ Status If(absl::string_view name, llvm::Value* condition,
const std::function<Status()>& true_block_generator,
const std::function<Status()>& false_block_generator =
[]() -> Status { return Status::OK(); });
@@ -222,7 +220,7 @@ class KernelSupportLibrary {
IfReturnVoid("", condition, true_block_generator, false_block_generator);
}
- void IfReturnVoid(tensorflow::StringPiece name, llvm::Value* condition,
+ void IfReturnVoid(absl::string_view name, llvm::Value* condition,
const std::function<void()>& true_block_generator,
const std::function<void()>& false_block_generator = []() {
}) {
@@ -259,13 +257,13 @@ class KernelSupportLibrary {
// Currently we only support at most one nullptr value in `arguments`.
static void EmitAndCallOutlinedKernel(
bool enable_fast_math, bool optimize_for_size, llvm::IRBuilder<>* b,
- tensorflow::StringPiece kernel_name, ArgumentVector arguments,
+ absl::string_view kernel_name, ArgumentVector arguments,
const std::function<void(ArgumentVector)>& kernel_body_generator);
// Thin wrappers around the more general EmitAndCallOutlinedKernel above.
static void EmitAndCallOutlinedKernel(
bool enable_fast_math, bool optimize_for_size, llvm::IRBuilder<>* b,
- tensorflow::StringPiece kernel_name, llvm::Value* arg0, llvm::Value* arg1,
+ absl::string_view kernel_name, llvm::Value* arg0, llvm::Value* arg1,
llvm::Value* arg2,
const std::function<void(llvm::Value*, llvm::Value*, llvm::Value*)>&
kernel_body_generator) {
@@ -278,7 +276,7 @@ class KernelSupportLibrary {
static void EmitAndCallOutlinedKernel(
bool enable_fast_math, bool optimize_for_size, llvm::IRBuilder<>* b,
- tensorflow::StringPiece kernel_name, llvm::Value* arg0, llvm::Value* arg1,
+ absl::string_view kernel_name, llvm::Value* arg0, llvm::Value* arg1,
llvm::Value* arg2, llvm::Value* arg3,
const std::function<void(llvm::Value*, llvm::Value*, llvm::Value*,
llvm::Value*)>& kernel_body_generator) {
diff --git a/tensorflow/compiler/xla/service/llvm_ir/llvm_loop.cc b/tensorflow/compiler/xla/service/llvm_ir/llvm_loop.cc
index ba7f94834c..978fa5b453 100644
--- a/tensorflow/compiler/xla/service/llvm_ir/llvm_loop.cc
+++ b/tensorflow/compiler/xla/service/llvm_ir/llvm_loop.cc
@@ -18,6 +18,7 @@ limitations under the License.
#include <numeric>
#include <vector>
+#include "absl/strings/str_cat.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Instructions.h"
@@ -25,14 +26,13 @@ limitations under the License.
#include "tensorflow/compiler/xla/shape_util.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/lib/strings/stringprintf.h"
#include "tensorflow/core/platform/logging.h"
namespace xla {
namespace llvm_ir {
-ForLoop::ForLoop(tensorflow::StringPiece prefix, tensorflow::StringPiece suffix,
+ForLoop::ForLoop(absl::string_view prefix, absl::string_view suffix,
llvm::Value* start_index, llvm::Value* end_index,
llvm::Value* step, UnrollMode unroll_mode,
bool prevent_vectorization)
@@ -46,9 +46,9 @@ ForLoop::ForLoop(tensorflow::StringPiece prefix, tensorflow::StringPiece suffix,
prevent_vectorization_(prevent_vectorization) {}
/* static */ std::unique_ptr<ForLoop> ForLoop::EmitForLoop(
- tensorflow::StringPiece prefix, llvm::Value* start_index,
- llvm::Value* end_index, llvm::Value* step, llvm::IRBuilder<>* b,
- UnrollMode unroll_mode, bool prevent_vectorization) {
+ absl::string_view prefix, llvm::Value* start_index, llvm::Value* end_index,
+ llvm::Value* step, llvm::IRBuilder<>* b, UnrollMode unroll_mode,
+ bool prevent_vectorization) {
std::unique_ptr<ForLoop> loop(new ForLoop(prefix, /*suffix=*/"", start_index,
end_index, step, unroll_mode,
prevent_vectorization));
@@ -168,16 +168,16 @@ std::vector<llvm::Metadata*> ForLoop::GetLoopMetadata(llvm::IRBuilder<>* b) {
return result;
}
-string ForLoop::GetQualifiedName(tensorflow::StringPiece name) {
+string ForLoop::GetQualifiedName(absl::string_view name) {
return llvm_ir::IrName(prefix_, llvm_ir::IrName(name, suffix_));
}
-llvm::BasicBlock* ForLoop::CreateLoopBB(tensorflow::StringPiece name,
+llvm::BasicBlock* ForLoop::CreateLoopBB(absl::string_view name,
llvm::IRBuilder<>* b) {
return CreateBasicBlock(insert_before_bb_, GetQualifiedName(name), b);
}
-std::unique_ptr<ForLoop> ForLoopNest::AddLoop(tensorflow::StringPiece suffix,
+std::unique_ptr<ForLoop> ForLoopNest::AddLoop(absl::string_view suffix,
llvm::Value* start_index,
llvm::Value* end_index,
UnrollMode unroll_mode,
@@ -186,12 +186,9 @@ std::unique_ptr<ForLoop> ForLoopNest::AddLoop(tensorflow::StringPiece suffix,
unroll_mode, prevent_vectorization);
}
-std::unique_ptr<ForLoop> ForLoopNest::AddLoop(tensorflow::StringPiece suffix,
- llvm::Value* start_index,
- llvm::Value* end_index,
- llvm::Value* stride,
- UnrollMode unroll_mode,
- bool prevent_vectorization) {
+std::unique_ptr<ForLoop> ForLoopNest::AddLoop(
+ absl::string_view suffix, llvm::Value* start_index, llvm::Value* end_index,
+ llvm::Value* stride, UnrollMode unroll_mode, bool prevent_vectorization) {
if (inner_loop_body_bb_ != nullptr) {
// Create this loop inside the previous one.
b_->SetInsertPoint(&*inner_loop_body_bb_->getFirstInsertionPt());
@@ -216,7 +213,7 @@ std::unique_ptr<ForLoop> ForLoopNest::AddLoop(tensorflow::StringPiece suffix,
std::unique_ptr<ForLoop> ForLoopNest::AddLoop(int64 start_index,
int64 end_index,
- tensorflow::StringPiece suffix,
+ absl::string_view suffix,
UnrollMode unroll_mode,
bool prevent_vectorization) {
CHECK_LE(start_index, end_index);
@@ -227,7 +224,7 @@ std::unique_ptr<ForLoop> ForLoopNest::AddLoop(int64 start_index,
std::unique_ptr<ForLoop> ForLoopNest::AddLoop(int64 start_index,
int64 end_index, int64 stride,
- tensorflow::StringPiece suffix,
+ absl::string_view suffix,
UnrollMode unroll_mode,
bool prevent_vectorization) {
CHECK_LE(start_index, end_index);
@@ -238,7 +235,7 @@ std::unique_ptr<ForLoop> ForLoopNest::AddLoop(int64 start_index,
}
IrArray::Index ForLoopNest::AddLoopsForShape(const Shape& shape,
- tensorflow::StringPiece suffix) {
+ absl::string_view suffix) {
std::vector<int64> dimensions(ShapeUtil::Rank(shape));
std::iota(dimensions.begin(), dimensions.end(), 0);
return AddLoopsForShapeOnDimensions(shape, dimensions, suffix);
@@ -246,14 +243,14 @@ IrArray::Index ForLoopNest::AddLoopsForShape(const Shape& shape,
IrArray::Index ForLoopNest::AddLoopsForShapeOnDimensions(
const Shape& shape, tensorflow::gtl::ArraySlice<int64> dimensions,
- tensorflow::StringPiece suffix) {
+ absl::string_view suffix) {
llvm_ir::IrArray::Index index(index_type_, shape.dimensions_size());
for (int64 dimension : dimensions) {
std::unique_ptr<llvm_ir::ForLoop> loop = AddLoop(
/*start_index=*/0,
/*end_index=*/shape.dimensions(dimension),
/*suffix=*/
- llvm_ir::IrName(suffix, tensorflow::strings::StrCat(dimension)));
+ llvm_ir::IrName(suffix, absl::StrCat(dimension)));
index[dimension] = loop->GetIndVarValue();
}
return index;
@@ -261,7 +258,7 @@ IrArray::Index ForLoopNest::AddLoopsForShapeOnDimensions(
IrArray::Index ForLoopNest::EmitOperandArrayLoopNest(
const llvm_ir::IrArray& operand_array, int64 dimension_to_skip,
- tensorflow::StringPiece name_suffix) {
+ absl::string_view name_suffix) {
// Prepares the dimension list we will use to emit the loop nest. Outermost
// loops are added first. Add loops in major-to-minor order, and skip the
// 'dimension_to_skip' dimension.
diff --git a/tensorflow/compiler/xla/service/llvm_ir/llvm_loop.h b/tensorflow/compiler/xla/service/llvm_ir/llvm_loop.h
index a4fed5c8dc..62aa15fe2d 100644
--- a/tensorflow/compiler/xla/service/llvm_ir/llvm_loop.h
+++ b/tensorflow/compiler/xla/service/llvm_ir/llvm_loop.h
@@ -19,15 +19,15 @@ limitations under the License.
#include <memory>
#include <string>
+#include "absl/strings/str_cat.h"
+#include "absl/strings/string_view.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Value.h"
#include "tensorflow/compiler/xla/service/llvm_ir/ir_array.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/gtl/array_slice.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/macros.h"
#include "tensorflow/core/platform/types.h"
@@ -78,7 +78,7 @@ class ForLoop {
// `unroll_mode` specifies the desired LLVM unrolling behavior for generated
// loop.
static std::unique_ptr<ForLoop> EmitForLoop(
- tensorflow::StringPiece prefix, llvm::Value* start_index,
+ absl::string_view prefix, llvm::Value* start_index,
llvm::Value* end_index, llvm::Value* step, llvm::IRBuilder<>* b,
UnrollMode unroll_mode = llvm_ir::UnrollMode::kDefaultUnroll,
bool prevent_vectorization = false);
@@ -133,19 +133,18 @@ class ForLoop {
// Allow ForLoopNest to call this private constructor.
friend class ForLoopNest;
- ForLoop(tensorflow::StringPiece prefix, tensorflow::StringPiece suffix,
+ ForLoop(absl::string_view prefix, absl::string_view suffix,
llvm::Value* start_index, llvm::Value* end_index, llvm::Value* step,
UnrollMode unroll_mode, bool prevent_vectorization);
// Emit the loop at the insert point of the builder.
void Emit(llvm::IRBuilder<>* b);
- llvm::BasicBlock* CreateLoopBB(tensorflow::StringPiece name,
- llvm::IRBuilder<>* b);
+ llvm::BasicBlock* CreateLoopBB(absl::string_view name, llvm::IRBuilder<>* b);
// Creates a name for an LLVM construct, appending prefix_ and suffix_, if
// they are set.
- string GetQualifiedName(tensorflow::StringPiece name);
+ string GetQualifiedName(absl::string_view name);
// Return a list of metadata nodes that should be associated with the
// llvm::Loop for this `ForLoop`.
@@ -182,7 +181,7 @@ class ForLoopNest {
SetIndexType(index_ty);
}
- ForLoopNest(tensorflow::StringPiece name, llvm::IRBuilder<>* b,
+ ForLoopNest(absl::string_view name, llvm::IRBuilder<>* b,
llvm::Type* index_ty = nullptr)
: name_(std::string(name)),
outer_loop_preheader_bb_(nullptr),
@@ -197,14 +196,14 @@ class ForLoopNest {
// been added then emit loop inside the body of the last added loop.
// unroll_mode is used to emit metadata that controls LLVM unrolling.
std::unique_ptr<ForLoop> AddLoop(
- tensorflow::StringPiece suffix, llvm::Value* start_index,
+ absl::string_view suffix, llvm::Value* start_index,
llvm::Value* end_index, llvm::Value* stride,
UnrollMode unroll_mode = xla::llvm_ir::UnrollMode::kDefaultUnroll,
bool prevent_vectorization = false);
// Like the above, except that it defaults to a stride of one.
std::unique_ptr<ForLoop> AddLoop(
- tensorflow::StringPiece suffix, llvm::Value* start_index,
+ absl::string_view suffix, llvm::Value* start_index,
llvm::Value* end_index,
UnrollMode unroll_mode = xla::llvm_ir::UnrollMode::kDefaultUnroll,
bool prevent_vectorization = false);
@@ -213,13 +212,13 @@ class ForLoopNest {
// end index are constant.
std::unique_ptr<ForLoop> AddLoop(
int64 start_index, int64 end_index, int64 stride,
- tensorflow::StringPiece suffix,
+ absl::string_view suffix,
UnrollMode unroll_mode = xla::llvm_ir::UnrollMode::kDefaultUnroll,
bool prevent_vectorization = false);
// Like the above, except that it defaults to a stride of one.
std::unique_ptr<ForLoop> AddLoop(
- int64 start_index, int64 end_index, tensorflow::StringPiece suffix,
+ int64 start_index, int64 end_index, absl::string_view suffix,
UnrollMode unroll_mode = xla::llvm_ir::UnrollMode::kDefaultUnroll,
bool prevent_vectorization = false);
@@ -234,8 +233,7 @@ class ForLoopNest {
// within the shape. One possible order for that sequence would be:
//
// (0,0), (0,1), (0,2), (1,0), (1,1), (1,2)
- IrArray::Index AddLoopsForShape(const Shape& shape,
- tensorflow::StringPiece suffix);
+ IrArray::Index AddLoopsForShape(const Shape& shape, absl::string_view suffix);
// Add a loop for each dimension in "dimensions". "suffix" is the
// name suffix of the indvar and basic blocks in this new loop nest.
@@ -245,7 +243,7 @@ class ForLoopNest {
// dimension that is not in "dimensions".
IrArray::Index AddLoopsForShapeOnDimensions(
const Shape& shape, tensorflow::gtl::ArraySlice<int64> dimensions,
- tensorflow::StringPiece suffix);
+ absl::string_view suffix);
// Emits a series of nested loops for iterating over an operand array. Loops
// are constructed in major to minor dimension layout order. No loop is
@@ -256,7 +254,7 @@ class ForLoopNest {
// basic blocks) constructed by this method.
IrArray::Index EmitOperandArrayLoopNest(const llvm_ir::IrArray& operand_array,
int64 dimension_to_skip,
- tensorflow::StringPiece name_suffix);
+ absl::string_view name_suffix);
// Convenience methods which return particular basic blocks of the outermost
// or innermost loops. These methods return nullptr if no loops have been
diff --git a/tensorflow/compiler/xla/service/llvm_ir/llvm_util.cc b/tensorflow/compiler/xla/service/llvm_ir/llvm_util.cc
index e6126881af..37b27b36ba 100644
--- a/tensorflow/compiler/xla/service/llvm_ir/llvm_util.cc
+++ b/tensorflow/compiler/xla/service/llvm_ir/llvm_util.cc
@@ -19,6 +19,8 @@ limitations under the License.
#include <memory>
#include <vector>
+#include "absl/strings/match.h"
+#include "absl/strings/str_cat.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/MDBuilder.h"
@@ -35,7 +37,6 @@ limitations under the License.
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/io/path.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/byte_order.h"
#include "tensorflow/core/platform/env.h"
#include "tensorflow/core/platform/logging.h"
@@ -61,7 +62,7 @@ string AsString(const std::string& str) {
return string(str.data(), str.length());
}
-llvm::StringRef AsStringRef(tensorflow::StringPiece str) {
+llvm::StringRef AsStringRef(absl::string_view str) {
return llvm::StringRef(str.data(), str.size());
}
@@ -262,15 +263,17 @@ llvm::Constant* ConvertLiteralToIrConstant(const Literal& literal,
}
llvm::AllocaInst* EmitAllocaAtFunctionEntry(llvm::Type* type,
- tensorflow::StringPiece name,
+ absl::string_view name,
llvm::IRBuilder<>* b,
int alignment) {
return EmitAllocaAtFunctionEntryWithCount(type, nullptr, name, b, alignment);
}
-llvm::AllocaInst* EmitAllocaAtFunctionEntryWithCount(
- llvm::Type* type, llvm::Value* element_count, tensorflow::StringPiece name,
- llvm::IRBuilder<>* b, int alignment) {
+llvm::AllocaInst* EmitAllocaAtFunctionEntryWithCount(llvm::Type* type,
+ llvm::Value* element_count,
+ absl::string_view name,
+ llvm::IRBuilder<>* b,
+ int alignment) {
llvm::IRBuilder<>::InsertPoint insert_point = b->saveIP();
llvm::Function* function = b->GetInsertBlock()->getParent();
b->SetInsertPoint(&function->getEntryBlock(),
@@ -285,7 +288,7 @@ llvm::AllocaInst* EmitAllocaAtFunctionEntryWithCount(
}
llvm::BasicBlock* CreateBasicBlock(llvm::BasicBlock* insert_before,
- tensorflow::StringPiece name,
+ absl::string_view name,
llvm::IRBuilder<>* b) {
return llvm::BasicBlock::Create(
/*Context=*/b->getContext(),
@@ -294,27 +297,25 @@ llvm::BasicBlock* CreateBasicBlock(llvm::BasicBlock* insert_before,
/*InsertBefore*/ insert_before);
}
-LlvmIfData EmitIfThenElse(llvm::Value* condition, tensorflow::StringPiece name,
+LlvmIfData EmitIfThenElse(llvm::Value* condition, absl::string_view name,
llvm::IRBuilder<>* b, bool emit_else) {
llvm_ir::LlvmIfData if_data;
if_data.if_block = b->GetInsertBlock();
if_data.true_block =
- CreateBasicBlock(nullptr, tensorflow::strings::StrCat(name, "-true"), b);
+ CreateBasicBlock(nullptr, absl::StrCat(name, "-true"), b);
if_data.false_block =
- emit_else ? CreateBasicBlock(
- nullptr, tensorflow::strings::StrCat(name, "-false"), b)
+ emit_else ? CreateBasicBlock(nullptr, absl::StrCat(name, "-false"), b)
: nullptr;
// Add a terminator to the if block, if necessary.
if (if_data.if_block->getTerminator() == nullptr) {
b->SetInsertPoint(if_data.if_block);
- if_data.after_block = CreateBasicBlock(
- nullptr, tensorflow::strings::StrCat(name, "-after"), b);
+ if_data.after_block =
+ CreateBasicBlock(nullptr, absl::StrCat(name, "-after"), b);
b->CreateBr(if_data.after_block);
} else {
if_data.after_block = if_data.if_block->splitBasicBlock(
- b->GetInsertPoint(),
- AsStringRef(tensorflow::strings::StrCat(name, "-after")));
+ b->GetInsertPoint(), AsStringRef(absl::StrCat(name, "-after")));
}
// Our basic block should now end with an unconditional branch. Remove it;
@@ -413,14 +414,14 @@ string IrName(string a) {
return a;
}
-string IrName(tensorflow::StringPiece a, tensorflow::StringPiece b) {
+string IrName(absl::string_view a, absl::string_view b) {
if (!a.empty() && !b.empty()) {
- return IrName(tensorflow::strings::StrCat(a, ".", b));
+ return IrName(absl::StrCat(a, ".", b));
}
- return IrName(tensorflow::strings::StrCat(a, b));
+ return IrName(absl::StrCat(a, b));
}
-string IrName(const HloInstruction* a, tensorflow::StringPiece b) {
+string IrName(const HloInstruction* a, absl::string_view b) {
return IrName(a->name(), b);
}
@@ -556,7 +557,7 @@ std::map<int, llvm::MDNode*> MergeMetadata(
return result;
}
-static string GetProcessUniqueIrFileName(tensorflow::StringPiece prefix) {
+static string GetProcessUniqueIrFileName(absl::string_view prefix) {
static tensorflow::mutex mu(tensorflow::LINKER_INITIALIZED);
static NameUniquer* uniquer = new NameUniquer(/*separator=*/"-");
@@ -584,18 +585,16 @@ Status DumpIRToDirectory(const string& directory_name,
// XlaJitCompiledCpuFunction::Compile. Avoid overwriting IR files previously
// dumped from the same process in such cases.
string unique_and_safe_file_name = GetProcessUniqueIrFileName(
- tensorflow::strings::StrCat("ir-", SanitizeFileName(hlo_module_name), "-",
- optimized ? "with" : "no", "-opt"));
+ absl::StrCat("ir-", SanitizeFileName(hlo_module_name), "-",
+ optimized ? "with" : "no", "-opt"));
string ir_file_name = tensorflow::io::JoinPath(
- directory_name,
- tensorflow::strings::StrCat(unique_and_safe_file_name, ".ll"));
+ directory_name, absl::StrCat(unique_and_safe_file_name, ".ll"));
// For some models the embedded constants can be huge, so also dump the module
// with the constants stripped to get IR that is easier to manipulate.
string ir_no_constant_initializers_file_name = tensorflow::io::JoinPath(
- directory_name,
- tensorflow::strings::StrCat(unique_and_safe_file_name, "-noconst.ll"));
+ directory_name, absl::StrCat(unique_and_safe_file_name, "-noconst.ll"));
TF_RETURN_IF_ERROR(CreateAndWriteStringToFile(
directory_name, ir_file_name, DumpModuleToString(llvm_module)));
@@ -607,8 +606,7 @@ Status DumpIRToDirectory(const string& directory_name,
llvm::Function* CreateFunction(llvm::FunctionType* function_type,
llvm::GlobalValue::LinkageTypes linkage,
bool enable_fast_math, bool optimize_for_size,
- tensorflow::StringPiece name,
- llvm::Module* module) {
+ absl::string_view name, llvm::Module* module) {
llvm::Function* function =
llvm::Function::Create(function_type, linkage, AsStringRef(name), module);
function->setCallingConv(llvm::CallingConv::C);
@@ -638,7 +636,7 @@ void InitializeLLVMCommandLineOptions(const HloModuleConfig& config) {
fake_argv_storage.push_back("");
for (const auto& it : options) {
// Skip options the XLA backend itself consumes.
- if (!tensorflow::str_util::StartsWith(it.first, "xla_")) {
+ if (!absl::StartsWith(it.first, "xla_")) {
if (it.second.empty()) {
fake_argv_storage.push_back(it.first);
} else {
diff --git a/tensorflow/compiler/xla/service/llvm_ir/llvm_util.h b/tensorflow/compiler/xla/service/llvm_ir/llvm_util.h
index 0958398534..dde50e19d1 100644
--- a/tensorflow/compiler/xla/service/llvm_ir/llvm_util.h
+++ b/tensorflow/compiler/xla/service/llvm_ir/llvm_util.h
@@ -20,6 +20,7 @@ limitations under the License.
#include <string>
#include <vector>
+#include "absl/strings/string_view.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/IRBuilder.h"
@@ -32,7 +33,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/hlo_module_config.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/gtl/array_slice.h"
#include "tensorflow/core/platform/types.h"
@@ -47,11 +47,11 @@ namespace llvm_ir {
// Convert a std::string (used by LLVM's interfaces) to string.
string AsString(const std::string& str);
-// Convert a tensorflow::StringPiece to a llvm::StringRef. Note: both
-// tensorflow::StringPiece and llvm::StringRef are non-owning pointers into a
+// Convert a absl::string_view to a llvm::StringRef. Note: both
+// absl::string_view and llvm::StringRef are non-owning pointers into a
// string in memory. This method is used to feed strings to LLVM
// & Clang APIs that expect llvm::StringRef.
-llvm::StringRef AsStringRef(tensorflow::StringPiece str);
+llvm::StringRef AsStringRef(absl::string_view str);
template <typename T>
llvm::ArrayRef<T> AsArrayRef(const std::vector<T>& vec) {
@@ -88,8 +88,8 @@ string DumpModuleToString(const llvm::Module& module);
// - removing all '%'s.
//
string IrName(string a);
-string IrName(tensorflow::StringPiece a, tensorflow::StringPiece b);
-string IrName(const HloInstruction* a, tensorflow::StringPiece b = "");
+string IrName(absl::string_view a, absl::string_view b);
+string IrName(const HloInstruction* a, absl::string_view b = "");
// Removes special characters from a function name.
//
@@ -164,21 +164,23 @@ llvm::Constant* ConvertLiteralToIrConstant(const Literal& literal,
// This can be useful to avoid e.g. executing an alloca every time
// through a loop.
llvm::AllocaInst* EmitAllocaAtFunctionEntry(llvm::Type* type,
- tensorflow::StringPiece name,
+ absl::string_view name,
llvm::IRBuilder<>* b,
int alignment = 0);
// As EmitAllocaAtFunctionEntry, but allocates element_count entries
// instead of a single element.
-llvm::AllocaInst* EmitAllocaAtFunctionEntryWithCount(
- llvm::Type* type, llvm::Value* element_count, tensorflow::StringPiece name,
- llvm::IRBuilder<>* b, int alignment = 0);
+llvm::AllocaInst* EmitAllocaAtFunctionEntryWithCount(llvm::Type* type,
+ llvm::Value* element_count,
+ absl::string_view name,
+ llvm::IRBuilder<>* b,
+ int alignment = 0);
// Creates a basic block with the same context and function as for the
// builder. Inserts at the end of the function if insert_before is
// null.
llvm::BasicBlock* CreateBasicBlock(llvm::BasicBlock* insert_before,
- tensorflow::StringPiece name,
+ absl::string_view name,
llvm::IRBuilder<>* b);
// Struct with data on a conditional branch in a diamond shape created
@@ -210,7 +212,7 @@ struct LlvmIfData {
// Currently the insertion point of the builder must be a well-formed
// block with a terminator. If you need to use this for a
// non-terminated block, just make the function able to do that too.
-LlvmIfData EmitIfThenElse(llvm::Value* condition, tensorflow::StringPiece name,
+LlvmIfData EmitIfThenElse(llvm::Value* condition, absl::string_view name,
llvm::IRBuilder<>* b, bool emit_else = true);
// Emits a compare operation between "lhs" and "rhs" with the given predicate,
@@ -285,8 +287,7 @@ Status DumpIRToDirectory(const string& directory_name,
llvm::Function* CreateFunction(llvm::FunctionType* function_type,
llvm::GlobalValue::LinkageTypes linkage,
bool enable_fast_math, bool optimize_for_size,
- tensorflow::StringPiece name,
- llvm::Module* module);
+ absl::string_view name, llvm::Module* module);
// Extracts the xla_backend_extra_options from `config` and passes those that
// don't start with xla_ to LLVM.
diff --git a/tensorflow/compiler/xla/service/llvm_ir/loop_emitter.cc b/tensorflow/compiler/xla/service/llvm_ir/loop_emitter.cc
index 36f5fa1952..cf7445804c 100644
--- a/tensorflow/compiler/xla/service/llvm_ir/loop_emitter.cc
+++ b/tensorflow/compiler/xla/service/llvm_ir/loop_emitter.cc
@@ -86,7 +86,7 @@ LoopEmitter::LoopEmitter(const ElementGenerator& target_element_generator,
}
std::vector<IrArray::Index> LoopEmitter::EmitIndexAndSetExitBasicBlock(
- tensorflow::StringPiece loop_name, llvm::Type* index_type) {
+ absl::string_view loop_name, llvm::Type* index_type) {
CHECK_NE(index_type, nullptr);
if (ShapeUtil::IsScalar(shape_)) {
// No loop needed, so set exit_bb_ to nullptr.
@@ -122,7 +122,7 @@ std::vector<IrArray::Index> LoopEmitter::EmitIndexAndSetExitBasicBlock(
return {array_index};
}
-Status LoopEmitter::EmitLoop(tensorflow::StringPiece loop_name,
+Status LoopEmitter::EmitLoop(absl::string_view loop_name,
llvm::Type* index_type) {
if (index_type == nullptr) {
index_type = b_->getInt64Ty();
diff --git a/tensorflow/compiler/xla/service/llvm_ir/loop_emitter.h b/tensorflow/compiler/xla/service/llvm_ir/loop_emitter.h
index c4f5c82086..57d9d8bbc6 100644
--- a/tensorflow/compiler/xla/service/llvm_ir/loop_emitter.h
+++ b/tensorflow/compiler/xla/service/llvm_ir/loop_emitter.h
@@ -69,10 +69,10 @@ class LoopEmitter {
}
virtual std::vector<IrArray::Index> EmitIndexAndSetExitBasicBlock(
- tensorflow::StringPiece loop_name, llvm::Type* index_type);
+ absl::string_view loop_name, llvm::Type* index_type);
// Emits a complete loop nest for every element in the given shape.
- Status EmitLoop(tensorflow::StringPiece loop_name = "",
+ Status EmitLoop(absl::string_view loop_name = "",
llvm::Type* index_type = nullptr);
protected:
diff --git a/tensorflow/compiler/xla/service/llvm_ir/sort_util.cc b/tensorflow/compiler/xla/service/llvm_ir/sort_util.cc
index c333311a7e..00dd3f1638 100644
--- a/tensorflow/compiler/xla/service/llvm_ir/sort_util.cc
+++ b/tensorflow/compiler/xla/service/llvm_ir/sort_util.cc
@@ -16,6 +16,7 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/llvm_ir/sort_util.h"
// IWYU pragma: no_include "llvm/IR/Intrinsics.gen.inc"
+#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constants.h"
@@ -30,7 +31,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/llvm_ir/loop_emitter.h"
#include "tensorflow/compiler/xla/shape_util.h"
#include "tensorflow/core/lib/core/status.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/platform/types.h"
namespace xla {
@@ -88,7 +88,7 @@ void EmitCompareLoop(int64 dimension_to_sort, const IrArray::Index& keys_index,
Status EmitSortInPlace(int64 dimension_to_sort, const IrArray& keys_array,
const absl::optional<IrArray>& values_array,
- tensorflow::StringPiece name, llvm::Value* xor_mask,
+ absl::string_view name, llvm::Value* xor_mask,
llvm::IRBuilder<>* b,
const gpu::LaunchDimensions* launch_dimensions) {
const Shape& keys_shape = keys_array.GetShape();
diff --git a/tensorflow/compiler/xla/service/llvm_ir/sort_util.h b/tensorflow/compiler/xla/service/llvm_ir/sort_util.h
index 39fffea931..527ed10374 100644
--- a/tensorflow/compiler/xla/service/llvm_ir/sort_util.h
+++ b/tensorflow/compiler/xla/service/llvm_ir/sort_util.h
@@ -16,12 +16,12 @@ limitations under the License.
#ifndef TENSORFLOW_COMPILER_XLA_SERVICE_LLVM_IR_SORT_UTIL_H_
#define TENSORFLOW_COMPILER_XLA_SERVICE_LLVM_IR_SORT_UTIL_H_
+#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "llvm/IR/Value.h"
#include "tensorflow/compiler/xla/service/gpu/partition_assignment.h"
#include "tensorflow/compiler/xla/service/llvm_ir/ir_array.h"
#include "tensorflow/core/lib/core/status.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/platform/types.h"
namespace xla {
@@ -32,7 +32,7 @@ namespace llvm_ir {
// the inner compare loop will not be parallelized.
Status EmitSortInPlace(int64 dimension_to_sort, const IrArray& keys_array,
const absl::optional<IrArray>& values_array,
- tensorflow::StringPiece name, llvm::Value* xor_mask,
+ absl::string_view name, llvm::Value* xor_mask,
llvm::IRBuilder<>* b,
const gpu::LaunchDimensions* launch_dimensions);
} // namespace llvm_ir
diff --git a/tensorflow/compiler/xla/service/local_service.cc b/tensorflow/compiler/xla/service/local_service.cc
index b7cb782a7e..ea59adadea 100644
--- a/tensorflow/compiler/xla/service/local_service.cc
+++ b/tensorflow/compiler/xla/service/local_service.cc
@@ -20,6 +20,7 @@ limitations under the License.
#include <vector>
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/client/executable_build_options.h"
#include "tensorflow/compiler/xla/client/xla_computation.h"
#include "tensorflow/compiler/xla/execution_options_util.h"
@@ -37,7 +38,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/compiler/xla/util.h"
#include "tensorflow/core/lib/gtl/cleanup.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/stream_executor_no_cuda.h"
diff --git a/tensorflow/compiler/xla/service/logical_buffer.cc b/tensorflow/compiler/xla/service/logical_buffer.cc
index c742d35a7b..3a21993322 100644
--- a/tensorflow/compiler/xla/service/logical_buffer.cc
+++ b/tensorflow/compiler/xla/service/logical_buffer.cc
@@ -15,11 +15,11 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/logical_buffer.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/service/hlo_computation.h"
#include "tensorflow/compiler/xla/service/hlo_instruction.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
namespace xla {
@@ -34,11 +34,11 @@ LogicalBuffer::~LogicalBuffer() {}
string LogicalBuffer::ToString() const {
string color_string;
if (has_color()) {
- color_string = tensorflow::strings::StrCat(" @", color().value());
+ color_string = absl::StrCat(" @", color().value());
}
- return tensorflow::strings::StrCat(instruction_->name(), "[",
- tensorflow::str_util::Join(index_, ","),
- "](#", id(), color_string, ")");
+ return absl::StrCat(instruction_->name(), "[",
+ tensorflow::str_util::Join(index_, ","), "](#", id(),
+ color_string, ")");
}
} // namespace xla
diff --git a/tensorflow/compiler/xla/service/multi_output_fusion.h b/tensorflow/compiler/xla/service/multi_output_fusion.h
index 6aa639a954..4c8cb7d379 100644
--- a/tensorflow/compiler/xla/service/multi_output_fusion.h
+++ b/tensorflow/compiler/xla/service/multi_output_fusion.h
@@ -19,10 +19,10 @@ limitations under the License.
#include <queue>
#include <vector>
+#include "absl/strings/string_view.h"
#include "tensorflow/compiler/xla/service/hlo_module.h"
#include "tensorflow/compiler/xla/service/hlo_pass_interface.h"
#include "tensorflow/compiler/xla/statusor.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
namespace xla {
@@ -48,9 +48,7 @@ class MultiOutputFusion : public HloPassInterface {
public:
MultiOutputFusion(int64 fuel) : fuel_(fuel) {}
- tensorflow::StringPiece name() const override {
- return "multi_output_fusion";
- }
+ absl::string_view name() const override { return "multi_output_fusion"; }
// Run multi-output fusion on the given module. Returns whether the module
// was changed.
diff --git a/tensorflow/compiler/xla/service/name_uniquer.cc b/tensorflow/compiler/xla/service/name_uniquer.cc
index f6e7578a89..70cd0a339a 100644
--- a/tensorflow/compiler/xla/service/name_uniquer.cc
+++ b/tensorflow/compiler/xla/service/name_uniquer.cc
@@ -15,8 +15,9 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/name_uniquer.h"
+#include "absl/strings/numbers.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/types.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/types.h"
@@ -52,7 +53,7 @@ NameUniquer::NameUniquer(const string& separator) {
return result;
}
-string NameUniquer::GetUniqueName(tensorflow::StringPiece prefix) {
+string NameUniquer::GetUniqueName(absl::string_view prefix) {
string root = GetSanitizedName(prefix.empty() ? "name" : std::string(prefix));
// Strip away numeric suffix (if any). Only recognize separator if it is in
@@ -63,20 +64,22 @@ string NameUniquer::GetUniqueName(tensorflow::StringPiece prefix) {
if (separator_index != string::npos && (separator_index > 0) &&
(separator_index < root.size() - 1)) {
string after_suffix = root.substr(separator_index + 1);
- if (tensorflow::strings::safe_strto64(after_suffix, &numeric_suffix)) {
+ if (absl::SimpleAtoi(after_suffix, &numeric_suffix)) {
has_numeric_suffix = true;
// Remove numeric suffix from root.
root = root.substr(0, separator_index);
+ } else {
+ // absl::SimpleAtoi may modify numeric_suffix even if it returns false.
+ numeric_suffix = 0;
}
}
SequentialIdGenerator& id_generator = generated_names_[root];
numeric_suffix = id_generator.RegisterId(numeric_suffix);
if (numeric_suffix == 0) {
- return has_numeric_suffix ? tensorflow::strings::StrCat(root, separator_, 0)
- : root;
+ return has_numeric_suffix ? absl::StrCat(root, separator_, 0) : root;
}
- tensorflow::strings::StrAppend(&root, separator_, numeric_suffix);
+ absl::StrAppend(&root, separator_, numeric_suffix);
return root;
}
diff --git a/tensorflow/compiler/xla/service/name_uniquer.h b/tensorflow/compiler/xla/service/name_uniquer.h
index 4423d61069..6dd89c240f 100644
--- a/tensorflow/compiler/xla/service/name_uniquer.h
+++ b/tensorflow/compiler/xla/service/name_uniquer.h
@@ -18,8 +18,8 @@ limitations under the License.
#include <string>
+#include "absl/strings/string_view.h"
#include "tensorflow/compiler/xla/types.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/gtl/flatmap.h"
#include "tensorflow/core/lib/gtl/flatset.h"
#include "tensorflow/core/platform/macros.h"
@@ -38,7 +38,7 @@ class NameUniquer {
// Get a sanitized unique name in a string, with an optional prefix for
// convenience.
- string GetUniqueName(tensorflow::StringPiece prefix = "");
+ string GetUniqueName(absl::string_view prefix = "");
// Sanitizes and returns the name. Unallowed characters will be replaced with
// '_'. The result will match the regexp "[a-zA-Z_][a-zA-Z0-9_.-]*".
diff --git a/tensorflow/compiler/xla/service/pattern_matcher.h b/tensorflow/compiler/xla/service/pattern_matcher.h
index ac6ea4c72f..ccc06ce613 100644
--- a/tensorflow/compiler/xla/service/pattern_matcher.h
+++ b/tensorflow/compiler/xla/service/pattern_matcher.h
@@ -16,11 +16,11 @@ limitations under the License.
#ifndef TENSORFLOW_COMPILER_XLA_SERVICE_PATTERN_MATCHER_H_
#define TENSORFLOW_COMPILER_XLA_SERVICE_PATTERN_MATCHER_H_
+#include "absl/strings/string_view.h"
#include "tensorflow/compiler/xla/layout_util.h"
#include "tensorflow/compiler/xla/service/hlo_instruction.h"
#include "tensorflow/compiler/xla/service/hlo_opcode.h"
#include "tensorflow/compiler/xla/shape_util.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
namespace xla {
@@ -622,7 +622,7 @@ template <typename Previous>
class HloInstructionPatternNameImpl {
public:
explicit HloInstructionPatternNameImpl(const Previous& previous,
- tensorflow::StringPiece name)
+ absl::string_view name)
: previous_(previous), name_(name) {}
bool Match(const ::xla::HloInstruction* inst) const {
@@ -631,7 +631,7 @@ class HloInstructionPatternNameImpl {
private:
Previous previous_;
- tensorflow::StringPiece name_;
+ absl::string_view name_;
};
// An HloInstructionPattern implementation that matches only if the instruction
@@ -784,7 +784,7 @@ class HloInstructionPattern {
// Modifies the pattern to match only if the instruction has the given name.
HloInstructionPattern<HloInstructionType, HloInstructionPatternNameImpl<Impl>>
- WithName(tensorflow::StringPiece name) const {
+ WithName(absl::string_view name) const {
return HloInstructionPattern<HloInstructionType,
HloInstructionPatternNameImpl<Impl>>(
HloInstructionPatternNameImpl<Impl>(impl_, name), matched_inst_);
diff --git a/tensorflow/compiler/xla/service/reduce_precision_insertion.h b/tensorflow/compiler/xla/service/reduce_precision_insertion.h
index afde3cf95c..256b231e3a 100644
--- a/tensorflow/compiler/xla/service/reduce_precision_insertion.h
+++ b/tensorflow/compiler/xla/service/reduce_precision_insertion.h
@@ -59,7 +59,7 @@ class ReducePrecisionInsertion : public HloPassInterface {
~ReducePrecisionInsertion() override{};
- tensorflow::StringPiece name() const override {
+ absl::string_view name() const override {
return "reduce-precision-insertion";
}
diff --git a/tensorflow/compiler/xla/service/reshape_mover.h b/tensorflow/compiler/xla/service/reshape_mover.h
index 1f59e3b314..1e86a0823a 100644
--- a/tensorflow/compiler/xla/service/reshape_mover.h
+++ b/tensorflow/compiler/xla/service/reshape_mover.h
@@ -26,7 +26,7 @@ namespace xla {
// them inputward also.
class ReshapeMover : public HloPassInterface {
public:
- tensorflow::StringPiece name() const override { return "reshape-mover"; }
+ absl::string_view name() const override { return "reshape-mover"; }
StatusOr<bool> Run(HloModule* module) override;
};
diff --git a/tensorflow/compiler/xla/service/scatter_expander.h b/tensorflow/compiler/xla/service/scatter_expander.h
index 8f735e877d..14f062c89c 100644
--- a/tensorflow/compiler/xla/service/scatter_expander.h
+++ b/tensorflow/compiler/xla/service/scatter_expander.h
@@ -22,7 +22,7 @@ namespace xla {
class ScatterExpander : public HloPassInterface {
public:
- tensorflow::StringPiece name() const override { return "scatter_expander"; }
+ absl::string_view name() const override { return "scatter_expander"; }
StatusOr<bool> Run(HloModule* module) override;
private:
diff --git a/tensorflow/compiler/xla/service/service.cc b/tensorflow/compiler/xla/service/service.cc
index 18d1b7732b..eafb2fe7ac 100644
--- a/tensorflow/compiler/xla/service/service.cc
+++ b/tensorflow/compiler/xla/service/service.cc
@@ -21,6 +21,7 @@ limitations under the License.
#include <vector>
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/execution_options_util.h"
#include "tensorflow/compiler/xla/layout_util.h"
#include "tensorflow/compiler/xla/legacy_flags/debug_options_flags.h"
@@ -46,7 +47,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/util.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
#include "tensorflow/core/lib/gtl/cleanup.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/lib/strings/stringprintf.h"
#include "tensorflow/core/platform/env.h"
#include "tensorflow/core/platform/logging.h"
@@ -55,8 +55,8 @@ limitations under the License.
#include "tensorflow/core/platform/types.h"
#include "tensorflow/core/util/ptr_util.h"
+using ::absl::StrCat;
using ::tensorflow::strings::Printf;
-using ::tensorflow::strings::StrCat;
namespace xla {
diff --git a/tensorflow/compiler/xla/service/shape_inference.cc b/tensorflow/compiler/xla/service/shape_inference.cc
index ec6aa6df55..50f2080aa4 100644
--- a/tensorflow/compiler/xla/service/shape_inference.cc
+++ b/tensorflow/compiler/xla/service/shape_inference.cc
@@ -22,6 +22,8 @@ limitations under the License.
#include <string>
#include "absl/algorithm/container.h"
+#include "absl/strings/str_cat.h"
+#include "absl/strings/string_view.h"
#include "tensorflow/compiler/xla/shape_util.h"
#include "tensorflow/compiler/xla/status_macros.h"
#include "tensorflow/compiler/xla/types.h"
@@ -29,11 +31,9 @@ limitations under the License.
#include "tensorflow/compiler/xla/window_util.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
#include "tensorflow/core/lib/core/errors.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/gtl/flatset.h"
#include "tensorflow/core/lib/math/math_util.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/lib/strings/stringprintf.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/protobuf.h"
@@ -50,7 +50,7 @@ bool AllUnique(tensorflow::gtl::ArraySlice<int64> slice) {
return std::set<int64>(slice.begin(), slice.end()).size() == slice.size();
}
-Status ExpectArray(const Shape& shape, tensorflow::StringPiece op_type) {
+Status ExpectArray(const Shape& shape, absl::string_view op_type) {
if (!ShapeUtil::IsArray(shape)) {
return InvalidArgument("Expected array argument for %s, but got %s.",
std::string(op_type).c_str(),
@@ -883,12 +883,10 @@ ShapeInference::InferDegenerateDimensionBroadcastShape(HloOpcode operation,
TF_DCHECK_OK(ShapeUtil::ValidateShapeWithOptionalLayout(lhs));
TF_DCHECK_OK(ShapeUtil::ValidateShapeWithOptionalLayout(rhs));
- TF_RETURN_IF_ERROR(
- ExpectArray(lhs, tensorflow::strings::StrCat("lhs of binary operation ",
- HloOpcodeString(opcode))));
- TF_RETURN_IF_ERROR(
- ExpectArray(rhs, tensorflow::strings::StrCat("rhs of binary operation ",
- HloOpcodeString(opcode))));
+ TF_RETURN_IF_ERROR(ExpectArray(
+ lhs, absl::StrCat("lhs of binary operation ", HloOpcodeString(opcode))));
+ TF_RETURN_IF_ERROR(ExpectArray(
+ rhs, absl::StrCat("rhs of binary operation ", HloOpcodeString(opcode))));
switch (opcode) {
case HloOpcode::kMaximum:
case HloOpcode::kMinimum:
@@ -2465,7 +2463,7 @@ ShapeInference::InferDegenerateDimensionBroadcastShape(HloOpcode operation,
string computation_signature = ShapeUtil::HumanString(to_apply);
string argument_shapes =
Join(arg_shapes, ", ", [](string* out, const Shape* shape) {
- tensorflow::strings::StrAppend(out, ShapeUtil::HumanString(*shape));
+ absl::StrAppend(out, ShapeUtil::HumanString(*shape));
});
return InvalidArgument(
"Call applied function arity must match number of arguments; got: "
diff --git a/tensorflow/compiler/xla/service/shaped_buffer.cc b/tensorflow/compiler/xla/service/shaped_buffer.cc
index 70714ffff0..5c12dc37b7 100644
--- a/tensorflow/compiler/xla/service/shaped_buffer.cc
+++ b/tensorflow/compiler/xla/service/shaped_buffer.cc
@@ -19,6 +19,7 @@ limitations under the License.
#include <utility>
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/layout_util.h"
#include "tensorflow/compiler/xla/shape_util.h"
#include "tensorflow/compiler/xla/status_macros.h"
@@ -76,7 +77,7 @@ void ShapedBuffer::clear() {
}
string ShapedBuffer::ToString() const {
- string s = tensorflow::strings::StrCat(
+ string s = absl::StrCat(
"ShapedBuffer(", platform_->Name(), ":", device_ordinal(),
"), on-host shape=" + ShapeUtil::HumanStringWithLayout(on_host_shape()),
", on-device shape=" +
diff --git a/tensorflow/compiler/xla/service/transfer_manager.cc b/tensorflow/compiler/xla/service/transfer_manager.cc
index e0f995fd0d..131269d641 100644
--- a/tensorflow/compiler/xla/service/transfer_manager.cc
+++ b/tensorflow/compiler/xla/service/transfer_manager.cc
@@ -19,6 +19,7 @@ limitations under the License.
#include <utility>
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/shape_util.h"
#include "tensorflow/compiler/xla/status_macros.h"
#include "tensorflow/compiler/xla/types.h"
@@ -28,7 +29,7 @@ limitations under the License.
#include "tensorflow/core/platform/macros.h"
#include "tensorflow/core/platform/notification.h"
-using ::tensorflow::strings::StrCat;
+using ::absl::StrCat;
namespace xla {
/* static */ tensorflow::mutex
diff --git a/tensorflow/compiler/xla/service/transpose_folding.h b/tensorflow/compiler/xla/service/transpose_folding.h
index 71e8446452..3e5aa2db60 100644
--- a/tensorflow/compiler/xla/service/transpose_folding.h
+++ b/tensorflow/compiler/xla/service/transpose_folding.h
@@ -49,7 +49,7 @@ class TransposeFolding : public HloPassInterface {
explicit TransposeFolding(
TransposableGemmOperandsFn transposable_gemm_operands,
TransposableConvOperandsFn transposable_conv_operands);
- tensorflow::StringPiece name() const override { return "transpose-folding"; }
+ absl::string_view name() const override { return "transpose-folding"; }
StatusOr<bool> Run(HloModule* module) override;
diff --git a/tensorflow/compiler/xla/service/tuple_points_to_analysis.cc b/tensorflow/compiler/xla/service/tuple_points_to_analysis.cc
index 0c2f2112af..48cdc25daf 100644
--- a/tensorflow/compiler/xla/service/tuple_points_to_analysis.cc
+++ b/tensorflow/compiler/xla/service/tuple_points_to_analysis.cc
@@ -20,6 +20,7 @@ limitations under the License.
#include <vector>
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/map_util.h"
#include "tensorflow/compiler/xla/service/hlo_dataflow_analysis.h"
#include "tensorflow/compiler/xla/service/hlo_instruction.h"
@@ -28,16 +29,14 @@ limitations under the License.
#include "tensorflow/compiler/xla/util.h"
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/lib/strings/stringprintf.h"
#include "tensorflow/core/platform/logging.h"
namespace xla {
string BufferAlias::ToString() const {
- return tensorflow::strings::StrCat("BufferAlias(", instruction_->name(), "[",
- tensorflow::str_util::Join(index_, ","),
- "])");
+ return absl::StrCat("BufferAlias(", instruction_->name(), "[",
+ tensorflow::str_util::Join(index_, ","), "])");
}
std::ostream& operator<<(std::ostream& out, const BufferAlias& buffer_alias) {
@@ -563,8 +562,7 @@ string TuplePointsToAnalysis::ToString() const {
for (const auto* computation : module_->MakeNonfusionComputations()) {
const char* entry =
computation == module_->entry_computation() ? "entry " : "";
- tensorflow::strings::StrAppend(&output, entry, "computation ",
- computation->name(), ":\n");
+ absl::StrAppend(&output, entry, "computation ", computation->name(), ":\n");
for (const HloInstruction* instruction :
computation->MakeInstructionPostOrder()) {
InstructionToString(instruction, &output);
@@ -576,12 +574,11 @@ string TuplePointsToAnalysis::ToString() const {
}
}
- tensorflow::strings::StrAppend(&output, "LogicalBuffers:\n");
+ absl::StrAppend(&output, "LogicalBuffers:\n");
for (const auto& b : logical_buffer_analysis_->logical_buffers()) {
- tensorflow::strings::StrAppend(&output, " buffer ", b->ToString(), ":\n");
+ absl::StrAppend(&output, " buffer ", b->ToString(), ":\n");
for (const BufferAlias& alias : logical_buffer_aliases_.at(b->id())) {
- tensorflow::strings::StrAppend(&output, " alias ", alias.ToString(),
- "\n");
+ absl::StrAppend(&output, " alias ", alias.ToString(), "\n");
}
}
return output;
@@ -590,21 +587,21 @@ string TuplePointsToAnalysis::ToString() const {
void TuplePointsToAnalysis::InstructionToString(
const HloInstruction* instruction, string* output) const {
const string prefix = instruction->IsFused() ? " " : "";
- tensorflow::strings::StrAppend(output, prefix, " instruction ",
- instruction->ToShortString(), ":\n");
+ absl::StrAppend(output, prefix, " instruction ",
+ instruction->ToShortString(), ":\n");
const PointsToSet& points_to_set = GetPointsToSet(instruction);
- points_to_set.ForEachElement([&prefix, &output](
- const ShapeIndex& index,
- const PointsToSet::BufferList& points_to) {
- tensorflow::strings::StrAppend(
- output, prefix, " {", tensorflow::str_util::Join(index, ","), "}: ",
- tensorflow::str_util::Join(
- points_to, ", ",
- [](string* out, const LogicalBuffer* source) {
- out->append(source->ToString());
- }),
- "\n");
- });
+ points_to_set.ForEachElement(
+ [&prefix, &output](const ShapeIndex& index,
+ const PointsToSet::BufferList& points_to) {
+ absl::StrAppend(output, prefix, " {",
+ tensorflow::str_util::Join(index, ","), "}: ",
+ tensorflow::str_util::Join(
+ points_to, ", ",
+ [](string* out, const LogicalBuffer* source) {
+ out->append(source->ToString());
+ }),
+ "\n");
+ });
}
bool TuplePointsToAnalysis::DoesNotUseOperandBuffer(
diff --git a/tensorflow/compiler/xla/service/tuple_simplifier.h b/tensorflow/compiler/xla/service/tuple_simplifier.h
index 7509501883..8c91d6e69d 100644
--- a/tensorflow/compiler/xla/service/tuple_simplifier.h
+++ b/tensorflow/compiler/xla/service/tuple_simplifier.h
@@ -30,7 +30,7 @@ class TupleSimplifier : public HloPassInterface {
TupleSimplifier() : TupleSimplifier(/*exclude_entry_computation=*/false) {}
explicit TupleSimplifier(bool exclude_entry_computation);
~TupleSimplifier() override {}
- tensorflow::StringPiece name() const override { return "tuple-simplifier"; }
+ absl::string_view name() const override { return "tuple-simplifier"; }
// Run tuple simplification on the given computation. Returns whether the
// computation was changed.
diff --git a/tensorflow/compiler/xla/service/while_loop_constant_sinking.h b/tensorflow/compiler/xla/service/while_loop_constant_sinking.h
index 21fb8568a8..2dba7d7f75 100644
--- a/tensorflow/compiler/xla/service/while_loop_constant_sinking.h
+++ b/tensorflow/compiler/xla/service/while_loop_constant_sinking.h
@@ -54,7 +54,7 @@ class WhileLoopConstantSinking : public HloPassInterface {
public:
~WhileLoopConstantSinking() override = default;
- tensorflow::StringPiece name() const override {
+ absl::string_view name() const override {
return "while-loop-invariant-code-motion";
}
diff --git a/tensorflow/compiler/xla/service/while_loop_invariant_code_motion.h b/tensorflow/compiler/xla/service/while_loop_invariant_code_motion.h
index 8e6cc87875..2cdf20ce80 100644
--- a/tensorflow/compiler/xla/service/while_loop_invariant_code_motion.h
+++ b/tensorflow/compiler/xla/service/while_loop_invariant_code_motion.h
@@ -38,7 +38,7 @@ class WhileLoopInvariantCodeMotion : public HloPassInterface {
: hoist_constants_(hoist_constants) {}
~WhileLoopInvariantCodeMotion() override = default;
- tensorflow::StringPiece name() const override {
+ absl::string_view name() const override {
return "while-loop-invariant-code-motion";
}
StatusOr<bool> Run(HloModule* module) override;
diff --git a/tensorflow/compiler/xla/service/while_loop_simplifier.cc b/tensorflow/compiler/xla/service/while_loop_simplifier.cc
index a24e2b0116..8e8bdaa47b 100644
--- a/tensorflow/compiler/xla/service/while_loop_simplifier.cc
+++ b/tensorflow/compiler/xla/service/while_loop_simplifier.cc
@@ -14,12 +14,12 @@ limitations under the License.
==============================================================================*/
#include "tensorflow/compiler/xla/service/while_loop_simplifier.h"
+#include "absl/strings/str_cat.h"
#include "absl/types/optional.h"
#include "tensorflow/compiler/xla/service/call_inliner.h"
#include "tensorflow/compiler/xla/service/while_loop_analysis.h"
#include "tensorflow/core/lib/gtl/flatmap.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
namespace xla {
@@ -239,8 +239,7 @@ static StatusOr<bool> TryRemoveDeadWhileParams(HloInstruction* while_op) {
<< tensorflow::str_util::Join(
user->users(), ", ",
[&](string* out, const HloInstruction* instr) {
- tensorflow::strings::StrAppend(
- out, instr->ToString(print_no_metadata));
+ absl::StrAppend(out, instr->ToString(print_no_metadata));
})
<< "}";
diff --git a/tensorflow/compiler/xla/service/while_loop_simplifier.h b/tensorflow/compiler/xla/service/while_loop_simplifier.h
index 3d3e1d60f2..78024f14dc 100644
--- a/tensorflow/compiler/xla/service/while_loop_simplifier.h
+++ b/tensorflow/compiler/xla/service/while_loop_simplifier.h
@@ -33,9 +33,7 @@ namespace xla {
class WhileLoopSimplifier : public HloPassInterface {
public:
~WhileLoopSimplifier() override {}
- tensorflow::StringPiece name() const override {
- return "simplify-while-loops";
- }
+ absl::string_view name() const override { return "simplify-while-loops"; }
StatusOr<bool> Run(HloModule* module) override;
};
diff --git a/tensorflow/compiler/xla/service/while_loop_simplifier_test.cc b/tensorflow/compiler/xla/service/while_loop_simplifier_test.cc
index 2e1571943e..c74de1b576 100644
--- a/tensorflow/compiler/xla/service/while_loop_simplifier_test.cc
+++ b/tensorflow/compiler/xla/service/while_loop_simplifier_test.cc
@@ -15,6 +15,8 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/while_loop_simplifier.h"
+#include "absl/strings/str_cat.h"
+#include "absl/strings/str_replace.h"
#include "tensorflow/compiler/xla/service/hlo_matchers.h"
#include "tensorflow/compiler/xla/test.h"
#include "tensorflow/compiler/xla/tests/hlo_verified_test_base.h"
@@ -64,10 +66,8 @@ void WhileLoopSimplifierTest::MakeModuleWithSimpleLoop(int num_iters) {
}
)";
- string hlo_string = tensorflow::str_util::StringReplace(
- hlo_string_template, "{{LOOP_BOUND}}",
- tensorflow::strings::StrCat(42 + num_iters),
- /*replace_all=*/true);
+ string hlo_string = absl::StrReplaceAll(
+ hlo_string_template, {{"{{LOOP_BOUND}}", absl::StrCat(42 + num_iters)}});
ParseAndVerifyModule(hlo_string);
}
@@ -103,10 +103,8 @@ void WhileLoopSimplifierTest::MakeModuleWithSimpleLoopTupleElementLoopBound(
}
)";
- string hlo_string = tensorflow::str_util::StringReplace(
- hlo_string_template, "{{LOOP_BOUND}}",
- tensorflow::strings::StrCat(42 + num_iters),
- /*replace_all=*/true);
+ string hlo_string = absl::StrReplaceAll(
+ hlo_string_template, {{"{{LOOP_BOUND}}", absl::StrCat(42 + num_iters)}});
ParseAndVerifyModule(hlo_string);
}
diff --git a/tensorflow/compiler/xla/service/while_util.cc b/tensorflow/compiler/xla/service/while_util.cc
index 52d9c3e5ae..e8f76ff745 100644
--- a/tensorflow/compiler/xla/service/while_util.cc
+++ b/tensorflow/compiler/xla/service/while_util.cc
@@ -15,15 +15,15 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/while_util.h"
#include "absl/algorithm/container.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/literal_util.h"
#include "tensorflow/compiler/xla/service/hlo_computation.h"
#include "tensorflow/compiler/xla/service/hlo_creation_utils.h"
#include "tensorflow/compiler/xla/service/tuple_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
namespace xla {
-using tensorflow::strings::StrCat;
+using absl::StrCat;
static StatusOr<HloComputation*> WidenWhileCondition(
HloComputation* narrow_condition, const Shape& wide_shape) {
diff --git a/tensorflow/compiler/xla/service/zero_sized_hlo_elimination.h b/tensorflow/compiler/xla/service/zero_sized_hlo_elimination.h
index 8763e588c4..a7f0e207eb 100644
--- a/tensorflow/compiler/xla/service/zero_sized_hlo_elimination.h
+++ b/tensorflow/compiler/xla/service/zero_sized_hlo_elimination.h
@@ -24,7 +24,7 @@ namespace xla {
class ZeroSizedHloElimination : public HloPassInterface {
public:
StatusOr<bool> Run(HloModule* module) override;
- tensorflow::StringPiece name() const override {
+ absl::string_view name() const override {
return "zero_sized_hlo_elimination";
}
};
diff --git a/tensorflow/compiler/xla/shape_util.cc b/tensorflow/compiler/xla/shape_util.cc
index 7244be80d9..03d20f3ca7 100644
--- a/tensorflow/compiler/xla/shape_util.cc
+++ b/tensorflow/compiler/xla/shape_util.cc
@@ -22,6 +22,12 @@ limitations under the License.
#include <utility>
#include <vector>
+#include "absl/strings/ascii.h"
+#include "absl/strings/numbers.h"
+#include "absl/strings/str_cat.h"
+#include "absl/strings/str_split.h"
+#include "absl/strings/string_view.h"
+#include "absl/strings/strip.h"
#include "absl/types/optional.h"
#include "tensorflow/compiler/xla/index_util.h"
#include "tensorflow/compiler/xla/layout_util.h"
@@ -31,20 +37,18 @@ limitations under the License.
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/compiler/xla/util.h"
#include "tensorflow/core/lib/core/errors.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/gtl/iterator_range.h"
#include "tensorflow/core/lib/hash/hash.h"
#include "tensorflow/core/lib/strings/numbers.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/protobuf.h"
#include "tensorflow/core/platform/regexp.h"
namespace xla {
-using ::tensorflow::strings::StrAppend;
-using ::tensorflow::strings::StrCat;
+using ::absl::StrAppend;
+using ::absl::StrCat;
string ShapeIndex::ToString() const { return ShapeIndexView(*this).ToString(); }
@@ -550,14 +554,14 @@ StatusOr<PrimitiveType> StringToPrimitiveType(const string& name) {
namespace {
// Parses shapes with simple recursive descent structure -- consumes from the
// front of s and passes that view recursively as required.
-StatusOr<Shape> ParseShapeStringInternal(tensorflow::StringPiece* s) {
- tensorflow::str_util::RemoveLeadingWhitespace(s);
+StatusOr<Shape> ParseShapeStringInternal(absl::string_view* s) {
+ *s = StripLeadingAsciiWhitespace(*s);
- if (tensorflow::str_util::ConsumePrefix(s, "(")) { // Tuple.
+ if (absl::ConsumePrefix(s, "(")) { // Tuple.
std::vector<Shape> shapes;
bool must_end = false;
while (true) {
- if (tensorflow::str_util::ConsumePrefix(s, ")")) {
+ if (absl::ConsumePrefix(s, ")")) {
break;
} else if (must_end) {
return InvalidArgument("Expected end of tuple; got: \"%s\"",
@@ -565,8 +569,8 @@ StatusOr<Shape> ParseShapeStringInternal(tensorflow::StringPiece* s) {
}
shapes.emplace_back();
TF_ASSIGN_OR_RETURN(shapes.back(), ParseShapeStringInternal(s));
- tensorflow::str_util::RemoveLeadingWhitespace(s);
- must_end = !tensorflow::str_util::ConsumePrefix(s, ",");
+ *s = StripLeadingAsciiWhitespace(*s);
+ must_end = !absl::ConsumePrefix(s, ",");
}
return ShapeUtil::MakeTupleShape(shapes);
}
@@ -575,9 +579,9 @@ StatusOr<Shape> ParseShapeStringInternal(tensorflow::StringPiece* s) {
string dimensions_string;
string format_string;
string layout_string;
- // tensorflow::StringPiece is not compatible with internal RE2 StringPiece, so
+ // absl::string_view is not compatible with internal RE2 StringPiece, so
// we convert in to the RE2-consumable type and then consume the corresponding
- // amount from our StringPiece type.
+ // amount from our string_view type.
static LazyRE2 shape_pattern = {
"^(\\w*\\d*)\\[([\\d,]*)\\](?:\\s*(dense|sparse)?\\s*{([\\d,]+)})?"};
tensorflow::RegexpStringPiece s_consumable(s->data(), s->size());
@@ -585,12 +589,12 @@ StatusOr<Shape> ParseShapeStringInternal(tensorflow::StringPiece* s) {
&dimensions_string, &format_string, &layout_string)) {
size_t consumed = s->size() - s_consumable.size();
s->remove_prefix(consumed);
- auto string_to_int64 = [&s](const string& input) -> StatusOr<int64> {
+ auto string_to_int64 = [&s](absl::string_view input) -> StatusOr<int64> {
int64 element;
- if (!tensorflow::strings::safe_strto64(input.c_str(), &element)) {
+ if (!absl::SimpleAtoi(input, &element)) {
return InvalidArgument(
"Invalid s64 value in parsed shape string: \"%s\" in \"%s\"",
- input.c_str(), std::string(*s).c_str());
+ string(input).c_str(), std::string(*s).c_str());
}
return element;
};
@@ -598,7 +602,7 @@ StatusOr<Shape> ParseShapeStringInternal(tensorflow::StringPiece* s) {
auto comma_list_to_int64s =
[string_to_int64](const string& input) -> StatusOr<std::vector<int64>> {
std::vector<int64> results;
- for (const string& piece : tensorflow::str_util::Split(input, ',')) {
+ for (const auto& piece : absl::StrSplit(input, ',', absl::SkipEmpty())) {
TF_ASSIGN_OR_RETURN(int64 element, string_to_int64(piece));
results.push_back(element);
}
@@ -649,8 +653,7 @@ StatusOr<Shape> ParseShapeStringInternal(tensorflow::StringPiece* s) {
}
} // namespace
-/* static */ StatusOr<Shape> ShapeUtil::ParseShapeString(
- tensorflow::StringPiece s) {
+/* static */ StatusOr<Shape> ShapeUtil::ParseShapeString(absl::string_view s) {
TF_ASSIGN_OR_RETURN(Shape shape, ParseShapeStringInternal(&s));
if (!s.empty()) {
return InvalidArgument("Invalid shape string to parse: \"%s\"",
diff --git a/tensorflow/compiler/xla/shape_util.h b/tensorflow/compiler/xla/shape_util.h
index cb72fbbb0e..84f36e48a0 100644
--- a/tensorflow/compiler/xla/shape_util.h
+++ b/tensorflow/compiler/xla/shape_util.h
@@ -228,7 +228,7 @@ class ShapeUtil {
// Parses a ShapeUtil::HumanString-format shape string back into a shape
// object.
- static StatusOr<Shape> ParseShapeString(tensorflow::StringPiece s);
+ static StatusOr<Shape> ParseShapeString(absl::string_view s);
// Returns whether the LHS and RHS shapes have the same dimensions; note: does
// not check element type.
diff --git a/tensorflow/compiler/xla/shape_util_test.cc b/tensorflow/compiler/xla/shape_util_test.cc
index e5dd62ae9a..f8112352d8 100644
--- a/tensorflow/compiler/xla/shape_util_test.cc
+++ b/tensorflow/compiler/xla/shape_util_test.cc
@@ -16,6 +16,7 @@ limitations under the License.
#include "tensorflow/compiler/xla/shape_util.h"
#include <numeric>
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/layout_util.h"
#include "tensorflow/compiler/xla/status_macros.h"
#include "tensorflow/compiler/xla/test.h"
@@ -24,7 +25,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/util.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
namespace xla {
namespace {
@@ -849,13 +849,13 @@ TEST(ShapeUtilTest, PermuteDimensionsLayout) {
std::iota(layout.begin(), layout.end(), 0);
do {
Shape s = ShapeUtil::MakeShapeWithLayout(F32, {10, 100, 1000}, layout);
- SCOPED_TRACE(tensorflow::strings::StrCat("s=", ShapeUtil::HumanString(s)));
+ SCOPED_TRACE(absl::StrCat("s=", ShapeUtil::HumanString(s)));
std::vector<int64> permutation(3);
std::iota(permutation.begin(), permutation.end(), 0);
do {
- SCOPED_TRACE(tensorflow::strings::StrCat(
- "permutation=", tensorflow::str_util::Join(permutation, ",")));
+ SCOPED_TRACE(absl::StrCat("permutation=",
+ tensorflow::str_util::Join(permutation, ",")));
// TransposeIsBitcast takes the inverse of the permutation that
// PermuteDimensions takes.
diff --git a/tensorflow/compiler/xla/status_macros.cc b/tensorflow/compiler/xla/status_macros.cc
index a6b1f9004f..2997e6e6c6 100644
--- a/tensorflow/compiler/xla/status_macros.cc
+++ b/tensorflow/compiler/xla/status_macros.cc
@@ -17,9 +17,9 @@ limitations under the License.
#include <algorithm>
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/stacktrace.h"
@@ -37,8 +37,7 @@ static void LogError(const Status& status, const char* filename, int line,
if (TF_PREDICT_TRUE(log_severity != tensorflow::NUM_SEVERITIES)) {
string stack_trace;
if (should_log_stack_trace) {
- stack_trace =
- tensorflow::strings::StrCat("\n", tensorflow::CurrentStackTrace());
+ stack_trace = absl::StrCat("\n", tensorflow::CurrentStackTrace());
}
switch (log_severity) {
case tensorflow::INFO:
@@ -142,17 +141,15 @@ Status MakeErrorStream::Impl::GetStatus() {
is_done_ = true;
const string& stream_str = stream_.str();
- const string str =
- prior_message_handling_ == kAppendToPriorMessage
- ? tensorflow::strings::StrCat(prior_message_, stream_str)
- : tensorflow::strings::StrCat(stream_str, prior_message_);
+ const string str = prior_message_handling_ == kAppendToPriorMessage
+ ? absl::StrCat(prior_message_, stream_str)
+ : absl::StrCat(stream_str, prior_message_);
if (TF_PREDICT_FALSE(str.empty())) {
- return MakeError(file_, line_, code_,
- tensorflow::strings::StrCat(
- str, "Error without message at ", file_, ":", line_),
- true /* should_log */,
- tensorflow::ERROR /* log_severity */,
- should_log_stack_trace_);
+ return MakeError(
+ file_, line_, code_,
+ absl::StrCat(str, "Error without message at ", file_, ":", line_),
+ true /* should_log */, tensorflow::ERROR /* log_severity */,
+ should_log_stack_trace_);
} else {
return MakeError(file_, line_, code_, str, should_log_, log_severity_,
should_log_stack_trace_);
diff --git a/tensorflow/compiler/xla/test_helpers.h b/tensorflow/compiler/xla/test_helpers.h
index 8918350135..3ede5e6e38 100644
--- a/tensorflow/compiler/xla/test_helpers.h
+++ b/tensorflow/compiler/xla/test_helpers.h
@@ -19,9 +19,9 @@ limitations under the License.
#include <list>
#include <vector>
+#include "absl/strings/string_view.h"
#include "tensorflow/compiler/xla/statusor.h"
#include "tensorflow/compiler/xla/types.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/platform/protobuf.h"
#include "tensorflow/core/platform/regexp.h"
#include "tensorflow/core/platform/test.h"
diff --git a/tensorflow/compiler/xla/tests/BUILD b/tensorflow/compiler/xla/tests/BUILD
index 6baf95d631..06df4c2e4c 100644
--- a/tensorflow/compiler/xla/tests/BUILD
+++ b/tensorflow/compiler/xla/tests/BUILD
@@ -43,6 +43,7 @@ cc_library(
"//tensorflow/compiler/xla/legacy_flags:debug_options_flags",
"//tensorflow/core:lib",
"//tensorflow/core:test",
+ "@com_google_absl//absl/strings",
],
alwayslink = True,
)
@@ -205,6 +206,7 @@ cc_library(
"//tensorflow/core:stream_executor_no_cuda",
"//tensorflow/core:test",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
@@ -391,6 +393,7 @@ xla_test(
"//tensorflow/core:regexp_internal",
"//tensorflow/core:test",
"@com_google_absl//absl/algorithm:container",
+ "@com_google_absl//absl/strings",
],
)
@@ -557,6 +560,7 @@ xla_test(
"//tensorflow/compiler/xla/tests:xla_internal_test_main",
"//tensorflow/core:lib",
"//tensorflow/core:test",
+ "@com_google_absl//absl/strings",
],
)
@@ -671,6 +675,7 @@ xla_test(
"//tensorflow/compiler/xla/tests:literal_test_util",
"//tensorflow/compiler/xla/tests:xla_internal_test_main",
"//tensorflow/core:lib",
+ "@com_google_absl//absl/strings",
],
)
@@ -689,7 +694,6 @@ xla_test(
"//tensorflow/compiler/xla:shape_util",
"//tensorflow/compiler/xla/client:local_client",
"//tensorflow/compiler/xla/client:xla_builder",
- "//tensorflow/compiler/xla/client:xla_computation",
"//tensorflow/compiler/xla/tests:client_library_test_base",
"//tensorflow/compiler/xla/tests:literal_test_util",
"//tensorflow/compiler/xla/tests:test_utils",
@@ -697,6 +701,7 @@ xla_test(
"//tensorflow/core:framework_internal",
"//tensorflow/core:lib",
"//tensorflow/core:test",
+ "@com_google_absl//absl/strings",
],
)
@@ -746,7 +751,6 @@ xla_test(
"//tensorflow/compiler/xla:shape_util",
"//tensorflow/compiler/xla/client:local_client",
"//tensorflow/compiler/xla/client:xla_builder",
- "//tensorflow/compiler/xla/client:xla_computation",
"//tensorflow/compiler/xla/tests:client_library_test_base",
"//tensorflow/compiler/xla/tests:literal_test_util",
"//tensorflow/compiler/xla/tests:test_utils",
@@ -754,6 +758,7 @@ xla_test(
"//tensorflow/core:framework_internal",
"//tensorflow/core:lib",
"//tensorflow/core:test",
+ "@com_google_absl//absl/strings",
],
)
@@ -829,7 +834,10 @@ xla_test(
timeout = "long",
srcs = ["convolution_test.cc"],
shard_count = 25,
- deps = CONVOLUTION_TEST_DEPS + ["@com_google_absl//absl/memory"],
+ deps = CONVOLUTION_TEST_DEPS + [
+ "@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
+ ],
)
xla_test(
@@ -839,7 +847,10 @@ xla_test(
backend_args = {"gpu": ["--xla_backend_extra_options=xla_gpu_experimental_conv_disable_layout_heuristic"]},
backends = ["gpu"],
shard_count = 25,
- deps = CONVOLUTION_TEST_DEPS + ["@com_google_absl//absl/memory"],
+ deps = CONVOLUTION_TEST_DEPS + [
+ "@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
+ ],
)
xla_test(
@@ -1001,6 +1012,7 @@ xla_test(
"//tensorflow/core:lib",
"//tensorflow/core:test",
"@com_google_absl//absl/container:inlined_vector",
+ "@com_google_absl//absl/strings",
],
)
@@ -1157,6 +1169,7 @@ xla_test_library(
"//tensorflow/core:lib",
"//tensorflow/core:test",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
@@ -1231,12 +1244,12 @@ xla_test(
"enable_for_xla_interpreter",
],
deps = [
- ":client_library_test_base",
"//tensorflow/compiler/xla/service:hlo_parser",
"//tensorflow/compiler/xla/tests:hlo_test_base",
"//tensorflow/compiler/xla/tests:xla_internal_test_main",
"//tensorflow/core:lib",
"//tensorflow/core:test",
+ "@com_google_absl//absl/strings",
],
)
@@ -1247,12 +1260,12 @@ xla_test(
"enable_for_xla_interpreter",
],
deps = [
- ":client_library_test_base",
"//tensorflow/compiler/xla/service:hlo_verifier",
"//tensorflow/compiler/xla/tests:hlo_test_base",
"//tensorflow/compiler/xla/tests:xla_internal_test_main",
"//tensorflow/core:lib",
"//tensorflow/core:test",
+ "@com_google_absl//absl/strings",
],
)
@@ -1425,6 +1438,7 @@ xla_test(
"//tensorflow/core:lib",
"//tensorflow/core:test",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
@@ -1660,7 +1674,6 @@ xla_test(
"//tensorflow/compiler/xla:status_macros",
"//tensorflow/compiler/xla:statusor",
"//tensorflow/compiler/xla:test",
- "//tensorflow/compiler/xla:test_helpers",
"//tensorflow/compiler/xla:xla_data_proto",
"//tensorflow/compiler/xla/client:client_library",
"//tensorflow/compiler/xla/client:global_data",
@@ -1671,6 +1684,7 @@ xla_test(
"//tensorflow/compiler/xla/tests:xla_internal_test_main",
"//tensorflow/core:lib",
"//tensorflow/core:test",
+ "@com_google_absl//absl/strings",
],
)
@@ -1851,13 +1865,9 @@ xla_test(
"//tensorflow/compiler/xla:shape_util",
"//tensorflow/compiler/xla:util",
"//tensorflow/compiler/xla:xla_data_proto",
- "//tensorflow/compiler/xla/client:client_library",
"//tensorflow/compiler/xla/client:local_client",
- "//tensorflow/compiler/xla/client:xla_builder",
- "//tensorflow/compiler/xla/client:xla_computation",
"//tensorflow/compiler/xla/service:hlo",
"//tensorflow/compiler/xla/service:hlo_runner",
- "//tensorflow/compiler/xla/service:platform_util",
"//tensorflow/compiler/xla/tests:client_library_test_base",
"//tensorflow/compiler/xla/tests:hlo_test_base",
"//tensorflow/compiler/xla/tests:literal_test_util",
@@ -1866,6 +1876,7 @@ xla_test(
"//tensorflow/core:lib",
"//tensorflow/core:test",
"@com_google_absl//absl/memory",
+ "@com_google_absl//absl/strings",
],
)
diff --git a/tensorflow/compiler/xla/tests/client_library_test_base.cc b/tensorflow/compiler/xla/tests/client_library_test_base.cc
index 2cab3264a7..0ab85c7df0 100644
--- a/tensorflow/compiler/xla/tests/client_library_test_base.cc
+++ b/tensorflow/compiler/xla/tests/client_library_test_base.cc
@@ -18,6 +18,7 @@ limitations under the License.
#include <string>
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/client/client_library.h"
#include "tensorflow/compiler/xla/client/local_client.h"
#include "tensorflow/compiler/xla/client/xla_builder.h"
@@ -196,8 +197,8 @@ Status ClientLibraryTestBase::ComputeAndCompareLiteralWithAllOutputLayouts(
AsInt64Slice(expected.shape().dimensions()), minor_to_major);
TF_ASSIGN_OR_RETURN(auto actual,
ExecuteAndTransfer(computation, arguments, &layout));
- verify_output(*actual, tensorflow::strings::StrCat(
- "Test with output layout: ",
+ verify_output(*actual,
+ absl::StrCat("Test with output layout: ",
ShapeUtil::HumanStringWithLayout(layout)));
} while (std::next_permutation(minor_to_major.begin(), minor_to_major.end()));
return Status::OK();
@@ -258,7 +259,7 @@ Status ClientLibraryTestBase::ComputeAndCompareLiteralWithAllInputLayouts(
output_with_layout));
string error_message = "Test with input layouts: ";
for (const auto& str : layout_strings) {
- tensorflow::strings::StrAppend(&error_message, str, " ");
+ absl::StrAppend(&error_message, str, " ");
}
verify_output(*actual, error_message);
return Status::OK();
@@ -391,7 +392,7 @@ Status ClientLibraryTestBase::ComputeAndCompareLiteralWithStatus(
}
void ClientLibraryTestBase::ComputeAndCompareR1U8(
- XlaBuilder* builder, tensorflow::StringPiece expected,
+ XlaBuilder* builder, absl::string_view expected,
tensorflow::gtl::ArraySlice<GlobalData*> arguments) {
auto actual_status = ExecuteAndTransfer(builder, arguments);
EXPECT_IS_OK(actual_status.status());
diff --git a/tensorflow/compiler/xla/tests/client_library_test_base.h b/tensorflow/compiler/xla/tests/client_library_test_base.h
index 24d0325929..ac96d3e325 100644
--- a/tensorflow/compiler/xla/tests/client_library_test_base.h
+++ b/tensorflow/compiler/xla/tests/client_library_test_base.h
@@ -22,6 +22,7 @@ limitations under the License.
#include <vector>
#include "absl/memory/memory.h"
+#include "absl/strings/string_view.h"
#include "tensorflow/compiler/xla/array2d.h"
#include "tensorflow/compiler/xla/array3d.h"
#include "tensorflow/compiler/xla/array4d.h"
@@ -36,7 +37,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/tests/test_utils.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
#include "tensorflow/core/lib/core/bitmap.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/gtl/array_slice.h"
#include "tensorflow/core/platform/stream_executor_no_cuda.h"
#include "tensorflow/core/platform/test.h"
@@ -202,7 +202,7 @@ class ClientLibraryTestBase : public ::testing::Test {
// Compare the result of the computation to a strings. In XLA strings are
// represented using rank-1 U8 shapes.
void ComputeAndCompareR1U8(
- XlaBuilder* builder, tensorflow::StringPiece expected,
+ XlaBuilder* builder, absl::string_view expected,
tensorflow::gtl::ArraySlice<GlobalData*> arguments);
// Convenience method for running a built computation, transferring the
diff --git a/tensorflow/compiler/xla/tests/compute_constant_test.cc b/tensorflow/compiler/xla/tests/compute_constant_test.cc
index 5a06d061f0..3db96d90c0 100644
--- a/tensorflow/compiler/xla/tests/compute_constant_test.cc
+++ b/tensorflow/compiler/xla/tests/compute_constant_test.cc
@@ -17,6 +17,7 @@ limitations under the License.
#include <utility>
#include <vector>
+#include "absl/strings/match.h"
#include "tensorflow/compiler/xla/client/client_library.h"
#include "tensorflow/compiler/xla/client/global_data.h"
#include "tensorflow/compiler/xla/client/xla_builder.h"
@@ -145,8 +146,8 @@ TEST_F(ComputeConstantTest, DirectParamMissing) {
EXPECT_FALSE(IsConstant(computation, &b));
auto value = ComputeConstantScalar<float>(client, computation, &b);
- EXPECT_TRUE(tensorflow::str_util::StrContains(value.status().ToString(),
- "depends on a parameter"))
+ EXPECT_TRUE(
+ absl::StrContains(value.status().ToString(), "depends on a parameter"))
<< value.status();
}
}
@@ -161,8 +162,8 @@ TEST_F(ComputeConstantTest, IndirectParamMissing) {
EXPECT_FALSE(IsConstant(computation, &b));
auto value = ComputeConstantScalar<float>(client, computation, &b);
- EXPECT_TRUE(tensorflow::str_util::StrContains(value.status().ToString(),
- "depends on a parameter"))
+ EXPECT_TRUE(
+ absl::StrContains(value.status().ToString(), "depends on a parameter"))
<< value.status();
}
}
diff --git a/tensorflow/compiler/xla/tests/convolution_test.cc b/tensorflow/compiler/xla/tests/convolution_test.cc
index 40658c3b77..026f96cdc4 100644
--- a/tensorflow/compiler/xla/tests/convolution_test.cc
+++ b/tensorflow/compiler/xla/tests/convolution_test.cc
@@ -19,6 +19,7 @@ limitations under the License.
#include <memory>
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/array2d.h"
#include "tensorflow/compiler/xla/array4d.h"
#include "tensorflow/compiler/xla/client/global_data.h"
@@ -36,7 +37,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/tests/test_macros.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/test.h"
#include "tensorflow/core/platform/types.h"
diff --git a/tensorflow/compiler/xla/tests/dot_operation_test.cc b/tensorflow/compiler/xla/tests/dot_operation_test.cc
index 0e9e92ed99..5873516442 100644
--- a/tensorflow/compiler/xla/tests/dot_operation_test.cc
+++ b/tensorflow/compiler/xla/tests/dot_operation_test.cc
@@ -16,6 +16,7 @@ limitations under the License.
#include <memory>
#include <vector>
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/array2d.h"
#include "tensorflow/compiler/xla/array3d.h"
#include "tensorflow/compiler/xla/client/local_client.h"
@@ -261,16 +262,14 @@ string PrintDotTestParam(
const ::testing::TestParamInfo<DotTestParam>& test_param) {
const DotTestParam& param = test_param.param;
if (param.has_addend) {
- return tensorflow::strings::StrCat(param.m, "x", param.k, "x", param.n,
- "_MajorToMinor",
- param.dot_lhs_row_major ? "T" : "F",
- param.dot_rhs_row_major ? "T" : "F",
- param.addend_row_major ? "T" : "F");
+ return absl::StrCat(param.m, "x", param.k, "x", param.n, "_MajorToMinor",
+ param.dot_lhs_row_major ? "T" : "F",
+ param.dot_rhs_row_major ? "T" : "F",
+ param.addend_row_major ? "T" : "F");
} else {
- return tensorflow::strings::StrCat(param.m, "x", param.k, "x", param.n,
- "_MajorToMinor",
- param.dot_lhs_row_major ? "T" : "F",
- param.dot_rhs_row_major ? "T" : "F");
+ return absl::StrCat(param.m, "x", param.k, "x", param.n, "_MajorToMinor",
+ param.dot_lhs_row_major ? "T" : "F",
+ param.dot_rhs_row_major ? "T" : "F");
}
}
diff --git a/tensorflow/compiler/xla/tests/hlo_test_base.cc b/tensorflow/compiler/xla/tests/hlo_test_base.cc
index 5635c3fe86..693454bd80 100644
--- a/tensorflow/compiler/xla/tests/hlo_test_base.cc
+++ b/tensorflow/compiler/xla/tests/hlo_test_base.cc
@@ -43,7 +43,7 @@ namespace xla {
namespace {
using absl::optional;
-using tensorflow::StringPiece;
+using absl::string_view;
using tensorflow::gtl::ArraySlice;
constexpr char kInterpreter[] = "interpreter";
@@ -239,7 +239,7 @@ StatusOr<::testing::AssertionResult> HloTestBase::RunAndCompareInternal(
}
::testing::AssertionResult HloTestBase::RunAndCompare(
- const StringPiece hlo_string, const absl::optional<ErrorSpec>& error,
+ string_view hlo_string, const absl::optional<ErrorSpec>& error,
const std::function<void(HloModule*)>& reference_preprocessor) {
auto module_or_status =
HloRunner::CreateModuleFromString(hlo_string, GetDebugOptionsForTest());
@@ -252,7 +252,7 @@ StatusOr<::testing::AssertionResult> HloTestBase::RunAndCompareInternal(
reference_preprocessor);
}
-::testing::AssertionResult HloTestBase::Run(const StringPiece hlo_string) {
+::testing::AssertionResult HloTestBase::Run(string_view hlo_string) {
auto module_or_status =
HloRunner::CreateModuleFromString(hlo_string, GetDebugOptionsForTest());
if (!module_or_status.ok()) {
@@ -289,7 +289,7 @@ StatusOr<::testing::AssertionResult> HloTestBase::RunAndCompareInternal(
}
::testing::AssertionResult HloTestBase::RunAndCompareNoHloPasses(
- const StringPiece hlo_string, const absl::optional<ErrorSpec>& error,
+ string_view hlo_string, const absl::optional<ErrorSpec>& error,
const std::function<void(HloModule*)>& reference_preprocessor) {
auto module_or_status =
HloRunner::CreateModuleFromString(hlo_string, GetDebugOptionsForTest());
@@ -316,7 +316,7 @@ StatusOr<::testing::AssertionResult> HloTestBase::RunAndCompareInternal(
}
HloComputation* HloTestBase::FindComputation(HloModule* module,
- tensorflow::StringPiece name) {
+ absl::string_view name) {
auto computations = module->computations();
auto it = absl::c_find_if(
computations, [&](HloComputation* c) { return c->name() == name; });
@@ -327,7 +327,7 @@ HloComputation* HloTestBase::FindComputation(HloModule* module,
}
HloInstruction* HloTestBase::FindInstruction(HloModule* module,
- tensorflow::StringPiece name) {
+ absl::string_view name) {
for (const HloComputation* c : module->computations()) {
auto instructions = c->instructions();
auto it = absl::c_find_if(
diff --git a/tensorflow/compiler/xla/tests/hlo_test_base.h b/tensorflow/compiler/xla/tests/hlo_test_base.h
index d88abf561a..ce39dd78d4 100644
--- a/tensorflow/compiler/xla/tests/hlo_test_base.h
+++ b/tensorflow/compiler/xla/tests/hlo_test_base.h
@@ -169,18 +169,18 @@ class HloTestBase : public ::testing::Test {
// input. Module can be passed in directly, or parsed from an hlo_string,
// or loaded from a file.
::testing::AssertionResult RunAndCompare(
- const tensorflow::StringPiece hlo_string,
+ const absl::string_view hlo_string,
const absl::optional<ErrorSpec>& error,
const std::function<void(HloModule*)>& reference_preprocessor = nullptr)
TF_MUST_USE_RESULT;
- ::testing::AssertionResult Run(const tensorflow::StringPiece hlo_string)
+ ::testing::AssertionResult Run(const absl::string_view hlo_string)
TF_MUST_USE_RESULT;
::testing::AssertionResult RunAndCompareFromFile(
const string& filename, const absl::optional<ErrorSpec>& error,
const std::function<void(HloModule*)>& reference_preprocessor = nullptr)
TF_MUST_USE_RESULT;
::testing::AssertionResult RunAndCompareNoHloPasses(
- const tensorflow::StringPiece hlo_string,
+ const absl::string_view hlo_string,
const absl::optional<ErrorSpec>& error,
const std::function<void(HloModule*)>& reference_preprocessor = nullptr)
TF_MUST_USE_RESULT;
@@ -228,10 +228,8 @@ class HloTestBase : public ::testing::Test {
//
// This is useful for tests which create HLOs from a string and then want to
// inspect a particular computation or instruction.
- HloComputation* FindComputation(HloModule* module,
- tensorflow::StringPiece name);
- HloInstruction* FindInstruction(HloModule* module,
- tensorflow::StringPiece name);
+ HloComputation* FindComputation(HloModule* module, absl::string_view name);
+ HloInstruction* FindInstruction(HloModule* module, absl::string_view name);
// Return an HLO verifier constructed for the test backend.
HloVerifier& verifier() const { return *hlo_verifier_; }
diff --git a/tensorflow/compiler/xla/tests/hlo_verified_test_base.cc b/tensorflow/compiler/xla/tests/hlo_verified_test_base.cc
index a509ee3207..dd130557b3 100644
--- a/tensorflow/compiler/xla/tests/hlo_verified_test_base.cc
+++ b/tensorflow/compiler/xla/tests/hlo_verified_test_base.cc
@@ -73,7 +73,7 @@ HloModule* HloVerifiedTestBase::CreateNewModule(const string& name) {
return modules_.back().get();
}
-void HloVerifiedTestBase::ParseAndVerifyModule(tensorflow::StringPiece hlo_text,
+void HloVerifiedTestBase::ParseAndVerifyModule(absl::string_view hlo_text,
const HloModuleConfig& config) {
CHECK(!module_) << "Called ParseModule when test already has a module.";
TF_ASSERT_OK_AND_ASSIGN(module_, ParseHloString(hlo_text, config));
diff --git a/tensorflow/compiler/xla/tests/hlo_verified_test_base.h b/tensorflow/compiler/xla/tests/hlo_verified_test_base.h
index 5b28c01c36..a2f1185d63 100644
--- a/tensorflow/compiler/xla/tests/hlo_verified_test_base.h
+++ b/tensorflow/compiler/xla/tests/hlo_verified_test_base.h
@@ -44,7 +44,7 @@ class HloVerifiedTestBase : public HloTestBase {
// Returns the default HloModule, lazily creating it if necessary via
// HloTestBase::CreateNewModule().
HloModule& module();
- void ParseAndVerifyModule(tensorflow::StringPiece hlo_text,
+ void ParseAndVerifyModule(absl::string_view hlo_text,
const HloModuleConfig& config = HloModuleConfig());
// Sets the shape-size function used during hlo verification. If this isn't
diff --git a/tensorflow/compiler/xla/tests/matrix_ops_simple_test.cc b/tensorflow/compiler/xla/tests/matrix_ops_simple_test.cc
index b6035a21a6..7956a034f8 100644
--- a/tensorflow/compiler/xla/tests/matrix_ops_simple_test.cc
+++ b/tensorflow/compiler/xla/tests/matrix_ops_simple_test.cc
@@ -18,6 +18,7 @@ limitations under the License.
#include <string>
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/array2d.h"
#include "tensorflow/compiler/xla/client/local_client.h"
#include "tensorflow/compiler/xla/client/xla_builder.h"
@@ -158,7 +159,7 @@ class TestLinspaceMaxParametric
string PrintTestLinspaceMaxParam(
const ::testing::TestParamInfo<TestLinspaceMaxParam>& test_param) {
const TestLinspaceMaxParam& param = test_param.param;
- return tensorflow::strings::StrCat(param.rows, "r", param.cols, "c");
+ return absl::StrCat(param.rows, "r", param.cols, "c");
}
#ifndef XLA_BACKEND_DOES_NOT_SUPPORT_FLOAT16
diff --git a/tensorflow/compiler/xla/tests/multioutput_fusion_test.cc b/tensorflow/compiler/xla/tests/multioutput_fusion_test.cc
index cadf1c5523..adc0956164 100644
--- a/tensorflow/compiler/xla/tests/multioutput_fusion_test.cc
+++ b/tensorflow/compiler/xla/tests/multioutput_fusion_test.cc
@@ -20,6 +20,7 @@ limitations under the License.
#include <utility>
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/client/local_client.h"
#include "tensorflow/compiler/xla/literal.h"
#include "tensorflow/compiler/xla/primitive_util.h"
@@ -291,7 +292,7 @@ const char* const kScalarOps = R"(
XLA_TEST_F(MultiOutputFusionTest,
DISABLED_ON_CPU(MultiOutputReduceFusionMinor)) {
- const string testcase = tensorflow::strings::StrCat(kScalarOps, R"(
+ const string testcase = absl::StrCat(kScalarOps, R"(
fused_reduce {
p0 = f32[2,2,2]{2,1,0} parameter(0)
c0 = f32[] constant(0)
@@ -323,7 +324,7 @@ XLA_TEST_F(MultiOutputFusionTest,
XLA_TEST_F(MultiOutputFusionTest,
DISABLED_ON_CPU(MultiOutputReduceFusionMajor)) {
- const string testcase = tensorflow::strings::StrCat(kScalarOps, R"(
+ const string testcase = absl::StrCat(kScalarOps, R"(
fused_reduce {
p0 = f32[2,2,2]{2,1,0} parameter(0)
c0 = f32[] constant(0)
@@ -355,7 +356,7 @@ XLA_TEST_F(MultiOutputFusionTest,
XLA_TEST_F(MultiOutputFusionTest,
DISABLED_ON_CPU(MultiOutputReduceFusionScalar)) {
- const string testcase = tensorflow::strings::StrCat(kScalarOps, R"(
+ const string testcase = absl::StrCat(kScalarOps, R"(
fused_reduce {
p0 = f32[2,2,2]{2,1,0} parameter(0)
c0 = f32[] constant(0)
@@ -388,7 +389,7 @@ XLA_TEST_F(MultiOutputFusionTest,
XLA_TEST_F(MultiOutputFusionTest,
DISABLED_ON_CPU(MultiOutputReduceFusionMinorWithExtraOutput)) {
- const string testcase = tensorflow::strings::StrCat(kScalarOps, R"(
+ const string testcase = absl::StrCat(kScalarOps, R"(
fused_reduce {
p0 = f32[2,2,2]{2,1,0} parameter(0)
c0 = f32[] constant(0)
@@ -422,7 +423,7 @@ XLA_TEST_F(MultiOutputFusionTest,
XLA_TEST_F(MultiOutputFusionTest,
DISABLED_ON_CPU(MultiOutputReduceFusionMajorWithExtraOutput)) {
- const string testcase = tensorflow::strings::StrCat(kScalarOps, R"(
+ const string testcase = absl::StrCat(kScalarOps, R"(
fused_reduce {
p0 = f32[2,2,2]{2,1,0} parameter(0)
c0 = f32[] constant(0)
@@ -457,7 +458,7 @@ XLA_TEST_F(MultiOutputFusionTest,
XLA_TEST_F(MultiOutputFusionTest,
DISABLED_ON_CPU(MultiOutputReduceFusionScalarWithExtraOutput)) {
- const string testcase = tensorflow::strings::StrCat(kScalarOps, R"(
+ const string testcase = absl::StrCat(kScalarOps, R"(
fused_reduce {
p0 = f32[2,2,2]{2,1,0} parameter(0)
c0 = f32[] constant(0)
@@ -494,7 +495,7 @@ XLA_TEST_F(MultiOutputFusionTest,
XLA_TEST_F(MultiOutputFusionTest,
DISABLED_ON_CPU(MultiOutputReduceFusionNonConstInit)) {
- const string testcase = tensorflow::strings::StrCat(kScalarOps, R"(
+ const string testcase = absl::StrCat(kScalarOps, R"(
fused_reduce {
p0 = f32[2,2,2]{2,1,0} parameter(0)
init1 = f32[] parameter(1)
@@ -529,7 +530,7 @@ XLA_TEST_F(MultiOutputFusionTest,
XLA_TEST_F(MultiOutputFusionTest,
DISABLED_ON_CPU(MultiOutputReduceFusionDifferentElementTypes)) {
- const string testcase = tensorflow::strings::StrCat(kScalarOps, R"(
+ const string testcase = absl::StrCat(kScalarOps, R"(
fused_reduce (p0: f16[2,2,2]) -> (f32[2,2], f32[2,2], f16[2,2,2]) {
p0 = f16[2,2,2]{2,1,0} parameter(0)
convert = f32[2,2,2]{2,1,0} convert(p0)
diff --git a/tensorflow/compiler/xla/tests/reduce_hlo_test.cc b/tensorflow/compiler/xla/tests/reduce_hlo_test.cc
index a080dd1732..4380b48df2 100644
--- a/tensorflow/compiler/xla/tests/reduce_hlo_test.cc
+++ b/tensorflow/compiler/xla/tests/reduce_hlo_test.cc
@@ -15,11 +15,11 @@ limitations under the License.
#include <array>
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/service/hlo_parser.h"
#include "tensorflow/compiler/xla/tests/hlo_test_base.h"
#include "tensorflow/compiler/xla/tests/test_macros.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/test.h"
#include "tensorflow/core/platform/types.h"
diff --git a/tensorflow/compiler/xla/tests/reduce_precision_test.cc b/tensorflow/compiler/xla/tests/reduce_precision_test.cc
index 531648fe3e..0916a07f4f 100644
--- a/tensorflow/compiler/xla/tests/reduce_precision_test.cc
+++ b/tensorflow/compiler/xla/tests/reduce_precision_test.cc
@@ -19,6 +19,7 @@ limitations under the License.
#include <numeric>
#include <vector>
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/array2d.h"
#include "tensorflow/compiler/xla/client/global_data.h"
#include "tensorflow/compiler/xla/client/local_client.h"
@@ -57,8 +58,8 @@ static const int mantissa_sizes[] = {23, 10, 23, 10};
string TestDataToString(const ::testing::TestParamInfo<int> data) {
int i = data.param;
- return tensorflow::strings::StrCat(exponent_sizes[i], "_exponent_bits_",
- mantissa_sizes[i], "_mantissa_bits");
+ return absl::StrCat(exponent_sizes[i], "_exponent_bits_", mantissa_sizes[i],
+ "_mantissa_bits");
}
// The FPVAL macro allows us to write out the binary representation of the
diff --git a/tensorflow/compiler/xla/tests/reduce_window_test.cc b/tensorflow/compiler/xla/tests/reduce_window_test.cc
index ebf7fa30be..7c8b029675 100644
--- a/tensorflow/compiler/xla/tests/reduce_window_test.cc
+++ b/tensorflow/compiler/xla/tests/reduce_window_test.cc
@@ -19,6 +19,7 @@ limitations under the License.
#include <memory>
#include "absl/memory/memory.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/array2d.h"
#include "tensorflow/compiler/xla/array3d.h"
#include "tensorflow/compiler/xla/array4d.h"
@@ -579,7 +580,7 @@ string R4ReduceWindowTestDataToString(
const ::testing::TestParamInfo<
::testing::tuple<R4ReduceWindowTestData, bool>>& data) {
const auto& param = ::testing::get<0>(data.param);
- string str = tensorflow::strings::StrCat(
+ string str = absl::StrCat(
"base_bounds_", tensorflow::str_util::Join(param.base_bounds, "x"), //
"__window_bounds_",
tensorflow::str_util::Join(param.window_bounds, "x"), //
@@ -593,7 +594,7 @@ string R4ReduceWindowTestDataToString(
// Test names are not allowed to contain the '-' character.
std::replace(str.begin(), str.end(), '-', 'n');
if (::testing::get<1>(data.param)) {
- str = tensorflow::strings::StrCat(str, "_bfloat16");
+ str = absl::StrCat(str, "_bfloat16");
}
return str;
}
@@ -935,7 +936,7 @@ string R3ReduceWindowTestDataToString(
const ::testing::TestParamInfo<
::testing::tuple<R3ReduceWindowTestData, bool>>& data) {
const auto& param = ::testing::get<0>(data.param);
- string str = tensorflow::strings::StrCat(
+ string str = absl::StrCat(
"base_bounds_", tensorflow::str_util::Join(param.base_bounds, "x"),
"__window_bounds_", tensorflow::str_util::Join(param.window_bounds, "x"),
"__strides_", tensorflow::str_util::Join(param.strides, "x"),
@@ -943,7 +944,7 @@ string R3ReduceWindowTestDataToString(
"__layout_", param.layout[0], "_", param.layout[1], "_", param.layout[2],
"__reducer_", param.reducer == kAdd ? "add" : "max");
if (::testing::get<1>(data.param)) {
- str = tensorflow::strings::StrCat(str, "_bfloat16");
+ str = absl::StrCat(str, "_bfloat16");
}
return str;
}
@@ -1069,7 +1070,7 @@ string R2ReduceWindowTestDataToString(
const ::testing::TestParamInfo<
::testing::tuple<R2ReduceWindowTestData, bool>>& data) {
const auto& param = ::testing::get<0>(data.param);
- string str = tensorflow::strings::StrCat(
+ string str = absl::StrCat(
"base_bounds_", tensorflow::str_util::Join(param.base_bounds, "x"), //
"__window_bounds_",
tensorflow::str_util::Join(param.window_bounds, "x"), //
@@ -1079,7 +1080,7 @@ string R2ReduceWindowTestDataToString(
"__layout_", param.layout[0], "_", param.layout[1], //
"__reducer_", param.reducer == kAdd ? "add" : "max");
if (::testing::get<1>(data.param)) {
- str = tensorflow::strings::StrCat(str, "_bfloat16");
+ str = absl::StrCat(str, "_bfloat16");
}
return str;
}
@@ -1274,7 +1275,7 @@ string R1ReduceWindowTestDataToString(
const ::testing::TestParamInfo<
::testing::tuple<R1ReduceWindowTestData, bool>>& data) {
const auto& param = ::testing::get<0>(data.param);
- string str = tensorflow::strings::StrCat(
+ string str = absl::StrCat(
"base_bounds_", tensorflow::str_util::Join(param.base_bounds, "x"),
"__window_bounds_", tensorflow::str_util::Join(param.window_bounds, "x"),
"__strides_", tensorflow::str_util::Join(param.strides, "x"),
@@ -1282,7 +1283,7 @@ string R1ReduceWindowTestDataToString(
"__pad_high_", tensorflow::str_util::Join(param.pad_high, "x"),
"__reducer_", param.reducer == kAdd ? "add" : "max");
if (::testing::get<1>(data.param)) {
- str = tensorflow::strings::StrCat(str, "_bfloat16");
+ str = absl::StrCat(str, "_bfloat16");
}
return str;
}
diff --git a/tensorflow/compiler/xla/tests/scalar_computations_test.cc b/tensorflow/compiler/xla/tests/scalar_computations_test.cc
index e42c71eb28..cf2d453f43 100644
--- a/tensorflow/compiler/xla/tests/scalar_computations_test.cc
+++ b/tensorflow/compiler/xla/tests/scalar_computations_test.cc
@@ -17,6 +17,7 @@ limitations under the License.
#include <limits>
#include <memory>
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/client/global_data.h"
#include "tensorflow/compiler/xla/client/local_client.h"
#include "tensorflow/compiler/xla/client/xla_builder.h"
@@ -31,7 +32,6 @@ limitations under the License.
#include "tensorflow/compiler/xla/tests/test_macros.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
#include "tensorflow/core/lib/gtl/array_slice.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/test.h"
#include "tensorflow/core/platform/types.h"
diff --git a/tensorflow/compiler/xla/tests/slice_test.cc b/tensorflow/compiler/xla/tests/slice_test.cc
index d865c414fd..b792b42103 100644
--- a/tensorflow/compiler/xla/tests/slice_test.cc
+++ b/tensorflow/compiler/xla/tests/slice_test.cc
@@ -19,6 +19,7 @@ limitations under the License.
#include <vector>
#include "absl/container/inlined_vector.h"
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/array2d.h"
#include "tensorflow/compiler/xla/client/local_client.h"
#include "tensorflow/compiler/xla/client/xla_builder.h"
@@ -449,7 +450,7 @@ struct R4Spec {
string R4SpecToString(const ::testing::TestParamInfo<R4Spec>& data) {
const R4Spec& spec = data.param;
- return tensorflow::strings::StrCat( //
+ return absl::StrCat( //
"input_", Join(spec.input_dims, "x"), //
"__layout_", Join(spec.input_layout, ""), //
"__starts_", Join(spec.slice_starts, "x"), //
diff --git a/tensorflow/compiler/xla/tests/test_macros.cc b/tensorflow/compiler/xla/tests/test_macros.cc
index be35ec6c6e..cd5f16a5d6 100644
--- a/tensorflow/compiler/xla/tests/test_macros.cc
+++ b/tensorflow/compiler/xla/tests/test_macros.cc
@@ -20,6 +20,8 @@ limitations under the License.
#include <string>
#include <unordered_map>
+#include "absl/strings/str_cat.h"
+#include "absl/strings/str_split.h"
#include "tensorflow/core/lib/strings/str_util.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/regexp.h"
@@ -44,7 +46,7 @@ ManifestT ReadManifest() {
string contents((std::istreambuf_iterator<char>(file_stream)),
std::istreambuf_iterator<char>());
- std::vector<string> lines = tensorflow::str_util::Split(contents, '\n');
+ std::vector<string> lines = absl::StrSplit(contents, '\n');
for (string& line : lines) {
auto comment = line.find("//");
if (comment != string::npos) {
@@ -54,7 +56,7 @@ ManifestT ReadManifest() {
continue;
}
tensorflow::str_util::StripTrailingWhitespace(&line);
- std::vector<string> pieces = tensorflow::str_util::Split(line, ' ');
+ std::vector<string> pieces = absl::StrSplit(line, ' ');
CHECK_GE(pieces.size(), 1);
auto& platforms = manifest[pieces[0]];
for (int64 i = 1; i < pieces.size(); ++i) {
@@ -73,8 +75,7 @@ string PrependDisabledIfIndicated(const string& test_case_name,
// First try full match: test_case_name.test_name
// If that fails, try to find just the test_case_name; this would disable all
// tests in the test case.
- auto it = manifest.find(
- tensorflow::strings::StrCat(test_case_name, ".", test_name));
+ auto it = manifest.find(absl::StrCat(test_case_name, ".", test_name));
if (it == manifest.end()) {
it = manifest.find(test_case_name);
if (it == manifest.end()) {
diff --git a/tensorflow/compiler/xla/tests/token_hlo_test.cc b/tensorflow/compiler/xla/tests/token_hlo_test.cc
index 2bdbd08309..b3157fbb00 100644
--- a/tensorflow/compiler/xla/tests/token_hlo_test.cc
+++ b/tensorflow/compiler/xla/tests/token_hlo_test.cc
@@ -15,11 +15,11 @@ limitations under the License.
#include <array>
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/service/hlo_verifier.h"
#include "tensorflow/compiler/xla/tests/hlo_test_base.h"
#include "tensorflow/compiler/xla/tests/test_macros.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/test.h"
#include "tensorflow/core/platform/types.h"
diff --git a/tensorflow/compiler/xla/tests/xla_hlo_profile_test.cc b/tensorflow/compiler/xla/tests/xla_hlo_profile_test.cc
index e12e095ecd..dfd0f56bdc 100644
--- a/tensorflow/compiler/xla/tests/xla_hlo_profile_test.cc
+++ b/tensorflow/compiler/xla/tests/xla_hlo_profile_test.cc
@@ -17,6 +17,9 @@ limitations under the License.
#include <vector>
#include "absl/algorithm/container.h"
+#include "absl/strings/match.h"
+#include "absl/strings/str_cat.h"
+#include "absl/strings/str_split.h"
#include "tensorflow/compiler/xla/array2d.h"
#include "tensorflow/compiler/xla/client/local_client.h"
#include "tensorflow/compiler/xla/client/xla_builder.h"
@@ -82,8 +85,7 @@ struct ParsedProfileOutputLine {
Status ParseOneProfileOutputLine(
const string& line, bool expect_hlo,
gtl::FlatMap<string, ParsedProfileOutputLine>* parsed_results,
- tensorflow::gtl::ArraySlice<tensorflow::StringPiece> opcodes_to_ignore =
- {}) {
+ tensorflow::gtl::ArraySlice<absl::string_view> opcodes_to_ignore = {}) {
string separator = "[^:]*:: +";
string match_percentage = R"(\d+\.\d*% +\d+Σ)";
string match_cycles = R"((\d+) cycles +\( *()" + match_percentage + R"()\))";
@@ -100,7 +102,7 @@ Status ParseOneProfileOutputLine(
string match_opcode =
expect_hlo ? "%[^=]+= [^ ]+ ([^(]+)\\(.*" : "(\\[total\\])";
- string regexp_pattern = tensorflow::strings::StrCat(
+ string regexp_pattern = absl::StrCat(
" +", match_cycles, separator, match_usecs, separator, match_flops,
separator, match_trops, separator, match_bytes_per_sec, separator,
match_bytes_per_cycle, separator, match_opcode);
@@ -205,7 +207,7 @@ XLA_TEST_F(HloProfileTest, ProfileSingleComputation) {
rhs_shape);
std::vector<string> profile_output_lines =
- tensorflow::str_util::Split(profile_output, '\n');
+ absl::StrSplit(profile_output, '\n');
gtl::FlatMap<string, ParsedProfileOutputLine> parsed_profile_lines;
@@ -292,22 +294,20 @@ XLA_TEST_F(HloProfileTest, ProfileWhileComputation) {
matrix_shape);
std::vector<string> profile_output_lines =
- tensorflow::str_util::Split(profile_output, '\n');
+ absl::StrSplit(profile_output, '\n');
auto while_body_profile_start =
- absl::c_find_if(profile_output_lines, [](tensorflow::StringPiece s) {
- return tensorflow::str_util::StartsWith(s,
- "Execution profile for body");
+ absl::c_find_if(profile_output_lines, [](absl::string_view s) {
+ return absl::StartsWith(s, "Execution profile for body");
});
ASSERT_NE(while_body_profile_start, profile_output_lines.cend());
- auto while_body_profile_end =
- std::find_if(while_body_profile_start, profile_output_lines.end(),
- [](tensorflow::StringPiece s) {
- return tensorflow::str_util::StartsWith(
- s, "********** microseconds report **********");
- });
+ auto while_body_profile_end = std::find_if(
+ while_body_profile_start, profile_output_lines.end(),
+ [](absl::string_view s) {
+ return absl::StartsWith(s, "********** microseconds report **********");
+ });
// We emit a blank line before the "********** microseconds report **********"
// line.
diff --git a/tensorflow/compiler/xla/tests/xla_internal_test_main.cc b/tensorflow/compiler/xla/tests/xla_internal_test_main.cc
index a075195618..b497a42349 100644
--- a/tensorflow/compiler/xla/tests/xla_internal_test_main.cc
+++ b/tensorflow/compiler/xla/tests/xla_internal_test_main.cc
@@ -13,8 +13,9 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
+#include "absl/strings/match.h"
+#include "absl/strings/string_view.h"
#include "tensorflow/compiler/xla/legacy_flags/debug_options_flags.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/strings/str_util.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/test.h"
@@ -32,16 +33,14 @@ GTEST_API_ int main(int argc, char** argv) {
// If the --benchmarks flag is passed in then only run the benchmarks, not the
// tests.
for (int i = 1; i < argc; i++) {
- tensorflow::StringPiece arg(argv[i]);
- if (arg == "--benchmarks" ||
- tensorflow::str_util::StartsWith(arg, "--benchmarks=")) {
+ absl::string_view arg(argv[i]);
+ if (arg == "--benchmarks" || absl::StartsWith(arg, "--benchmarks=")) {
const char* pattern = nullptr;
- if (tensorflow::str_util::StartsWith(arg, "--benchmarks=")) {
+ if (absl::StartsWith(arg, "--benchmarks=")) {
pattern = argv[i] + strlen("--benchmarks=");
} else {
// Handle flag of the form '--benchmarks foo' (no '=').
- if (i + 1 >= argc ||
- tensorflow::str_util::StartsWith(argv[i + 1], "--")) {
+ if (i + 1 >= argc || absl::StartsWith(argv[i + 1], "--")) {
LOG(ERROR) << "--benchmarks flag requires an argument.";
return 2;
}
diff --git a/tensorflow/compiler/xla/text_literal_reader.cc b/tensorflow/compiler/xla/text_literal_reader.cc
index 7de2c39b38..af379767c9 100644
--- a/tensorflow/compiler/xla/text_literal_reader.cc
+++ b/tensorflow/compiler/xla/text_literal_reader.cc
@@ -21,13 +21,16 @@ limitations under the License.
#include <vector>
#include "absl/memory/memory.h"
+#include "absl/strings/match.h"
+#include "absl/strings/numbers.h"
+#include "absl/strings/string_view.h"
+#include "absl/strings/strip.h"
#include "tensorflow/compiler/xla/literal.h"
#include "tensorflow/compiler/xla/shape_util.h"
#include "tensorflow/compiler/xla/status_macros.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/compiler/xla/util.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/io/buffered_inputstream.h"
#include "tensorflow/core/lib/io/random_inputstream.h"
#include "tensorflow/core/lib/strings/str_util.h"
@@ -37,8 +40,8 @@ limitations under the License.
namespace xla {
StatusOr<std::unique_ptr<Literal>> TextLiteralReader::ReadPath(
- tensorflow::StringPiece path) {
- CHECK(!tensorflow::str_util::EndsWith(path, ".gz"))
+ absl::string_view path) {
+ CHECK(!absl::EndsWith(path, ".gz"))
<< "TextLiteralReader no longer supports reading .gz files";
std::unique_ptr<tensorflow::RandomAccessFile> file;
Status s =
@@ -58,8 +61,8 @@ namespace {
// This is an optimized version of tensorflow::str_util::Split which uses
// StringPiece for the delimited strings and uses an out parameter for the
// result to avoid vector creation/destruction.
-void SplitByDelimToStringPieces(tensorflow::StringPiece text, char delim,
- std::vector<tensorflow::StringPiece>* result) {
+void SplitByDelimToStringPieces(absl::string_view text, char delim,
+ std::vector<absl::string_view>* result) {
result->clear();
if (text.empty()) {
@@ -73,7 +76,7 @@ void SplitByDelimToStringPieces(tensorflow::StringPiece text, char delim,
size_t token_start = 0;
for (size_t i = 0; i < text.size() + 1; i++) {
if (i == text.size() || text[i] == delim) {
- tensorflow::StringPiece token(text.data() + token_start, i - token_start);
+ absl::string_view token(text.data() + token_start, i - token_start);
result->push_back(token);
token_start = i + 1;
}
@@ -90,11 +93,7 @@ StatusOr<std::unique_ptr<Literal>> TextLiteralReader::ReadAllLines() {
return s;
}
- tensorflow::StringPiece sp(shape_string);
- if (tensorflow::str_util::RemoveWhitespaceContext(&sp) > 0) {
- string tmp = std::string(sp);
- shape_string = tmp;
- }
+ absl::StripAsciiWhitespace(&shape_string);
TF_ASSIGN_OR_RETURN(Shape shape, ShapeUtil::ParseShapeString(shape_string));
if (shape.element_type() != F32) {
return Unimplemented(
@@ -105,35 +104,33 @@ StatusOr<std::unique_ptr<Literal>> TextLiteralReader::ReadAllLines() {
auto result = absl::make_unique<Literal>(shape);
const float fill = std::numeric_limits<float>::quiet_NaN();
result->PopulateWithValue<float>(fill);
- std::vector<tensorflow::StringPiece> pieces;
- std::vector<tensorflow::StringPiece> coordinates;
+ std::vector<absl::string_view> pieces;
+ std::vector<absl::string_view> coordinates;
std::vector<int64> coordinate_values;
string line;
while (buf.ReadLine(&line).ok()) {
SplitByDelimToStringPieces(line, ':', &pieces);
- tensorflow::StringPiece coordinates_string = pieces[0];
- tensorflow::StringPiece value_string = pieces[1];
- tensorflow::str_util::RemoveWhitespaceContext(&coordinates_string);
- tensorflow::str_util::RemoveWhitespaceContext(&value_string);
- if (!tensorflow::str_util::ConsumePrefix(&coordinates_string, "(")) {
+ absl::string_view coordinates_string =
+ absl::StripAsciiWhitespace(pieces[0]);
+ absl::string_view value_string = absl::StripAsciiWhitespace(pieces[1]);
+ if (!absl::ConsumePrefix(&coordinates_string, "(")) {
return InvalidArgument(
"expected '(' at the beginning of coordinates: \"%s\"", line.c_str());
}
- if (!tensorflow::str_util::ConsumeSuffix(&coordinates_string, ")")) {
+ if (!absl::ConsumeSuffix(&coordinates_string, ")")) {
return InvalidArgument("expected ')' at the end of coordinates: \"%s\"",
line.c_str());
}
float value;
- if (!tensorflow::strings::safe_strtof(std::string(value_string).c_str(),
- &value)) {
+ if (!absl::SimpleAtof(std::string(value_string).c_str(), &value)) {
return InvalidArgument("could not parse value as float: \"%s\"",
std::string(value_string).c_str());
}
SplitByDelimToStringPieces(coordinates_string, ',', &coordinates);
coordinate_values.clear();
- for (tensorflow::StringPiece piece : coordinates) {
+ for (absl::string_view piece : coordinates) {
int64 coordinate_value;
- if (!tensorflow::strings::safe_strto64(piece, &coordinate_value)) {
+ if (!absl::SimpleAtoi(piece, &coordinate_value)) {
return InvalidArgument(
"could not parse coordinate member as int64: \"%s\"",
std::string(piece).c_str());
diff --git a/tensorflow/compiler/xla/text_literal_reader.h b/tensorflow/compiler/xla/text_literal_reader.h
index 708e8c80d8..b265640802 100644
--- a/tensorflow/compiler/xla/text_literal_reader.h
+++ b/tensorflow/compiler/xla/text_literal_reader.h
@@ -18,11 +18,11 @@ limitations under the License.
#include <memory>
+#include "absl/strings/string_view.h"
#include "tensorflow/compiler/xla/literal.h"
#include "tensorflow/compiler/xla/statusor.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/platform/env.h"
#include "tensorflow/core/platform/macros.h"
@@ -41,8 +41,7 @@ class TextLiteralReader {
public:
// See class comment -- reads a file in its entirety (there must be only one
// literal in the text file path provided).
- static StatusOr<std::unique_ptr<Literal>> ReadPath(
- tensorflow::StringPiece path);
+ static StatusOr<std::unique_ptr<Literal>> ReadPath(absl::string_view path);
private:
// Ownership of file is transferred.
diff --git a/tensorflow/compiler/xla/text_literal_writer.cc b/tensorflow/compiler/xla/text_literal_writer.cc
index 24e0784741..7347d161f8 100644
--- a/tensorflow/compiler/xla/text_literal_writer.cc
+++ b/tensorflow/compiler/xla/text_literal_writer.cc
@@ -17,6 +17,7 @@ limitations under the License.
#include <string>
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/literal.h"
#include "tensorflow/compiler/xla/shape_util.h"
#include "tensorflow/compiler/xla/status_macros.h"
@@ -24,14 +25,13 @@ limitations under the License.
#include "tensorflow/compiler/xla/xla_data.pb.h"
#include "tensorflow/core/lib/gtl/array_slice.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/env.h"
#include "tensorflow/core/platform/types.h"
namespace xla {
-/* static */ Status TextLiteralWriter::WriteToPath(
- const Literal& literal, tensorflow::StringPiece path) {
+/* static */ Status TextLiteralWriter::WriteToPath(const Literal& literal,
+ absl::string_view path) {
std::unique_ptr<tensorflow::WritableFile> f;
auto s = tensorflow::Env::Default()->NewWritableFile(std::string(path), &f);
if (!s.ok()) {
@@ -51,11 +51,10 @@ namespace xla {
if (!status.ok()) {
return;
}
- string coordinates = tensorflow::strings::StrCat(
- "(", tensorflow::str_util::Join(indices, ", "), ")");
+ string coordinates =
+ absl::StrCat("(", tensorflow::str_util::Join(indices, ", "), ")");
- status = f_ptr->Append(
- tensorflow::strings::StrCat(coordinates, ": ", value, "\n"));
+ status = f_ptr->Append(absl::StrCat(coordinates, ": ", value, "\n"));
});
auto ignored = f->Close();
return status;
diff --git a/tensorflow/compiler/xla/text_literal_writer.h b/tensorflow/compiler/xla/text_literal_writer.h
index 159ac1b7e1..34de8572d6 100644
--- a/tensorflow/compiler/xla/text_literal_writer.h
+++ b/tensorflow/compiler/xla/text_literal_writer.h
@@ -16,11 +16,11 @@ limitations under the License.
#ifndef TENSORFLOW_COMPILER_XLA_TEXT_LITERAL_WRITER_H_
#define TENSORFLOW_COMPILER_XLA_TEXT_LITERAL_WRITER_H_
+#include "absl/strings/string_view.h"
#include "tensorflow/compiler/xla/literal.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
#include "tensorflow/core/lib/core/status.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/platform/macros.h"
namespace xla {
@@ -37,8 +37,7 @@ namespace xla {
// This should be readable by xla::TextLiteralReader.
class TextLiteralWriter {
public:
- static Status WriteToPath(const Literal& literal,
- tensorflow::StringPiece path);
+ static Status WriteToPath(const Literal& literal, absl::string_view path);
private:
TF_DISALLOW_COPY_AND_ASSIGN(TextLiteralWriter);
diff --git a/tensorflow/compiler/xla/tools/BUILD b/tensorflow/compiler/xla/tools/BUILD
index 40d28a57bf..e458ab9a1e 100644
--- a/tensorflow/compiler/xla/tools/BUILD
+++ b/tensorflow/compiler/xla/tools/BUILD
@@ -24,6 +24,7 @@ tf_cc_binary(
"//tensorflow/core:framework_internal",
"//tensorflow/core:lib",
"//tensorflow/core:lib_internal",
+ "@com_google_absl//absl/strings",
],
)
diff --git a/tensorflow/compiler/xla/tools/dumped_computation_to_operation_list.cc b/tensorflow/compiler/xla/tools/dumped_computation_to_operation_list.cc
index f0af0580c1..4cb90f660b 100644
--- a/tensorflow/compiler/xla/tools/dumped_computation_to_operation_list.cc
+++ b/tensorflow/compiler/xla/tools/dumped_computation_to_operation_list.cc
@@ -46,8 +46,7 @@ class OperationDumper : public DfsHloVisitorWithDefault {
Status DefaultAction(HloInstruction* hlo) override {
string params = tensorflow::str_util::Join(
hlo->operands(), ", ", [](string* out, const HloInstruction* operand) {
- tensorflow::strings::StrAppend(
- out, ShapeUtil::HumanString(operand->shape()));
+ absl::StrAppend(out, ShapeUtil::HumanString(operand->shape()));
});
// Spit `op_name(params...) -> result_type :: path` to stdout.
std::cout << tensorflow::strings::Printf(
diff --git a/tensorflow/compiler/xla/tools/hex_floats_to_packed_literal.cc b/tensorflow/compiler/xla/tools/hex_floats_to_packed_literal.cc
index eb7bff053b..e0549b1c47 100644
--- a/tensorflow/compiler/xla/tools/hex_floats_to_packed_literal.cc
+++ b/tensorflow/compiler/xla/tools/hex_floats_to_packed_literal.cc
@@ -17,10 +17,10 @@ limitations under the License.
#include <string>
#include <vector>
+#include "absl/strings/string_view.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/core/lib/core/casts.h"
#include "tensorflow/core/lib/core/status.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/io/buffered_inputstream.h"
#include "tensorflow/core/lib/io/random_inputstream.h"
#include "tensorflow/core/platform/env.h"
diff --git a/tensorflow/compiler/xla/util.cc b/tensorflow/compiler/xla/util.cc
index e43498e381..c505c3f757 100644
--- a/tensorflow/compiler/xla/util.cc
+++ b/tensorflow/compiler/xla/util.cc
@@ -18,11 +18,13 @@ limitations under the License.
#include <stdarg.h>
#include <numeric>
+#include "absl/strings/match.h"
+#include "absl/strings/str_cat.h"
+#include "absl/strings/str_split.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/strings/numbers.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/lib/strings/stringprintf.h"
#include "tensorflow/core/platform/env.h"
#include "tensorflow/core/platform/mutex.h"
@@ -54,16 +56,16 @@ ScopedLoggingTimer::~ScopedLoggingTimer() {
}
}
-Status AddStatus(Status prior, tensorflow::StringPiece context) {
+Status AddStatus(Status prior, absl::string_view context) {
CHECK(!prior.ok());
- return Status{prior.code(), tensorflow::strings::StrCat(
- context, ": ", prior.error_message())};
+ return Status{prior.code(),
+ absl::StrCat(context, ": ", prior.error_message())};
}
-Status AppendStatus(Status prior, tensorflow::StringPiece context) {
+Status AppendStatus(Status prior, absl::string_view context) {
CHECK(!prior.ok());
- return Status{prior.code(), tensorflow::strings::StrCat(prior.error_message(),
- ": ", context)};
+ return Status{prior.code(),
+ absl::StrCat(prior.error_message(), ": ", context)};
}
// Implementation note: we can't common these out (without using macros) because
@@ -146,15 +148,13 @@ Status Unavailable(const char* format, ...) {
return WithLogBacktrace(tensorflow::errors::Unavailable(message));
}
-string Reindent(tensorflow::StringPiece original,
- const tensorflow::StringPiece indentation) {
- std::vector<string> pieces = tensorflow::str_util::Split(
- tensorflow::StringPiece(original.data(), original.size()), '\n');
+string Reindent(absl::string_view original,
+ const absl::string_view indentation) {
+ std::vector<string> pieces =
+ absl::StrSplit(absl::string_view(original.data(), original.size()), '\n');
return tensorflow::str_util::Join(
pieces, "\n", [indentation](string* out, string s) {
- tensorflow::StringPiece piece(s);
- tensorflow::str_util::RemoveWhitespaceContext(&piece);
- tensorflow::strings::StrAppend(out, indentation, piece);
+ absl::StrAppend(out, indentation, absl::StripAsciiWhitespace(s));
});
}
@@ -234,20 +234,20 @@ bool HasInteriorPadding(const PaddingConfig& config) {
namespace {
string HumanReadableNumOps(double flops, double nanoseconds,
- tensorflow::StringPiece op_prefix) {
+ absl::string_view op_prefix) {
if (nanoseconds == 0) {
- return tensorflow::strings::StrCat("NaN ", op_prefix, "OP/s");
+ return absl::StrCat("NaN ", op_prefix, "OP/s");
}
double nano_flops = flops / nanoseconds;
string throughput = tensorflow::strings::HumanReadableNum(
static_cast<int64>(nano_flops * 1e9));
- tensorflow::StringPiece sp(throughput);
+ absl::string_view sp(throughput);
// Use the more common "G(FLOPS)", rather than "B(FLOPS)"
- if (tensorflow::str_util::EndsWith(sp, "B") || // Ends in 'B', ignoring case
- tensorflow::str_util::EndsWith(sp, "b")) {
+ if (absl::EndsWith(sp, "B") || // Ends in 'B', ignoring case
+ absl::EndsWith(sp, "b")) {
*throughput.rbegin() = 'G';
}
- throughput += tensorflow::strings::StrCat(op_prefix, "OP/s");
+ throughput += absl::StrCat(op_prefix, "OP/s");
return throughput;
}
} // namespace
@@ -260,8 +260,7 @@ string HumanReadableNumTranscendentalOps(double trops, double nanoseconds) {
return HumanReadableNumOps(trops, nanoseconds, "TR");
}
-void LogLines(int sev, tensorflow::StringPiece text, const char* fname,
- int lineno) {
+void LogLines(int sev, absl::string_view text, const char* fname, int lineno) {
const int orig_sev = sev;
if (sev == tensorflow::FATAL) {
sev = tensorflow::ERROR;
@@ -275,7 +274,7 @@ void LogLines(int sev, tensorflow::StringPiece text, const char* fname,
size_t cur = 0;
while (cur < text.size()) {
size_t eol = text.find('\n', cur);
- if (eol == tensorflow::StringPiece::npos) {
+ if (eol == absl::string_view::npos) {
eol = text.size();
}
auto msg = text.substr(cur, eol - cur);
diff --git a/tensorflow/compiler/xla/util.h b/tensorflow/compiler/xla/util.h
index efeafbc53a..671ef17f36 100644
--- a/tensorflow/compiler/xla/util.h
+++ b/tensorflow/compiler/xla/util.h
@@ -26,16 +26,16 @@ limitations under the License.
#include "absl/algorithm/container.h"
#include "absl/container/inlined_vector.h"
+#include "absl/strings/str_cat.h"
+#include "absl/strings/string_view.h"
#include "tensorflow/compiler/xla/status.h"
#include "tensorflow/compiler/xla/status_macros.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
#include "tensorflow/core/lib/core/status.h"
-#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/gtl/array_slice.h"
#include "tensorflow/core/lib/math/math_util.h"
#include "tensorflow/core/lib/strings/numbers.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/macros.h"
#include "tensorflow/core/platform/protobuf.h"
@@ -202,8 +202,8 @@ void StridedCopy(tensorflow::gtl::MutableArraySlice<D> dest, int64 dest_base,
// Adds some context information to the error message in a
// Status. This is useful as Statuses are
// propagated upwards.
-Status AddStatus(Status prior, tensorflow::StringPiece context);
-Status AppendStatus(Status prior, tensorflow::StringPiece context);
+Status AddStatus(Status prior, absl::string_view context);
+Status AppendStatus(Status prior, absl::string_view context);
// Status error shorthands -- printfs the arguments to be
// used as an error message and returns a status in the canonical
@@ -222,26 +222,26 @@ Status InvalidArgumentV(const char* format, va_list args);
template <typename... Args>
Status InvalidArgumentStrCat(Args&&... concat) {
- return InvalidArgument(
- "%s", tensorflow::strings::StrCat(std::forward<Args>(concat)...).c_str());
+ return InvalidArgument("%s",
+ absl::StrCat(std::forward<Args>(concat)...).c_str());
}
template <typename... Args>
Status UnimplementedStrCat(Args&&... concat) {
- return Unimplemented(
- "%s", tensorflow::strings::StrCat(std::forward<Args>(concat)...).c_str());
+ return Unimplemented("%s",
+ absl::StrCat(std::forward<Args>(concat)...).c_str());
}
template <typename... Args>
Status InternalErrorStrCat(Args&&... concat) {
- return InternalError(
- "%s", tensorflow::strings::StrCat(std::forward<Args>(concat)...).c_str());
+ return InternalError("%s",
+ absl::StrCat(std::forward<Args>(concat)...).c_str());
}
template <typename... Args>
Status ResourceExhaustedStrCat(Args&&... concat) {
- return ResourceExhausted(
- "%s", tensorflow::strings::StrCat(std::forward<Args>(concat)...).c_str());
+ return ResourceExhausted("%s",
+ absl::StrCat(std::forward<Args>(concat)...).c_str());
}
// Splits the lines of the original, replaces leading whitespace with the prefix
@@ -250,8 +250,7 @@ Status ResourceExhaustedStrCat(Args&&... concat) {
//
// Note: even different amounts of leading whitespace on different lines will be
// uniformly replaced with "indentation".
-string Reindent(tensorflow::StringPiece original,
- tensorflow::StringPiece indentation);
+string Reindent(absl::string_view original, absl::string_view indentation);
// Checks whether permutation is a permutation of the [0, rank) integer range.
bool IsPermutation(tensorflow::gtl::ArraySlice<int64> permutation, int64 rank);
@@ -313,7 +312,7 @@ string CommaSeparatedString(const Container& c, const char* prefix = "",
string comma_separated = prefix;
const char* separator = "";
for (const auto& entry : c) {
- tensorflow::strings::StrAppend(&comma_separated, separator, entry);
+ absl::StrAppend(&comma_separated, separator, entry);
separator = ", ";
}
comma_separated += suffix;
@@ -395,8 +394,7 @@ string HumanReadableNumTranscendentalOps(double trops, double nanoseconds);
// Split the text into multiple lines and log each line with the given
// severity, filename, and line number.
-void LogLines(int sev, tensorflow::StringPiece text, const char* fname,
- int lineno);
+void LogLines(int sev, absl::string_view text, const char* fname, int lineno);
template <typename T>
inline bool IsPowerOfTwo(T x) {
diff --git a/tensorflow/compiler/xla/window_util.cc b/tensorflow/compiler/xla/window_util.cc
index f11123ca24..fd48918994 100644
--- a/tensorflow/compiler/xla/window_util.cc
+++ b/tensorflow/compiler/xla/window_util.cc
@@ -17,10 +17,10 @@ limitations under the License.
#include <vector>
+#include "absl/strings/str_cat.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
#include "tensorflow/core/lib/strings/str_util.h"
-#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/lib/strings/stringprintf.h"
namespace xla {
@@ -49,8 +49,8 @@ PaddingConfig MakeSymmetricPadding(tensorflow::gtl::ArraySlice<int64> sizes) {
}
/* static */ string ToString(const WindowDimension& dim) {
- using tensorflow::strings::StrAppend;
- using tensorflow::strings::StrCat;
+ using absl::StrAppend;
+ using absl::StrCat;
string str = StrCat("(size=", dim.size());
if (dim.stride() != 1) {
StrAppend(&str, ",stride=", dim.stride());
@@ -75,8 +75,8 @@ PaddingConfig MakeSymmetricPadding(tensorflow::gtl::ArraySlice<int64> sizes) {
}
string ToString(const Window& window) {
- using tensorflow::strings::StrAppend;
- using tensorflow::strings::StrCat;
+ using absl::StrAppend;
+ using absl::StrCat;
string str;
const auto add_field =