8000 Internal only change. by copybara-service[bot] · Pull Request #93587 · tensorflow/tensorflow · GitHub
[go: up one dir, main page]

Skip to content

Internal only change. #93587

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tensorflow/core/BUILD
< 10000 tr>
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ tf_cuda_library(
"//tensorflow/core/framework:tensor_slice.h",
"//tensorflow/core/framework:tensor_types.h",
"//tensorflow/core/framework:tensor_util.h",
"//tensorflow/core/framework:tf_data_file_logger_options.h",
"//tensorflow/core/framework:thread_factory.h",
"//tensorflow/core/framework:tracking_allocator.h",
"//tensorflow/core/framework:type_index.h",
Expand Down
1 change: 1 addition & 0 deletions tensorflow/core/data/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,7 @@ tf_cc_test(
# copybara:uncomment extra_copts = ["-Wthread-safety-analysis"],
deps = [
":utils",
"//tensorflow/core:framework",
"@com_google_googletest//:gtest_main",
],
)
3 changes: 2 additions & 1 deletion tensorflow/core/data/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ limitations under the License.
#include "absl/container/flat_hash_map.h"
#include "absl/status/statusor.h"
#include "tensorflow/core/framework/metrics.h"
#include "tensorflow/core/framework/tf_data_file_logger_options.h"
#include "tensorflow/core/protobuf/data_service.pb.h"

namespace tensorflow {
Expand All @@ -47,7 +48,7 @@ absl::StatusOr<bool> DisableCompressionAtRuntime(
return false;
}

void LogFilenames(const std::vector<std::string>& files) {}
void LogFilenames(const LogFilenamesOptions& options) {}

} // namespace data
} // namespace tensorflow
4 changes: 3 additions & 1 deletion tensorflow/core/data/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ limitations under the License.
#include <memory>
#include <optional>
#include <string>
#include <vector>

#include "absl/container/flat_hash_map.h"
#include "absl/status/statusor.h"
#include "tensorflow/core/framework/tf_data_file_logger_options.h"
#include "tensorflow/core/protobuf/data_service.pb.h"

namespace tensorflow {
Expand Down Expand Up @@ -54,7 +56,7 @@ absl::StatusOr<bool> DisableCompressionAtRuntime(
// every call. Thread safe.
// TODO (shushanik) Implement streamz error reporting in case the logging is not
// successful
void LogFilenames(const std::vector<std::string>& files);
void LogFilenames(const LogFilenamesOptions& options);

} // namespace data
} // namespace tensorflow
Expand Down
10 changes: 7 additions & 3 deletions tensorflow/core/data/utils_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
#include <vector>

#include <gtest/gtest.h>
#include "tensorflow/core/framework/tf_data_file_logger_options.h"

namespace tensorflow::data {
namespace {
Expand Down Expand Up @@ -56,9 +57,12 @@ TEST(LocalityOptimizedPath, TfDataPath) {
}

TEST(LocalityOptimizedPath, LogFilenames) {
EXPECT_NO_FATAL_FAILURE(LogFilenames(
std::vector<std::string>({"/path/file1", "file2.txt", "a"})));
EXPECT_NO_FATAL_FAILURE(LogFilenames(std::vector<std::string>({})));
LogFilenamesOptions options = {.files = {"/path/file1", "file2.txt", "a"},
.data_service_address = ""};
EXPECT_NO_FATAL_FAILURE(LogFilenames(options));

LogFilenamesOptions options_default_address = {.files = {}};
EXPECT_NO_FATAL_FAILURE(LogFilenames(options_default_address));
}

} // namespace
Expand Down
3 changes: 3 additions & 0 deletions tensorflow/core/framework/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ exports_files(
"tensor_reference.h",
"tensor_slice.h",
"tensor_util.h",
"tf_data_file_logger_options.h",
"thread_factory.h",
"tracking_allocator.h",
"versions.h",
Expand Down Expand Up @@ -260,6 +261,7 @@ filegroup(
"tensor_slice.h",
"tensor_types.h",
"tensor_util.h",
"tf_data_file_logger_options.h",
"thread_factory.h",
"tracking_allocator.h",
"type_index.h",
Expand Down Expand Up @@ -342,6 +344,7 @@ filegroup(
"tensor_shape.h",
"tensor_types.h",
"tensor_util.h",
"tf_data_file_logger_options.h",
"tracking_allocator.h",
"type_index.h",
"type_traits.h",
Expand Down
43 changes: 43 additions & 0 deletions tensorflow/core/framework/tf_data_file_logger_options.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* Copyright 2025 The TensorFlow Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_CORE_FRAMEWORK_TF_DATA_FILE_LOGGER_OPTIONS_H_
#define TENSORFLOW_CORE_FRAMEWORK_TF_DATA_FILE_LOGGER_OPTIONS_H_

#include <string>
#include <vector>

namespace tensorflow {
namespace data {

struct LogFilenamesOptions {
std::vector<std::string> files;
std::string data_service_address = "";
};

inline bool operator==(const LogFilenamesOptions& lhs,
const LogFilenamesOptions& rhs) {
return lhs.files == rhs.files &&
lhs.data_service_address == rhs.data_service_address;
}

inline bool operator!=(const LogFilenamesOptions& lhs,
const LogFilenamesOptions& rhs) {
return !(lhs == rhs);
}

} // namespace data
} // namespace tensorflow

#endif // TENSORFLOW_CORE_FRAMEWORK_TF_DATA_FILE_LOGGER_OPTIONS_H_
11 changes: 9 additions & 2 deletions tensorflow/core/kernels/data/fixed_length_record_dataset_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ limitations under the License.
#include "tensorflow/core/framework/metrics.h"
#include "tensorflow/core/framework/partial_tensor_shape.h"
#include "tensorflow/core/framework/tensor.h"
#include "tensorflow/core/framework/tf_data_file_logger_options.h"
#include "tensorflow/core/lib/io/buffered_inputstream.h"
#include "tensorflow/core/lib/io/inputbuffer.h"
#include "tensorflow/core/lib/io/random_inputstream.h"
Expand Down Expand Up @@ -133,7 +134,10 @@ class FixedLengthRecordDatasetOp::Dataset : public DatasetBase {
: DatasetIterator<Dataset>(params) {}

absl::Status Initialize(IteratorContext* ctx) override {
LogFilenames(dataset()->filenames_);
LogFilenamesOptions log_filenames_options = {
.files = dataset()->filenames_,
.data_service_address = ctx->data_service_address()};
LogFilenames(log_filenames_options);
return absl::OkStatus();
}

Expand Down Expand Up @@ -264,7 +268,10 @@ class FixedLengthRecordDatasetOp::Dataset : public DatasetBase {
: DatasetIterator<Dataset>(params) {}

absl::Status Initialize(IteratorContext* ctx) override {
LogFilenames(dataset()->filenames_);
LogFilenamesOptions log_filenames_options = {
.files = dataset()->filenames_,
.data_service_address = ctx->data_service_address()};
LogFilenames(log_filenames_options);
return absl::OkStatus();
}

Expand Down
6 changes: 5 additions & 1 deletion tensorflow/core/kernels/data/text_line_dataset_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ limitations under the License.
#include "tensorflow/core/framework/metrics.h"
#include "tensorflow/core/framework/partial_tensor_shape.h"
#include "tensorflow/core/framework/tensor.h"
#include "tensorflow/core/framework/tf_data_file_logger_options.h"
#include "tensorflow/core/lib/io/buffered_inputstream.h"
#include "tensorflow/core/lib/io/inputbuffer.h"
#include "tensorflow/core/lib/io/random_inputstream.h"
Expand Down Expand Up @@ -101,7 +102,10 @@ class TextLineDatasetOp::Dataset : public DatasetBase {
: DatasetIterator<Dataset>(params) {}

absl::Status Initialize(IteratorContext* ctx) override {
LogFilenames(dataset()->filenames_);
LogFilenamesOptions log_filenames_options = {
.files = dataset()->filenames_,
.data_service_address = ctx->data_service_address()};
LogFilenames(log_filenames_options);
return absl::OkStatus();
}

Expand Down
6 changes: 5 additions & 1 deletion tensorflow/core/kernels/data/tf_record_dataset_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ limitations under the License.
#include "tensorflow/core/framework/metrics.h"
#include "tensorflow/core/framework/partial_tensor_shape.h"
#include "tensorflow/core/framework/tensor.h"
#include "tensorflow/core/framework/tf_data_file_logger_options.h"
#include "tensorflow/core/lib/io/buffered_inputstream.h"
#include "tensorflow/core/lib/io/inputbuffer.h"
#include "tensorflow/core/lib/io/random_inputstream.h"
Expand Down Expand Up @@ -134,7 +135,10 @@ class TFRecordDatasetOp::Dataset : public DatasetBase {
: DatasetIterator<Dataset>(params) {}

absl::Status Initialize(IteratorContext* ctx) override {
LogFilenames(dataset()->filenames_);
LogFilenamesOptions log_filenames_options = {
.files = dataset()->filenames_,
.data_service_address = ctx->data_service_address()};
LogFilenames(log_filenames_options);
return absl::OkStatus();
}

Expand Down
0