Skip to content

Commit c9b076d

Browse files
LukeBoyercopybara-github
authored andcommitted
Add printer for tfl options 2
LiteRT-PiperOrigin-RevId: 774940906
1 parent a8d6280 commit c9b076d

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

litert/core/model/model.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,17 @@ void AbslStringify(Sink& sink, const ::litert::internal::TflOptions& opts) {
11431143
}
11441144
}
11451145

1146+
template <class Sink>
1147+
void AbslStringify(Sink& sink, const ::litert::internal::TflOptions2& opts) {
1148+
// NOTE: Printers for specific options will be added on an as needed basis.
1149+
const auto type = opts.type;
1150+
switch (type) {
1151+
default:
1152+
absl::Format(&sink, "{%s}", ::litert::kNoPrinterTag);
1153+
break;
1154+
}
1155+
}
1156+
11461157
// AddOptionsT
11471158

11481159
template <typename Sink>

litert/core/model/model_test.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,14 @@ TEST(PrintingTest, TflOptionsNoPrinter) {
586586
EXPECT_EQ(absl::StrFormat("%v", opts), "{!no_printer}");
587587
}
588588

589+
TEST(PrintingTest, TflOptions2NoPrinter) {
590+
TflOptions2 opts;
591+
opts.type = ::tflite::BuiltinOptions2_StableHLOCompositeOptions;
592+
::tflite::StableHLOCompositeOptionsT comp_opts;
593+
opts.Set(std::move(comp_opts));
594+
EXPECT_EQ(absl::StrFormat("%v", opts), "{!no_printer}");
595+
}
596+
589597
TEST(PrintingTest, FusedActivationFunction) {
590598
EXPECT_EQ(absl::StrFormat("%v", ::tflite::ActivationFunctionType_RELU),
591599
"RELU");

0 commit comments

Comments
 (0)