Skip to content

Commit d133fe3

Browse files
majnemercopybara-github
authored andcommitted
[TSL] Refactor snappy implementation and introduce resize_uninitialized.
This change moves platform specific snappy implementations to tsl/platform/snappy.cc, removing duplicate code. Additionally, STLStringResizeUninitialized is moved from tensor_cord.cc to tsl/lib/strings/resize_uninitialized.h to be used by snappy.cc and tensor_cord.cc. PiperOrigin-RevId: 821467924
1 parent fb5b215 commit d133fe3

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

tsl/platform/snappy.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ limitations under the License.
1616
#ifndef TENSORFLOW_TSL_PLATFORM_SNAPPY_H_
1717
#define TENSORFLOW_TSL_PLATFORM_SNAPPY_H_
1818

19-
#include "xla/tsl/platform/types.h"
19+
#include <cstddef>
20+
#include <string>
2021

2122
#if !defined(PLATFORM_WINDOWS)
2223
#include <sys/uio.h>
@@ -25,21 +26,18 @@ using ::iovec; // NOLINT(misc-unused-using-decls)
2526
} // namespace tsl
2627
#else
2728
namespace tsl {
28-
struct iovec {
29-
void* iov_base;
30-
size_t iov_len;
31-
};
29+
using ::snappy::iovec;
3230
} // namespace tsl
3331
#endif
3432

3533
namespace tsl {
3634
namespace port {
3735

3836
// Snappy compression/decompression support
39-
bool Snappy_Compress(const char* input, size_t length, string* output);
37+
bool Snappy_Compress(const char* input, size_t length, std::string* output);
4038

4139
bool Snappy_CompressFromIOVec(const struct iovec* iov,
42-
size_t uncompressed_length, string* output);
40+
size_t uncompressed_length, std::string* output);
4341

4442
bool Snappy_GetUncompressedLength(const char* input, size_t length,
4543
size_t* result);

0 commit comments

Comments
 (0)