Skip to content

Commit

Permalink
Replace std::string_view with absl::string_view
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 704611232
  • Loading branch information
Google-ML-Automation committed Dec 10, 2024
1 parent 3503c55 commit 85c16b8
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 26 deletions.
1 change: 1 addition & 0 deletions xla/hlo/experimental/auto_sharding/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ cc_library(
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:string_view",
"@com_google_absl//absl/time",
"@com_google_ortools//ortools/linear_solver:linear_solver_cc_proto",
"@tsl//tsl/platform:fingerprint",
Expand Down
4 changes: 2 additions & 2 deletions xla/hlo/experimental/auto_sharding/auto_sharding_solver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ limitations under the License.
#include <optional>
#include <random>
#include <string>
#include <string_view>
#include <utility>
#include <vector>

#include "absl/container/btree_set.h"
#include "absl/strings/string_view.h"
#include "absl/strings/substitute.h"
#include "xla/hlo/experimental/auto_sharding/auto_sharding.pb.h"

Expand Down Expand Up @@ -360,7 +360,7 @@ std::optional<std::pair<int64_t, int64_t>> ReduceMemoryTerms(
AutoShardingSolverRequest_Group>& groups,
const tsl::protobuf::RepeatedPtrField< // NOLINT
AutoShardingSolverRequest_Costs>& memory_costs,
std::string_view prim_type,
absl::string_view prim_type,
std::vector<std::vector<MPVariable*>>& prim_vars,
std::vector<std::pair<int64_t, int64_t>>& reduced_intervals,
std::vector<MPVariable*>& group_vars,
Expand Down
1 change: 1 addition & 0 deletions xla/service/cpu/tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ xla_cc_test(
"//xla/stream_executor:stream_executor_h",
"//xla/tests:hlo_test_base",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:string_view",
"@com_google_googletest//:gtest",
"@llvm-project//llvm:ARMCodeGen", # fixdeps: keep
"@llvm-project//llvm:X86CodeGen", # fixdeps: keep
Expand Down
2 changes: 1 addition & 1 deletion xla/service/cpu/tests/cpu_aot_export_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace xla::cpu {

class CpuAotCompilationTest : public HloTestBase {
protected:
void ExportAndLoad(std::string_view hlo_string) {
void ExportAndLoad(absl::string_view hlo_string) {
TF_ASSERT_OK_AND_ASSIGN(std::unique_ptr<HloModule> module,
ParseAndReturnVerifiedModule(hlo_string));

Expand Down
1 change: 1 addition & 0 deletions xla/service/gpu/tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,7 @@ xla_test(
deps = [
"//xla:xla_proto_cc",
"//xla/tests:hlo_test_base",
"@com_google_absl//absl/strings:string_view",
"@tsl//tsl/platform:test_main",
],
)
Expand Down
5 changes: 2 additions & 3 deletions xla/service/gpu/tests/simplify_fp_conversions_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#include <string_view>

#include "absl/strings/string_view.h"
#include "xla/tests/hlo_test_base.h"
#include "xla/xla.pb.h"

Expand Down Expand Up @@ -43,7 +42,7 @@ class SimplifyFPConversionsTest : public HloTestBase {
enable_simplify_all_fp_conversions_ = enable_simplify_all_fp_conversions;
}

static constexpr std::string_view kHloText = R"(
static constexpr absl::string_view kHloText = R"(
HloModule module
ENTRY main {
Expand Down
10 changes: 7 additions & 3 deletions xla/tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1938,6 +1938,7 @@ xla_test(
"//xla:error_spec",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/strings:string_view",
"@com_google_googletest//:gtest",
],
)
Expand All @@ -1951,6 +1952,7 @@ xla_test(
":test_macros_header",
":xla_internal_test_main",
"//xla:error_spec",
"@com_google_absl//absl/strings:string_view",
"@com_google_googletest//:gtest",
],
)
Expand All @@ -1967,6 +1969,7 @@ xla_test(
":xla_internal_test_main",
"//xla:literal",
"//xla:literal_util",
"@com_google_absl//absl/strings:string_view",
"@com_google_googletest//:gtest",
"@tsl//tsl/platform:statusor",
],
Expand Down Expand Up @@ -3472,6 +3475,9 @@ xla_test(
name = "two_plus_two_simple_test",
srcs = ["two_plus_two_simple_test.cc"],
deps = [
":client_library_test_base",
":literal_test_util",
":xla_internal_test_main",
"//xla:error_spec",
"//xla:literal",
"//xla:literal_util",
Expand All @@ -3481,12 +3487,10 @@ xla_test(
"//xla/client:local_client",
"//xla/hlo/builder:xla_builder",
"//xla/service",
"//xla/tests:client_library_test_base",
"//xla/tests:literal_test_util",
"//xla/tests:xla_internal_test_main",
"//xla/tsl/lib/core:status_test_util",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:string_view",
"@com_google_googletest//:gtest_main",
"@tsl//tsl/platform:env",
"@tsl//tsl/platform:path",
Expand Down
2 changes: 1 addition & 1 deletion xla/tests/dot_operation_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ class ParametricDotTest : public DotOperationTest,
->GetDeviceDescription()
.gpu_compute_capability();
if (std::holds_alternative<se::RocmComputeCapability>(gpu_comp)) {
std::string_view name(
absl::string_view name(
::testing::UnitTest::GetInstance()->current_test_info()->name());
if (name.find("TestF16/270x270x520_MajorToMinor") != std::string::npos) {
GTEST_SKIP() << "Not supported on ROCm until Triton is re-enabled.";
Expand Down
4 changes: 2 additions & 2 deletions xla/tests/runtime_topk_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#include <string_view>
#include <utility>
#include <vector>

#include <gtest/gtest.h>
#include "absl/strings/string_view.h"
#include "xla/literal.h"
#include "xla/literal_util.h"
#include "xla/tests/hlo_test_base.h"
Expand All @@ -31,7 +31,7 @@ namespace {
class TopkTest : public HloTestBase {};

XLA_TEST_F(TopkTest, CustomCallTarget) {
std::string_view hlo_text_module = R"(
absl::string_view hlo_text_module = R"(
HloModule topk
ENTRY TopK {
Expand Down
10 changes: 5 additions & 5 deletions xla/tests/sort_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ limitations under the License.
==============================================================================*/

#include <string>
#include <string_view>
#include <vector>

#include <gtest/gtest.h>
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include "absl/strings/str_join.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/string_view.h"
#include "xla/error_spec.h"
#include "xla/tests/hlo_test_base.h"
#include "xla/tests/test_macros.h"
Expand All @@ -32,7 +32,7 @@ namespace {
class SortTest : public HloTestBase {};

XLA_TEST_F(SortTest, SortDim0) {
std::string_view hlo_text_module = R"(
absl::string_view hlo_text_module = R"(
HloModule sort
compare {
Expand All @@ -51,7 +51,7 @@ XLA_TEST_F(SortTest, SortDim0) {
}

XLA_TEST_F(SortTest, SortDim1) {
std::string_view hlo_text_module = R"(
absl::string_view hlo_text_module = R"(
HloModule sort
compare {
Expand All @@ -70,7 +70,7 @@ XLA_TEST_F(SortTest, SortDim1) {
}

XLA_TEST_F(SortTest, SortTwiceWithSameComparator) {
std::string_view hlo_text_module = R"(
absl::string_view hlo_text_module = R"(
HloModule sort
compare {
Expand Down Expand Up @@ -102,7 +102,7 @@ class SortManyInputsTest : public SortTest,

XLA_TEST_P(SortManyInputsTest, SortManyInputs) {
int num_inputs = GetParam();
std::string_view hlo_text_module_template = R"(
absl::string_view hlo_text_module_template = R"(
HloModule sort
compare {
Expand Down
9 changes: 4 additions & 5 deletions xla/tests/topk_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#include <string_view>

#include <gtest/gtest.h>
#include "absl/strings/string_view.h"
#include "xla/error_spec.h"
#include "xla/tests/hlo_test_base.h"
#include "xla/tests/test_macros.h"
Expand All @@ -26,7 +25,7 @@ namespace {
class TopkTest : public HloTestBase {};

XLA_TEST_F(TopkTest, LargestTopK) {
std::string_view hlo_text_module = R"(
absl::string_view hlo_text_module = R"(
HloModule topk
ENTRY TopK {
Expand All @@ -38,7 +37,7 @@ XLA_TEST_F(TopkTest, LargestTopK) {
}

XLA_TEST_F(TopkTest, SmallestTopK) {
std::string_view hlo_text_module = R"(
absl::string_view hlo_text_module = R"(
HloModule topk
ENTRY TopK {
Expand All @@ -51,7 +50,7 @@ XLA_TEST_F(TopkTest, SmallestTopK) {

XLA_TEST_F(TopkTest, TopKOfTranspose) {
// Regression test for b/362565176
std::string_view hlo_text_module = R"(
absl::string_view hlo_text_module = R"(
HloModule topk
ENTRY main {
Expand Down
8 changes: 4 additions & 4 deletions xla/tests/two_plus_two_simple_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ limitations under the License.
#include <cstdlib>
#include <memory>
#include <string>
#include <string_view>
#include <vector>

#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "absl/status/statusor.h"
#include "absl/strings/match.h"
#include "absl/strings/numbers.h"
#include "absl/strings/string_view.h"
#include "xla/client/local_client.h"
#include "xla/error_spec.h"
#include "xla/hlo/builder/xla_builder.h"
Expand Down Expand Up @@ -94,10 +94,10 @@ TEST_F(TwoPlusTwoSimpleTest, TwoPlusTwoScalarWithTwoTransfer) {
int64_t newest = -1;
const std::string* newest_path = nullptr;
for (const auto& path : paths) {
std::string_view file = tsl::io::Basename(path);
absl::string_view file = tsl::io::Basename(path);
size_t pos = file.find('-');
ASSERT_NE(pos, std::string_view::npos);
std::string_view timestamp_str = file.substr(0, pos);
ASSERT_NE(pos, absl::string_view::npos);
absl::string_view timestamp_str = file.substr(0, pos);
int64_t timestamp;
ASSERT_TRUE(absl::SimpleAtoi(timestamp_str, &timestamp));
if (timestamp > newest) {
Expand Down

0 comments on commit 85c16b8

Please sign in to comment.