Skip to content

Commit 617c10e

Browse files
committed
Fix validateTags() bug
empty string array is a valid tag. TF 1.x model does not have any tags
1 parent a4f32dc commit 617c10e

File tree

2 files changed

+1
-7
lines changed

2 files changed

+1
-7
lines changed

tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/SavedModelBundle.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ opts, runOpts, new BytePointer(exportDir), new PointerPointer(tags),
429429
}
430430

431431
private static void validateTags(String[] tags) {
432-
if (tags == null || tags.length == 0 || Arrays.stream(tags).anyMatch(t -> t == null || t.isEmpty())) {
432+
if (tags == null || Arrays.stream(tags).anyMatch(t -> t == null || t.isEmpty())) {
433433
throw new IllegalArgumentException("Invalid tags: " + Arrays.toString(tags));
434434
}
435435
}

tensorflow-core/tensorflow-core-api/src/test/java/org/tensorflow/SavedModelBundleTest.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,6 @@ public void cannotExportOrImportInvalidTags() {
264264
assertThrows(IllegalArgumentException.class, () ->
265265
SavedModelBundle.loader("/").withTags()
266266
);
267-
assertThrows(IllegalArgumentException.class, () ->
268-
SavedModelBundle.loader("/").withTags(new String[]{})
269-
);
270267
assertThrows(IllegalArgumentException.class, () ->
271268
SavedModelBundle.loader("/").withTags(new String[]{"tag", null})
272269
);
@@ -276,9 +273,6 @@ public void cannotExportOrImportInvalidTags() {
276273
assertThrows(IllegalArgumentException.class, () ->
277274
SavedModelBundle.exporter("/").withTags()
278275
);
279-
assertThrows(IllegalArgumentException.class, () ->
280-
SavedModelBundle.exporter("/").withTags(new String[]{})
281-
);
282276
assertThrows(IllegalArgumentException.class, () ->
283277
SavedModelBundle.exporter("/").withTags(new String[]{"tag", null})
284278
);

0 commit comments

Comments
 (0)