[go: nahoru, domu]

Skip to content

Commit

Permalink
[XLA:GPU] [NFC] Remove redundant argument to GetKernelAnnotation
Browse files Browse the repository at this point in the history
It's always the current module.

PiperOrigin-RevId: 644301234
  • Loading branch information
cheshire authored and tensorflower-gardener committed Jun 19, 2024
1 parent c72dbfc commit af74a34
Show file tree
Hide file tree
Showing 32 changed files with 301 additions and 425 deletions.
4 changes: 2 additions & 2 deletions third_party/xla/third_party/tsl/tsl/lib/io/block.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class Block::Iter : public Iterator {
uint32 restart_index_; // Index of restart block in which current_ falls
string key_;
StringPiece value_;
Status status_;
absl::Status status_;

inline int Compare(const StringPiece& a, const StringPiece& b) const {
return a.compare(b);
Expand Down Expand Up @@ -135,7 +135,7 @@ class Block::Iter : public Iterator {
}

bool Valid() const override { return current_ < restarts_; }
Status status() const override { return status_; }
absl::Status status() const override { return status_; }
StringPiece key() const override {
assert(Valid());
return key_;
Expand Down
20 changes: 10 additions & 10 deletions third_party/xla/third_party/tsl/tsl/lib/io/buffered_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class BufferedWritableFile : public WritableFile {
}
~BufferedWritableFile() override { Close().IgnoreError(); }

Status Append(StringPiece str_data) override {
absl::Status Append(StringPiece str_data) override {
int64_t bytes_left = str_data.size();
const char* data = str_data.data();

Expand All @@ -58,41 +58,41 @@ class BufferedWritableFile : public WritableFile {
bytes_left -= append_bytes;
}

return OkStatus();
return absl::OkStatus();
}

Status Append(const absl::Cord& data) override {
absl::Status Append(const absl::Cord& data) override {
for (absl::string_view fragment : data.Chunks()) {
TF_RETURN_IF_ERROR(Append(fragment));
}
return OkStatus();
return absl::OkStatus();
}

Status Close() override {
absl::Status Close() override {
TF_RETURN_IF_ERROR(Flush());
return file_->Close();
}

Status Flush() override {
absl::Status Flush() override {
if (buffer_pos_ > 0) {
TF_RETURN_IF_ERROR(file_->Append(StringPiece(&buffer_[0], buffer_pos_)));
buffer_pos_ = 0;
}
return file_->Flush();
}

tsl::Status Tell(int64_t* position) override {
absl::Status Tell(int64_t* position) override {
int64_t bytes_written;
tsl::Status status = file_->Tell(&bytes_written);
absl::Status status = file_->Tell(&bytes_written);
if (status.ok()) {
*position = bytes_written + buffer_pos_;
return OkStatus();
return absl::OkStatus();
} else {
return status;
}
}

Status Sync() override { return file_->Sync(); }
absl::Status Sync() override { return file_->Sync(); }

// For compatibilty with the TensorBundle writer, we expose CRC32 checksums.
uint32_t crc32() const { return crc32_; }
Expand Down
55 changes: 28 additions & 27 deletions third_party/xla/third_party/tsl/tsl/lib/io/buffered_inputstream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ BufferedInputStream::~BufferedInputStream() {
}
}

Status BufferedInputStream::FillBuffer() {
absl::Status BufferedInputStream::FillBuffer() {
if (!file_status_.ok()) {
pos_ = 0;
limit_ = 0;
return file_status_;
}
Status s = input_stream_->ReadNBytes(size_, &buf_);
absl::Status s = input_stream_->ReadNBytes(size_, &buf_);
pos_ = 0;
limit_ = buf_.size();
if (!s.ok()) {
Expand All @@ -57,10 +57,10 @@ Status BufferedInputStream::FillBuffer() {
}

template <typename StringType>
Status BufferedInputStream::ReadLineHelper(StringType* result,
bool include_eol) {
absl::Status BufferedInputStream::ReadLineHelper(StringType* result,
bool include_eol) {
result->clear();
Status s;
absl::Status s;
size_t start_pos = pos_;
while (true) {
if (pos_ == limit_) {
Expand All @@ -79,7 +79,7 @@ Status BufferedInputStream::ReadLineHelper(StringType* result,
result->append(1, c);
}
pos_++;
return OkStatus();
return absl::OkStatus();
}
// We don't append '\r' to *result
if (c == '\r') {
Expand All @@ -89,12 +89,13 @@ Status BufferedInputStream::ReadLineHelper(StringType* result,
pos_++;
}
if (absl::IsOutOfRange(s) && !result->empty()) {
return OkStatus();
return absl::OkStatus();
}
return s;
}

Status BufferedInputStream::ReadNBytes(int64_t bytes_to_read, tstring* result) {
absl::Status BufferedInputStream::ReadNBytes(int64_t bytes_to_read,
tstring* result) {
if (bytes_to_read < 0) {
return errors::InvalidArgument("Can't read a negative number of bytes: ",
bytes_to_read);
Expand All @@ -105,7 +106,7 @@ Status BufferedInputStream::ReadNBytes(int64_t bytes_to_read, tstring* result) {
}
result->reserve(bytes_to_read);

Status s;
absl::Status s;
while (result->size() < static_cast<size_t>(bytes_to_read)) {
// Check whether the buffer is fully read or not.
if (pos_ == limit_) {
Expand All @@ -127,12 +128,12 @@ Status BufferedInputStream::ReadNBytes(int64_t bytes_to_read, tstring* result) {
// obtained enough data to satisfy the function call. Returning OK then.
if (absl::IsOutOfRange(s) &&
(result->size() == static_cast<size_t>(bytes_to_read))) {
return OkStatus();
return absl::OkStatus();
}
return s;
}

Status BufferedInputStream::SkipNBytes(int64_t bytes_to_skip) {
absl::Status BufferedInputStream::SkipNBytes(int64_t bytes_to_skip) {
if (bytes_to_skip < 0) {
return errors::InvalidArgument("Can only skip forward, not ",
bytes_to_skip);
Expand All @@ -144,22 +145,22 @@ Status BufferedInputStream::SkipNBytes(int64_t bytes_to_skip) {
// Otherwise, we already have read limit_ - pos_, so skip the rest. At this
// point we need to get fresh data into the buffer, so reset pos_ and
// limit_.
Status s = input_stream_->SkipNBytes(bytes_to_skip - (limit_ - pos_));
absl::Status s = input_stream_->SkipNBytes(bytes_to_skip - (limit_ - pos_));
pos_ = 0;
limit_ = 0;
if (absl::IsOutOfRange(s)) {
file_status_ = s;
}
return s;
}
return OkStatus();
return absl::OkStatus();
}

int64_t BufferedInputStream::Tell() const {
return input_stream_->Tell() - (limit_ - pos_);
}

Status BufferedInputStream::Seek(int64_t position) {
absl::Status BufferedInputStream::Seek(int64_t position) {
if (position < 0) {
return errors::InvalidArgument("Seeking to a negative position: ",
position);
Expand All @@ -176,17 +177,17 @@ Status BufferedInputStream::Seek(int64_t position) {
if (position < Tell()) {
// Seek within buffer before 'pos_'
pos_ -= Tell() - position;
return OkStatus();
return absl::OkStatus();
}

// Seek after 'pos_'
return SkipNBytes(position - Tell());
}

template <typename T>
Status BufferedInputStream::ReadAll(T* result) {
absl::Status BufferedInputStream::ReadAll(T* result) {
result->clear();
Status status;
absl::Status status;
while (status.ok()) {
status = FillBuffer();
if (limit_ == 0) {
Expand All @@ -198,27 +199,27 @@ Status BufferedInputStream::ReadAll(T* result) {

if (absl::IsOutOfRange(status)) {
file_status_ = status;
return OkStatus();
return absl::OkStatus();
}
return status;
}

template Status BufferedInputStream::ReadAll<std::string>(std::string* result);
template Status BufferedInputStream::ReadAll<tstring>(tstring* result);

Status BufferedInputStream::Reset() {
absl::Status BufferedInputStream::Reset() {
TF_RETURN_IF_ERROR(input_stream_->Reset());
pos_ = 0;
limit_ = 0;
file_status_ = OkStatus();
return OkStatus();
file_status_ = absl::OkStatus();
return absl::OkStatus();
}

Status BufferedInputStream::ReadLine(std::string* result) {
absl::Status BufferedInputStream::ReadLine(std::string* result) {
return ReadLineHelper(result, false);
}

Status BufferedInputStream::ReadLine(tstring* result) {
absl::Status BufferedInputStream::ReadLine(tstring* result) {
return ReadLineHelper(result, false);
}

Expand All @@ -228,8 +229,8 @@ std::string BufferedInputStream::ReadLineAsString() {
return result;
}

Status BufferedInputStream::SkipLine() {
Status s;
absl::Status BufferedInputStream::SkipLine() {
absl::Status s;
bool skipped = false;
while (true) {
if (pos_ == limit_) {
Expand All @@ -242,11 +243,11 @@ Status BufferedInputStream::SkipLine() {
char c = buf_[pos_++];
skipped = true;
if (c == '\n') {
return OkStatus();
return absl::OkStatus();
}
}
if (absl::IsOutOfRange(s) && skipped) {
return OkStatus();
return absl::OkStatus();
}
return s;
}
Expand Down
22 changes: 11 additions & 11 deletions third_party/xla/third_party/tsl/tsl/lib/io/buffered_inputstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ class BufferedInputStream : public InputStreamInterface {

~BufferedInputStream() override;

Status ReadNBytes(int64_t bytes_to_read, tstring* result) override;
absl::Status ReadNBytes(int64_t bytes_to_read, tstring* result) override;

Status SkipNBytes(int64_t bytes_to_skip) override;
absl::Status SkipNBytes(int64_t bytes_to_skip) override;

int64_t Tell() const override;

Expand All @@ -58,7 +58,7 @@ class BufferedInputStream : public InputStreamInterface {
// Note: When seeking backwards in a stream, this implementation uses
// Reset() + SkipNBytes(), so its performance will be dependent
// largely on the performance of SkipNBytes().
Status Seek(int64_t position);
absl::Status Seek(int64_t position);

// Read one text line of data into "*result" until end-of-file or a
// \n is read. (The \n is not included in the result.) Overwrites
Expand All @@ -67,8 +67,8 @@ class BufferedInputStream : public InputStreamInterface {
// If successful, returns OK. If we are already at the end of the
// file, we return an OUT_OF_RANGE error. Otherwise, we return
// some other non-OK status.
Status ReadLine(std::string* result);
Status ReadLine(tstring* result);
absl::Status ReadLine(std::string* result);
absl::Status ReadLine(tstring* result);

// Returns one text line of data until end-of-file or a '\n' is read. The '\n'
// is included in the result.
Expand All @@ -83,21 +83,21 @@ class BufferedInputStream : public InputStreamInterface {
// If successful, returns OK. If we are already at the end of the
// file, we return an OUT_OF_RANGE error. Otherwise, we return
// some other non-OK status.
Status SkipLine();
absl::Status SkipLine();

// Reads the entire contents of the file into *result.
//
// Note: the amount of memory used by this function call is unbounded, so only
// use in ops that expect that behavior.
template <typename T>
Status ReadAll(T* result);
absl::Status ReadAll(T* result);

Status Reset() override;
absl::Status Reset() override;

private:
Status FillBuffer();
absl::Status FillBuffer();
template <typename StringType>
Status ReadLineHelper(StringType* result, bool include_eol);
absl::Status ReadLineHelper(StringType* result, bool include_eol);

InputStreamInterface* input_stream_; // not owned.
size_t size_; // buffer size.
Expand All @@ -108,7 +108,7 @@ class BufferedInputStream : public InputStreamInterface {
bool owns_input_stream_ = false;
// When EoF is reached, file_status_ contains the status to skip unnecessary
// buffer allocations.
Status file_status_ = OkStatus();
absl::Status file_status_ = absl::OkStatus();

BufferedInputStream(const BufferedInputStream&) = delete;
void operator=(const BufferedInputStream&) = delete;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ReadOnceInputStream : public InputStreamInterface {
public:
ReadOnceInputStream() : start_(true) {}

virtual Status ReadNBytes(int64_t bytes_to_read, tstring* result) {
virtual absl::Status ReadNBytes(int64_t bytes_to_read, tstring* result) {
if (bytes_to_read < 11) {
return errors::InvalidArgument("Not reading all bytes: ", bytes_to_read);
}
Expand All @@ -52,9 +52,9 @@ class ReadOnceInputStream : public InputStreamInterface {
int64_t Tell() const override { return start_ ? 0 : 10; }

// Resets the stream to the beginning.
Status Reset() override {
absl::Status Reset() override {
start_ = true;
return OkStatus();
return absl::OkStatus();
}

private:
Expand Down Expand Up @@ -311,7 +311,7 @@ TEST(BufferedInputStream, OutOfRangeCache) {
TF_ASSERT_OK((in.ReadNBytes(7, &read)));
EXPECT_EQ(read, "3456789");
EXPECT_EQ(10, in.Tell());
Status s = in.ReadNBytes(5, &read);
absl::Status s = in.ReadNBytes(5, &read);
// Make sure the read is failing with OUT_OF_RANGE error. If it is failing
// with other errors, it is not caching the OUT_OF_RANGE properly.
EXPECT_EQ(error::OUT_OF_RANGE, s.code()) << s;
Expand Down
Loading

0 comments on commit af74a34

Please sign in to comment.