Skip to content

Commit 49f97f1

Browse files
Merged commit includes the following changes:
467408627 by A. Unique TensorFlower<[email protected]>: Update sqlite version in TF -- 467380418 by A. Unique TensorFlower<[email protected]>: compat: Update forward compatibility horizon to 2022-08-13 -- 467378663 by A. Unique TensorFlower<[email protected]>: Update GraphDef version to 1222. -- 467363891 by A. Unique TensorFlower<[email protected]>: Update TFRT dependency to use revision http://github.com/tensorflow/runtime/commit/b750bc2999cf02abca6ad9eeff0a04ec7bf3b683. -- 467363622 by A. Unique TensorFlower<[email protected]>: [xla:runtime] NFC: Move constraints documentation from jitrt to xla/runtime/constraints -- 467362586 by A. Unique TensorFlower<[email protected]>: [xla:runtime] NFC: Extract JitCompilationContext library from jitrt and move it to xla/runtime -- 467361314 by A. Unique TensorFlower<[email protected]>: Update TFRT dependency to use revision http://github.com/tensorflow/runtime/commit/0a042cbb5275e6ff9a3a7c2748c74df6dcede09e. -- 467360160 by A. Unique TensorFlower<[email protected]>: [xla:runtime] NFC: Extract calling_convention library from jitrt and move it to xla/runtime -- 467341954 by A. Unique TensorFlower<[email protected]>: Op documentation update. update of g3doc/_includes/tf_passes.md -- 467341426 by A. Unique TensorFlower<[email protected]>: Refactor SELECT_V2 in preparation for porting to TFLM. -- 467340678 by A. Unique TensorFlower<[email protected]>: Create some global stat tracking for CompilationEnvironments. This tracking can be used to help debug cases in which multiple CompilationEnvironments are used to compile a single HloModule (which should not happen). -- 467339870 by A. Unique TensorFlower<[email protected]>: Automated rollback of changelist 467224197. 467339756 by A. Unique TensorFlower<[email protected]>: Update TFRT dependency to use revision http://github.com/tensorflow/runtime/commit/b20ec05d272477fa6223213687bb22145df92674. -- 467339529 by A. Unique TensorFlower<[email protected]>: [XLA] Bugfix for gather index parallel partitioning where the sharded non-parallel dims in indices are not handled. -- 467337900 by A. Unique TensorFlower<[email protected]>: [XLA] Minor renamings, refactorings, checks. -- 467337622 by A. Unique TensorFlower<[email protected]>: Remove unneeded dependency. -- 467337170 by A. Unique TensorFlower<[email protected]>: Integrate LLVM at llvm/llvm-project@2c3ca3b684bb Updates LLVM usage to match [2c3ca3b684bb](llvm/llvm-project@2c3ca3b684bb) -- 467335264 by A. Unique TensorFlower<[email protected]>: [SavedModel Fingerprinting] Add hash #5, which represents the checkpoint. The `checkpoint_hash` is a hash of the serialized .index file, which is the metadata file of the TensorBundle containing a string-string table of the name of a tensor to its serialized BundleEntryProto. The BundleEntryProto contains a crc32 hash of the tensor contents, but not the contents of the tensor itself. RFC: tensorflow/community#415 -- 467334010 by A. Unique TensorFlower<[email protected]>: Update TFRT dependency to use revision http://github.com/tensorflow/runtime/commit/76b3fea4cc9d5e7cb8a85798e41a61a55c301578. -- 467332094 by A. Unique TensorFlower<[email protected]>: [xla:runtime] NFC: Extract executable library from jitrt and move it to xla/runtime -- 467324078 by A. Unique TensorFlower<[email protected]>: #tf-data-service #codehealth Clean up clang-tidy report. missing #include <vector> for 'std::vector' -- 467322782 by A. Unique TensorFlower<[email protected]>: PR #57137: [oneDNN] Skip appending kernel registration to log message for MKL ops Imported from GitHub PR tensorflow/tensorflow#57137 This PR skips printing kernel registrations for MKL ops since it leads to performance drop for some eager models caused by this commit tensorflow/tensorflow@c04f65d This is a temporary fix and the condition will be removed when support for block format is removed as a more permanent fix. Copybara import of the project: -- 89c4c20fd138a0e992599ac333e1b41417bdd7a5 by Kanvi Khanna <[email protected]>: [oneDNN] Skip appending kernel registration to log message for MKL ops Merging this change closes #57137 -- 467322425 by A. Unique TensorFlower<[email protected]>: #tf-data-service #codehealth Clean up clang-tidy report. missing #include <memory> for 'std::unique_ptr' -- 467321561 by A. Unique TensorFlower<[email protected]>: #tf-data-service #codehealth Clean up clang-tidy report. 'int64' is deprecated: Use int64_t instead. -- 467321058 by A. Unique TensorFlower<[email protected]>: PR #57089: [TF-TRT] Adjusting Conv2D Test Tolerance Imported from GitHub PR tensorflow/tensorflow#57089 This PR adjusts & fixes the unittest tolerance for the test `Conv2DStridedNCHWTest` in INT8 mode. Copybara import of the project: -- 13e4bff8394aaa58f2cdf07b6495f6793a1d2324 by DEKHTIARJonathan <[email protected]>: [TF-TRT] Adjusting Conv2D Test Tolerance Merging this change closes #57089 -- 467320826 by A. Unique TensorFlower<[email protected]>: PR #55804: [TF-TRT] Various Cleanups & Python Debugging Assertion Improvements Imported from GitHub PR tensorflow/tensorflow#55804 This PR cleans a few spots in the code base, improves the debuggability of assertion messages in unittests. And replace `distutils.version.LooseVersion` (deprecated) with `packaging.version.Version` (new recommended API). Copybara import of the project: -- a4d15ef2cbdcefbf634228b9a5a58a559a5206e5 by DEKHTIARJonathan <[email protected]>: [TF-TRT] Various Cleanups & Python Debugging Assertion Improvements Merging this change closes #55804 -- 467320083 by A. Unique TensorFlower<[email protected]>: #tf-data-service #codehealth Clean up clang-tidy report. missing #include <ostream> for 'std::ostream' -- 467319094 by A. Unique TensorFlower<[email protected]>: #tf-data-service #codehealth Clean up clang-tidy report. 'int64' is deprecated: Use int64_t instead. -- 467318151 by A. Unique TensorFlower<[email protected]>: #tf-data-service #codehealth Clean up clang-tidy report. missing #include <iterator> for 'std::back_inserter' -- 467316931 by A. Unique TensorFlower<[email protected]>: #tf-data-service #codehealth Clean up clang-tidy report. using decl 'IsSubsetOf' is unused -- 467316097 by A. Unique TensorFlower<[email protected]>: Move passes under tensorflow/compiler/mlir/tensorflow/. -- 467315812 by A. Unique TensorFlower<[email protected]>: #tf-data-service #codehealth Clean up clang-tidy report. missing #include <memory> for 'std::unique_ptr' -- 467314236 by A. Unique TensorFlower<[email protected]>: #tf-data-service #codehealth Clean up clang-tidy report. missing #include <memory> for 'std::unique_ptr' -- 467313254 by A. Unique TensorFlower<[email protected]>: #tf-data-service #codehealth Clean up clang-tidy report. missing #include <vector> for 'std::vector' missing #include <memory> for 'std::make_unique' -- 467312293 by A. Unique TensorFlower<[email protected]>: #tf-data-service #codehealth Clean up clang-tidy report. using decl 'RangeSquareDataset' is unused -- 467311309 by A. Unique TensorFlower<[email protected]>: #tf-data-service #codehealth Clean up clang-tidy report. missing #include <vector> for 'std::vector' -- 467310637 by A. Unique TensorFlower<[email protected]>: PR #57013: [TF-TRT] Add LogSoftmax Support for TF-TRT Imported from GitHub PR tensorflow/tensorflow#57013 This PR adds TF-TRT support to `tf.nn.log_softmax` operation. This is performed using the formula `logsoftmax = logits - log(reduce_sum(exp(logits), axis=-1))` . The implemented TRT layers are fused into a single op. @DEKHTIARJonathan @tfeher : Please review the changes. Copybara import of the project: -- 1a8eb9a28dc919f815cbf9c58e0c383992faa08b by Pavani Majety <[email protected]>: Add LogSoftmax conversion Fix Softmax comments [TF-TRT] Move LogSoftmax to use OpConverterBase Fix compiler errors clang-format Undo changes to convert_nodes.cc Fix comments Merging this change closes #57013 -- 467310335 by A. Unique TensorFlower<[email protected]>: #tf-data-service #codehealth Clean up clang-tidy report. missing #include <array> for 'std::array' -- 467310313 by A. Unique TensorFlower<[email protected]>: Update test config in cross device ops -- 467309032 by A. Unique TensorFlower<[email protected]>: Update TFRT dependency to use revision http://github.com/tensorflow/runtime/commit/eba528ef667653c3554984e5c05573b152c9893b. -- 467308765 by A. Unique TensorFlower<[email protected]>: #tf-data-service #codehealth Clean up clang-tidy report. missing #include <vector> for 'std::vector' -- 467307702 by A. Unique TensorFlower<[email protected]>: #tf-data-service #codehealth Clean up clang-tidy report. missing #include <vector> for 'std::vector' -- 467306473 by A. Unique TensorFlower<[email protected]>: #tf-data-service #codehealth Clean up clang-tidy report. 'int64' is deprecated: Use int64_t instead. -- 467306092 by A. Unique TensorFlower<[email protected]>: PR #56771: Add return_index_map argument in ssim() Imported from GitHub PR tensorflow/tensorflow#56771 Closes #53115 Copybara import of the project: -- 8f5a1b1e8c10ae0ff705d95f605df41e674b9102 by CohenAriel <[email protected]>: Add return_index_map argument in ssim() Merging this change closes #56771 -- 467305190 by A. Unique TensorFlower<[email protected]>: #tf-data-service #codehealth Clean up clang-tidy report. missing #include <unordered_map> for 'std::unordered_map' missing #include <vector> for 'std::vector' missing #include <memory> for 'std::shared_ptr' -- 467304747 by A. Unique TensorFlower<[email protected]>: [tfrt:jitrt] NFC: Remove Executable::KernelContext It was added before runtime::KernelContext and is not used anywhere. Remove it to avoid confusion. In the future we should reuse runtime::KernelContext as an extension point for user-defined memory allocation etc. -- 467303335 by A. Unique TensorFlower<[email protected]>: #tf-data-service #codehealth Clean up clang-tidy report. 'int64' is deprecated: Use int64_t instead. -- 467301808 by A. Unique TensorFlower<[email protected]>: Changes all local `State` or `TaskState` enum in coordination service into `CoordinatedTaskState` enum in proto. -- 467300580 by A. Unique TensorFlower<[email protected]>: lite: enable variable freezing in tf_tfl_translate tester -- 467298890 by A. Unique TensorFlower<[email protected]>: Update TFRT dependency to use revision http://github.com/tensorflow/runtime/commit/9bb23f7d1ee0e9a55d26c7168790667e5266a74c. -- 467292686 by A. Unique TensorFlower<[email protected]>: [xla:runtime] NFC: Move execution_engine library from jitrt to xla/runtime -- 467280901 by A. Unique TensorFlower<[email protected]>: [GML] Add tests for concat in the GML tiling and fusion pipeline -- 467276349 by A. Unique TensorFlower<[email protected]>: [GML] Implement dim-based shape reification for concat -- 467273958 by A. Unique TensorFlower<[email protected]>: Change mutexes under stream_executor/gpu to use absl::Mutex and absl::MutexLock instead of tensorflow::mutex and tensorflow::mutex_lock. Change instance of absl::make_unique to std::make_unique -- 467272897 by A. Unique TensorFlower<[email protected]>: [tf.data] Prepend `/bufferedio/` for all paths passed to LoadDataset op. -- PiperOrigin-RevId: 467408627
1 parent db84fb3 commit 49f97f1

File tree

117 files changed

+3908
-1137
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+3908
-1137
lines changed

tensorflow/cc/saved_model/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,10 @@ cc_library(
381381
"//tensorflow/python:__pkg__",
382382
],
383383
deps = [
384+
":constants",
384385
"//tensorflow/core:protos_all_cc",
385386
"//tensorflow/core/platform:types",
387+
"//tensorflow/core/util/tensor_bundle:naming",
386388
"@com_google_protobuf//:protobuf_headers",
387389
"//tensorflow/core/grappler:op_types",
388390
"@com_google_absl//absl/container:btree",

tensorflow/cc/saved_model/fingerprinting.cc

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ limitations under the License.
2323
#include "absl/strings/str_cat.h"
2424
#include "absl/strings/str_split.h"
2525
#include "absl/strings/strip.h"
26+
#include "tensorflow/cc/saved_model/constants.h"
2627
#include "tensorflow/core/framework/attr_value.pb.h"
2728
#include "tensorflow/core/framework/function.pb.h"
2829
#include "tensorflow/core/framework/op_def.pb.h"
@@ -31,13 +32,16 @@ limitations under the License.
3132
#include "tensorflow/core/grappler/op_types.h"
3233
#include "tensorflow/core/lib/strings/numbers.h"
3334
#include "tensorflow/core/lib/strings/proto_serialization.h"
35+
#include "tensorflow/core/platform/env.h"
3436
#include "tensorflow/core/platform/errors.h"
3537
#include "tensorflow/core/platform/fingerprint.h"
38+
#include "tensorflow/core/platform/path.h"
3639
#include "tensorflow/core/platform/statusor.h"
3740
#include "tensorflow/core/protobuf/fingerprint.pb.h"
3841
#include "tensorflow/core/protobuf/meta_graph.pb.h"
3942
#include "tensorflow/core/protobuf/saved_model.pb.h"
4043
#include "tensorflow/core/protobuf/saved_object_graph.pb.h"
44+
#include "tensorflow/core/util/tensor_bundle/naming.h"
4145

4246
namespace tensorflow::fingerprinting {
4347

@@ -86,6 +90,20 @@ void CanonicalizeNodes(GraphDef* graph_def) {
8690
}
8791
}
8892

93+
// Returns the hash of the checkpoint .index file, 0 if there is none.
94+
uint64 HashCheckpointIndexFile(absl::string_view model_dir) {
95+
std::string meta_filename = MetaFilename(io::JoinPath(
96+
model_dir, kSavedModelVariablesDirectory, kSavedModelVariablesFilename));
97+
std::string data;
98+
Status read_status = ReadFileToString(Env::Default(), meta_filename, &data);
99+
if (read_status.ok()) {
100+
return tensorflow::Fingerprint64(data);
101+
} else {
102+
LOG(WARNING) << read_status.error_message();
103+
return 0;
104+
}
105+
}
106+
89107
} // namespace
90108

91109
uint64 ComputeHash(const GraphDef& graph_def) {
@@ -94,7 +112,8 @@ uint64 ComputeHash(const GraphDef& graph_def) {
94112
return tensorflow::Fingerprint64(graph_def_string);
95113
}
96114

97-
FingerprintDef CreateFingerprintDef(const MetaGraphDef& metagraph) {
115+
FingerprintDef CreateFingerprintDef(const MetaGraphDef& metagraph,
116+
absl::string_view export_dir) {
98117
// Create a copy of `metagraph` which will be used and mutated for fingerprint
99118
// computation.
100119
MetaGraphDef metagraph_copy = metagraph;
@@ -114,6 +133,8 @@ FingerprintDef CreateFingerprintDef(const MetaGraphDef& metagraph) {
114133
RegularizeAndHashSavedObjectGraph(metagraph_copy.object_graph_def());
115134
fingerprint_def.set_saved_object_graph_hash(
116135
RegularizeAndHashSavedObjectGraph(metagraph_copy.object_graph_def()));
136+
// Set fingerprint field #5.
137+
fingerprint_def.set_checkpoint_hash(HashCheckpointIndexFile(export_dir));
117138
// Set version of the fingerprint.
118139
VersionDef* version = fingerprint_def.mutable_version();
119140
version->set_producer(kFingerprintProducer);

tensorflow/cc/saved_model/fingerprinting.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ uint64 RegularizeAndHashSignatureDefs(
3737
uint64 RegularizeAndHashSavedObjectGraph(
3838
const SavedObjectGraph& object_graph_def);
3939

40-
// Creates a FingerprintDef proto from a MetaGraph.
41-
FingerprintDef CreateFingerprintDef(const MetaGraphDef& metagraph);
40+
// Creates a FingerprintDef proto from a MetaGraph and the checkpoint meta file
41+
// (.index) in `export_dir`.
42+
FingerprintDef CreateFingerprintDef(const MetaGraphDef& metagraph,
43+
absl::string_view export_dir);
4244

4345
// Canonicalizes the GraphDef in order to remove sources of non-determinism.
4446
void CanonicalizeGraphDef(GraphDef& graph_def);

tensorflow/cc/saved_model/fingerprinting_test.cc

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ GraphDef CreateTestProto() {
4343
return graph_def;
4444
}
4545

46-
StatusOr<SavedModel> ReadSavedModel(absl::string_view file_path) {
46+
StatusOr<SavedModel> ReadSavedModel(absl::string_view file_dir) {
47+
std::string file_path = io::JoinPath(file_dir, "saved_model.pb");
4748
std::string serialized_saved_model;
48-
auto status = ReadFileToString(Env::Default(), std::string(file_path),
49-
&serialized_saved_model);
49+
auto status =
50+
ReadFileToString(Env::Default(), file_path, &serialized_saved_model);
5051
if (!status.ok()) {
5152
return status;
5253
}
@@ -63,25 +64,26 @@ TEST(FingerprintingTest, TestComputeHash) {
6364
TEST(FingerprintingTest, TestCreateFingerprint) {
6465
const std::string export_dir =
6566
io::JoinPath(testing::TensorFlowSrcRoot(), "cc/saved_model/testdata",
66-
"VarsAndArithmeticObjectGraph", "saved_model.pb");
67-
67+
"VarsAndArithmeticObjectGraph");
6868
TF_ASSERT_OK_AND_ASSIGN(SavedModel saved_model_pb,
6969
ReadSavedModel(export_dir));
7070
FingerprintDef fingerprint_def =
71-
CreateFingerprintDef(saved_model_pb.meta_graphs(0));
71+
CreateFingerprintDef(saved_model_pb.meta_graphs(0), export_dir);
7272

7373
EXPECT_GT(fingerprint_def.graph_def_checksum(), 0);
7474
EXPECT_EQ(fingerprint_def.graph_def_program_hash(), 10127142238652115842U);
7575
EXPECT_EQ(fingerprint_def.signature_def_hash(), 5693392539583495303);
7676
EXPECT_EQ(fingerprint_def.saved_object_graph_hash(), 3678101440349108924);
77+
// TODO(b/242348400): The checkpoint hash is non-deterministic, so we cannot
78+
// check its value here.
79+
EXPECT_GT(fingerprint_def.checkpoint_hash(), 0);
7780
}
7881

7982
// Test that canonicalization returns the same hash for two models saved by
8083
// calling `tf.saved_model.save` twice in a row in the same program.
8184
TEST(FingerprintingTest, TestCanonicalizeGraphDeforModelSavedTwice) {
82-
const std::string export_dir =
83-
io::JoinPath(testing::TensorFlowSrcRoot(), "cc/saved_model/testdata",
84-
"bert1", "saved_model.pb");
85+
const std::string export_dir = io::JoinPath(
86+
testing::TensorFlowSrcRoot(), "cc/saved_model/testdata", "bert1");
8587
TF_ASSERT_OK_AND_ASSIGN(SavedModel saved_model_pb,
8688
ReadSavedModel(export_dir));
8789

@@ -90,9 +92,8 @@ TEST(FingerprintingTest, TestCanonicalizeGraphDeforModelSavedTwice) {
9092
CanonicalizeGraphDef(*graph_def);
9193
uint64 hash1 = ComputeHash(*graph_def);
9294

93-
const std::string export_dir2 =
94-
io::JoinPath(testing::TensorFlowSrcRoot(), "cc/saved_model/testdata",
95-
"bert2", "saved_model.pb");
95+
const std::string export_dir2 = io::JoinPath(
96+
testing::TensorFlowSrcRoot(), "cc/saved_model/testdata", "bert2");
9697
TF_ASSERT_OK_AND_ASSIGN(SavedModel saved_model_pb2,
9798
ReadSavedModel(export_dir2));
9899
const MetaGraphDef& metagraph2 = saved_model_pb2.meta_graphs(0);
@@ -106,22 +107,20 @@ TEST(FingerprintingTest, TestCanonicalizeGraphDeforModelSavedTwice) {
106107
// Compare the fingerprints of two models saved by calling
107108
// `tf.saved_model.save` twice in a row in the same program.
108109
TEST(FingerprintingTest, TestCompareFingerprintForTwoModelSavedTwice) {
109-
const std::string export_dir =
110-
io::JoinPath(testing::TensorFlowSrcRoot(), "cc/saved_model/testdata",
111-
"bert1", "saved_model.pb");
110+
const std::string export_dir = io::JoinPath(
111+
testing::TensorFlowSrcRoot(), "cc/saved_model/testdata", "bert1");
112112

113113
TF_ASSERT_OK_AND_ASSIGN(SavedModel saved_model_pb,
114114
ReadSavedModel(export_dir));
115115
FingerprintDef fingerprint_def =
116-
CreateFingerprintDef(saved_model_pb.meta_graphs(0));
116+
CreateFingerprintDef(saved_model_pb.meta_graphs(0), export_dir);
117117

118-
const std::string export_dir2 =
119-
io::JoinPath(testing::TensorFlowSrcRoot(), "cc/saved_model/testdata",
120-
"bert2", "saved_model.pb");
118+
const std::string export_dir2 = io::JoinPath(
119+
testing::TensorFlowSrcRoot(), "cc/saved_model/testdata", "bert2");
121120
TF_ASSERT_OK_AND_ASSIGN(SavedModel saved_model_pb2,
122121
ReadSavedModel(export_dir2));
123122
FingerprintDef fingerprint_def2 =
124-
CreateFingerprintDef(saved_model_pb2.meta_graphs(0));
123+
CreateFingerprintDef(saved_model_pb2.meta_graphs(0), export_dir2);
125124

126125
EXPECT_EQ(fingerprint_def.graph_def_program_hash(),
127126
fingerprint_def2.graph_def_program_hash());
@@ -132,30 +131,38 @@ TEST(FingerprintingTest, TestCompareFingerprintForTwoModelSavedTwice) {
132131
}
133132

134133
TEST(FingerprintingTest, TestFingerprintComputationDoesNotMutateModel) {
135-
const std::string export_dir =
136-
io::JoinPath(testing::TensorFlowSrcRoot(), "cc/saved_model/testdata",
137-
"bert1", "saved_model.pb");
134+
const std::string export_dir = io::JoinPath(
135+
testing::TensorFlowSrcRoot(), "cc/saved_model/testdata", "bert1");
138136
TF_ASSERT_OK_AND_ASSIGN(SavedModel saved_model_pb,
139137
ReadSavedModel(export_dir));
140138
FingerprintDef fingerprint_def =
141-
CreateFingerprintDef(saved_model_pb.meta_graphs(0));
139+
CreateFingerprintDef(saved_model_pb.meta_graphs(0), export_dir);
142140
FingerprintDef fingerprint_def2 =
143-
CreateFingerprintDef(saved_model_pb.meta_graphs(0));
141+
CreateFingerprintDef(saved_model_pb.meta_graphs(0), export_dir);
144142

145143
EXPECT_EQ(fingerprint_def.graph_def_checksum(),
146144
fingerprint_def2.graph_def_checksum());
147145
}
148146

149147
TEST(FingerprintingTest, TestFingerprintHasVersion) {
150-
const std::string export_dir =
151-
io::JoinPath(testing::TensorFlowSrcRoot(), "cc/saved_model/testdata",
152-
"bert1", "saved_model.pb");
148+
const std::string export_dir = io::JoinPath(
149+
testing::TensorFlowSrcRoot(), "cc/saved_model/testdata", "bert1");
153150
TF_ASSERT_OK_AND_ASSIGN(SavedModel saved_model_pb,
154151
ReadSavedModel(export_dir));
155152
FingerprintDef fingerprint_def =
156-
CreateFingerprintDef(saved_model_pb.meta_graphs(0));
153+
CreateFingerprintDef(saved_model_pb.meta_graphs(0), export_dir);
157154
EXPECT_EQ(fingerprint_def.version().producer(), 0);
158155
}
159156

157+
TEST(FingerprintingTest, TestHashCheckpointForModelWithNoVariables) {
158+
const std::string export_dir = io::JoinPath(
159+
testing::TensorFlowSrcRoot(), "cc/saved_model/testdata", "bert1");
160+
TF_ASSERT_OK_AND_ASSIGN(SavedModel saved_model_pb,
161+
ReadSavedModel(export_dir));
162+
FingerprintDef fingerprint_def =
163+
CreateFingerprintDef(saved_model_pb.meta_graphs(0), export_dir);
164+
EXPECT_EQ(fingerprint_def.checkpoint_hash(), 0);
165+
}
166+
160167
} // namespace
161168
} // namespace tensorflow::fingerprinting

tensorflow/compiler/mlir/g3doc/_includes/tf_passes.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,21 @@ will be transformed into this region-based operation
541541
This pass is performing fusion specific to GPU targets. This is an ad-hoc
542542
pass for now, but should be integrated with some notion of "target" in the
543543
MLIR pipeline in the future.
544+
### `-tf-group-by-dialect`: Groups ops into functions that only contain one dialect.
545+
Factors operations into subroutines such that all functions only
546+
contain a single dialect. Which of the dialects are allowed in the
547+
"top" function is configurable.
548+
549+
For example, the code
550+
x.a()
551+
x.b()
552+
%c = y.c()
553+
x.d(%c)
554+
would be transformed into something like
555+
call @x_1()
556+
%c = call @y_1()
557+
call @x_2(%c)
558+
with @x_1, @x_2 and @y_1 filled in.
544559
### `-tf-guarantee-all-funcs-one-use`: Guarantee all FuncOp's have only a single use.
545560
### `-tf-hoist-replicate-invariant-resource-writes`: Hoists writes to replicate invariant resource variables.
546561
This pass hoists replicate invariant resource variable writes outside
@@ -661,6 +676,20 @@ Would be transformed to:
661676
-direction : Move transposes to the beginning or the end of the block where they are defined.
662677
```
663678
### `-tf-optimize`: Optimize TensorFlow module
679+
### `-tf-order-by-dialect`: Reorders ops so ops of the same dialect are next to each other.
680+
Performs a reordering of ops so that
681+
(a) ops of the same dialect are next to each other
682+
(b) order within a dialect is preserved
683+
.
684+
For example, this would transform
685+
%a = "x.f"()
686+
%b = "y.f"(%a)
687+
%c = "x.f"(%a)
688+
to
689+
%a = "x.f"()
690+
%c = "x.f"(%a)
691+
%b = "y.f"(%a)
692+
so that the two "x" dialect instructions are next to each other.
664693
### `-tf-outside-compiled-to-host-launch`: Wraps each op with the _xla_outside_compiled attribute in a separate tf_device.launch on replicated host device.
665694
This pass wraps ops with the same `_xla_outside_compilation`
666695
attribute value in a tf_device.launch op with host device assignment.

tensorflow/compiler/mlir/lite/tf_tfl_translate.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ limitations under the License.
1818

1919
#include "absl/strings/str_split.h"
2020
#include "llvm/ADT/None.h"
21+
#include "llvm/ADT/Optional.h"
2122
#include "llvm/ADT/STLExtras.h"
2223
#include "llvm/ADT/SmallVector.h"
2324
#include "llvm/ADT/StringExtras.h"
@@ -294,10 +295,11 @@ int main(int argc, char **argv) {
294295
});
295296

296297
std::string result;
297-
// TODO(b/153507667): Pass the session object when importing logic is removed.
298+
llvm::Optional<tensorflow::Session *> session = llvm::None;
299+
if (bundle) session = bundle->GetSession();
298300
auto status = tensorflow::ConvertTFExecutorToTFLOrFlatbuffer(
299301
module.ValueOrDie().get(), output_mlir, toco_flags, pass_config, tags,
300-
/*saved_model_dir=*/"", /*session=*/llvm::None, &result);
302+
/*saved_model_dir=*/"", session, &result);
301303
if (!status.ok()) return kTrFailure;
302304

303305
std::string error_msg;

tensorflow/compiler/mlir/tensorflow/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,7 @@ cc_library(
11531153
"transforms/generated_optimize.inc",
11541154
"transforms/gpu_fusion.cc",
11551155
"transforms/graph_pruning.cc",
1156+
"transforms/group_by_dialect.cc",
11561157
"transforms/guarantee_all_funcs_one_use.cc",
11571158
"transforms/hoist_replicate_invariant_resource_writes.cc",
11581159
"transforms/host_launch_to_outside_compiled.cc",
@@ -1165,6 +1166,7 @@ cc_library(
11651166
"transforms/materialize_mlir_passthrough_op.cc",
11661167
"transforms/merge_control_flow.cc",
11671168
"transforms/optimize.cc",
1169+
"transforms/order_by_dialect.cc",
11681170
"transforms/outside_compiled_to_host_launch.cc",
11691171
"transforms/parallel_execute_to_islands.cc",
11701172
"transforms/prepare_tpu_computation_for_tf_export.cc",

0 commit comments

Comments
 (0)