Skip to content

Commit

Permalink
Automated Code Change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 624763692
  • Loading branch information
tensorflower-gardener committed Apr 14, 2024
1 parent bbef2f0 commit 6bca2f5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 33 deletions.
20 changes: 10 additions & 10 deletions tensorflow/c/experimental/stream_executor/stream_executor.cc
Expand Up @@ -66,7 +66,7 @@ absl::Status ValidateSPPlatform(const SP_Platform& platform) {
TF_RETURN_IF_ERROR(
tensorflow::device_utils::ValidateDeviceType(platform.type));
// `visible_device_count` could be 0 at initialization time.
return ::tensorflow::OkStatus();
return absl::OkStatus();
}

absl::Status ValidateSPPlatformFns(const SP_PlatformFns& platform_fns) {
Expand All @@ -78,33 +78,33 @@ absl::Status ValidateSPPlatformFns(const SP_PlatformFns& platform_fns) {
TF_VALIDATE_NOT_NULL(SP_PlatformFns, platform_fns, destroy_stream_executor);
TF_VALIDATE_NOT_NULL(SP_PlatformFns, platform_fns, create_device_fns);
TF_VALIDATE_NOT_NULL(SP_PlatformFns, platform_fns, destroy_device_fns);
return ::tensorflow::OkStatus();
return absl::OkStatus();
}

absl::Status ValidateSPAllocatorStats(const SP_AllocatorStats& stats) {
TF_VALIDATE_STRUCT_SIZE(SP_AllocatorStats, stats,
SP_ALLOCATORSTATS_STRUCT_SIZE);
// All other fields could theoretically be zero/null.
return ::tensorflow::OkStatus();
return absl::OkStatus();
}

absl::Status ValidateSPDeviceMemoryBase(const SP_DeviceMemoryBase& mem) {
TF_VALIDATE_STRUCT_SIZE(SP_DeviceMemoryBase, mem,
SP_DEVICE_MEMORY_BASE_STRUCT_SIZE);
// All other fields could theoretically be zero/null.
return ::tensorflow::OkStatus();
return absl::OkStatus();
}

absl::Status ValidateSPDevice(const SP_Device& device) {
TF_VALIDATE_STRUCT_SIZE(SP_Device, device, SP_DEVICE_STRUCT_SIZE);
// All other fields could theoretically be zero/null.
return ::tensorflow::OkStatus();
return absl::OkStatus();
}

absl::Status ValidateSPDeviceFns(const SP_DeviceFns& device_fns) {
TF_VALIDATE_STRUCT_SIZE(SP_DeviceFns, device_fns, SP_DEVICE_FNS_STRUCT_SIZE);
// All other fields could theoretically be zero/null.
return ::tensorflow::OkStatus();
return absl::OkStatus();
}

absl::Status ValidateSPStreamExecutor(const SP_StreamExecutor& se,
Expand Down Expand Up @@ -140,7 +140,7 @@ absl::Status ValidateSPStreamExecutor(const SP_StreamExecutor& se,
TF_VALIDATE_NOT_NULL(SP_StreamExecutor, se, mem_zero);
TF_VALIDATE_NOT_NULL(SP_StreamExecutor, se, memset);
TF_VALIDATE_NOT_NULL(SP_StreamExecutor, se, memset32);
return ::tensorflow::OkStatus();
return absl::OkStatus();
}

absl::Status ValidateSEPlatformRegistrationParams(
Expand All @@ -150,7 +150,7 @@ absl::Status ValidateSEPlatformRegistrationParams(
TF_VALIDATE_NOT_NULL(SE_PlatformRegistrationParams, params, destroy_platform);
TF_VALIDATE_NOT_NULL(SE_PlatformRegistrationParams, params,
destroy_platform_fns);
return ::tensorflow::OkStatus();
return absl::OkStatus();
}
#undef TF_VALIDATE_NOT_NULL

Expand Down Expand Up @@ -421,7 +421,7 @@ class CStreamExecutor : public StreamExecutorInterface {
}
absl::Status DeallocateEvent(Event* event) override {
static_cast<CEvent*>(event->implementation())->Destroy();
return ::tensorflow::OkStatus();
return absl::OkStatus();
}
absl::Status RecordEvent(Stream* stream, Event* event) override {
SP_Stream stream_handle =
Expand Down Expand Up @@ -733,6 +733,6 @@ absl::Status InitStreamExecutorPlugin(SEInitPluginFn init_fn,
stream_executor::PlatformManager::RegisterPlatform(std::move(cplatform)));
// TODO(annarev): Return `use_bfc_allocator` value in some way so that it is
// available in `PluggableDeviceProcessState` once the latter is checked in.
return ::tensorflow::OkStatus();
return absl::OkStatus();
}
} // namespace stream_executor
Expand Up @@ -37,14 +37,15 @@ typedef void (*SEInitPluginFn)(SE_PlatformRegistrationParams* const,

// Registers StreamExecutor platform. `device_type` and `platform_name` are
// output parameters.
tsl::Status InitStreamExecutorPlugin(void* dso_handle, std::string* device_type,
std::string* platform_name);
absl::Status InitStreamExecutorPlugin(void* dso_handle,
std::string* device_type,
std::string* platform_name);

// Allow registering a StreamExecutor plugin using a function (used for
// testing).
tsl::Status InitStreamExecutorPlugin(SEInitPluginFn init_fn,
std::string* device_type,
std::string* platform_name);
absl::Status InitStreamExecutorPlugin(SEInitPluginFn init_fn,
std::string* device_type,
std::string* platform_name);

// This file implements core stream executor base classes in terms of
// the C API defined in stream_executor.h. A class "CSomething" represents a
Expand Down Expand Up @@ -74,12 +75,12 @@ class CPlatform : public Platform {
}
bool UseBfcAllocator() const { return platform_.use_bfc_allocator; }
bool ForceMemoryGrowth() const { return platform_.force_memory_growth; }
tsl::StatusOr<std::unique_ptr<DeviceDescription>> DescriptionForDevice(
absl::StatusOr<std::unique_ptr<DeviceDescription>> DescriptionForDevice(
int ordinal) const override;
tsl::StatusOr<StreamExecutor*> ExecutorForDevice(int ordinal) override;
tsl::StatusOr<StreamExecutor*> GetExecutor(
absl::StatusOr<StreamExecutor*> ExecutorForDevice(int ordinal) override;
absl::StatusOr<StreamExecutor*> GetExecutor(
const StreamExecutorConfig& config) override;
tsl::StatusOr<std::unique_ptr<StreamExecutor>> GetUncachedExecutor(
absl::StatusOr<std::unique_ptr<StreamExecutor>> GetUncachedExecutor(
const StreamExecutorConfig& config) override;

void DestroyAllExecutors() { executor_cache_.DestroyAllExecutors(); }
Expand All @@ -105,10 +106,10 @@ class CStream : public StreamInterface {
stream_handle_(nullptr) {}
~CStream() override { Destroy(); }

tsl::Status Create() {
absl::Status Create() {
tensorflow::TF_StatusPtr c_status(TF_NewStatus());
stream_executor_->create_stream(device_, &stream_handle_, c_status.get());
tsl::Status s = tensorflow::StatusFromTF_Status(c_status.get());
absl::Status s = tensorflow::StatusFromTF_Status(c_status.get());
return s;
}

Expand All @@ -135,13 +136,13 @@ class CEvent : public EventInterface {
event_handle_(nullptr) {}
~CEvent() override { Destroy(); }

tsl::Status Create() {
absl::Status Create() {
tensorflow::TF_StatusPtr c_status(TF_NewStatus());
stream_executor_->create_event(device_, &event_handle_, c_status.get());
return tensorflow::StatusFromTF_Status(c_status.get());
}

tsl::Status Record(SP_Stream stream_handle) {
absl::Status Record(SP_Stream stream_handle) {
tensorflow::TF_StatusPtr c_status(TF_NewStatus());
stream_executor_->record_event(device_, stream_handle, event_handle_,
c_status.get());
Expand Down
20 changes: 10 additions & 10 deletions tensorflow/c/experimental/stream_executor/stream_executor_test.cc
Expand Up @@ -39,17 +39,17 @@ TEST(StreamExecutor, SuccessfulRegistration) {
test_util::PopulateDefaultPlatformRegistrationParams(params);
};
std::string device_type, platform_name;
tsl::Status status =
absl::Status status =
InitStreamExecutorPlugin(plugin_init, &device_type, &platform_name);
TF_ASSERT_OK(status);
tsl::StatusOr<Platform*> maybe_platform =
absl::StatusOr<Platform*> maybe_platform =
PlatformManager::PlatformWithName("MY_DEVICE");
TF_ASSERT_OK(maybe_platform.status());
Platform* platform = std::move(maybe_platform).value();
ASSERT_EQ(platform->Name(), test_util::kDeviceName);
ASSERT_EQ(platform->VisibleDeviceCount(), test_util::kDeviceCount);

tsl::StatusOr<StreamExecutor*> maybe_executor =
absl::StatusOr<StreamExecutor*> maybe_executor =
platform->ExecutorForDevice(0);
TF_ASSERT_OK(maybe_executor.status());
}
Expand All @@ -63,7 +63,7 @@ TEST(StreamExecutor, NameNotSet) {
};

std::string device_type, platform_name;
tsl::Status status =
absl::Status status =
InitStreamExecutorPlugin(plugin_init, &device_type, &platform_name);
ASSERT_EQ(status.code(), tensorflow::error::FAILED_PRECONDITION);
ASSERT_EQ(status.message(), "'name' field in SP_Platform must be set.");
Expand All @@ -78,7 +78,7 @@ TEST(StreamExecutor, InvalidNameWithSemicolon) {
};

std::string device_type, platform_name;
tsl::Status status =
absl::Status status =
InitStreamExecutorPlugin(plugin_init, &device_type, &platform_name);
ASSERT_EQ(status.code(), tensorflow::error::FAILED_PRECONDITION);
EXPECT_THAT(
Expand All @@ -95,7 +95,7 @@ TEST(StreamExecutor, InvalidNameWithSlash) {
};

std::string device_type, platform_name;
tsl::Status status =
absl::Status status =
InitStreamExecutorPlugin(plugin_init, &device_type, &platform_name);
ASSERT_EQ(status.code(), tensorflow::error::FAILED_PRECONDITION);
EXPECT_THAT(status.message(),
Expand All @@ -111,7 +111,7 @@ TEST(StreamExecutor, CreateDeviceNotSet) {
};

std::string device_type, platform_name;
tsl::Status status =
absl::Status status =
InitStreamExecutorPlugin(plugin_init, &device_type, &platform_name);
ASSERT_EQ(status.code(), tensorflow::error::FAILED_PRECONDITION);
ASSERT_EQ(status.message(),
Expand All @@ -127,7 +127,7 @@ TEST(StreamExecutor, UnifiedMemoryAllocateNotSet) {
};

std::string device_type, platform_name;
tsl::Status status =
absl::Status status =
InitStreamExecutorPlugin(plugin_init, &device_type, &platform_name);
ASSERT_EQ(status.code(), tensorflow::error::FAILED_PRECONDITION);
ASSERT_EQ(
Expand All @@ -153,7 +153,7 @@ class StreamExecutorTest : public ::testing::Test {
platform_, test_util::DestroyPlatform, platform_fns_,
test_util::DestroyPlatformFns, device_fns_, se_, timer_fns_);
}
tsl::StatusOr<StreamExecutor*> maybe_executor =
absl::StatusOr<StreamExecutor*> maybe_executor =
cplatform_->ExecutorForDevice(ordinal);
TF_CHECK_OK(maybe_executor.status());
return std::move(maybe_executor).value();
Expand Down Expand Up @@ -624,7 +624,7 @@ TEST_F(StreamExecutorTest, HostCallbackError) {
};
StreamExecutor* executor = GetExecutor(0);
TF_ASSERT_OK_AND_ASSIGN(auto stream, executor->CreateStream());
std::function<tsl::Status()> callback = []() -> tsl::Status {
std::function<absl::Status()> callback = []() -> absl::Status {
return tsl::errors::Unimplemented("Unimplemented");
};
ASSERT_FALSE(stream->DoHostCallbackWithStatus(callback).ok());
Expand Down

0 comments on commit 6bca2f5

Please sign in to comment.