Skip to content

Commit

Permalink
Added versioning.
Browse files Browse the repository at this point in the history
Change-Id: Ie0d7bbb9798dd4d06493537a0f44ca18f8a07a5f
  • Loading branch information
wwwind committed Jul 31, 2020
1 parent 9ca8d0c commit f81de27
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tensorflow/lite/kernels/register.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ BuiltinOpResolver::BuiltinOpResolver() {
/* max_version = */ 4);
AddBuiltin(BuiltinOperator_TRANSPOSE, Register_TRANSPOSE(),
/* min_version = */ 1,
/* max_version = */ 4);
/* max_version = */ 5);
AddBuiltin(BuiltinOperator_MEAN, Register_MEAN(),
/* min_version = */ 1,
/* max_version = */ 3);
Expand Down Expand Up @@ -201,7 +201,7 @@ BuiltinOpResolver::BuiltinOpResolver() {
AddBuiltin(BuiltinOperator_SELECT_V2, Register_SELECT_V2());
AddBuiltin(BuiltinOperator_SLICE, Register_SLICE(),
/* min_version = */ 1,
/* max_version = */ 3);
/* max_version = */ 4);
AddBuiltin(BuiltinOperator_SIN, Register_SIN());
AddBuiltin(BuiltinOperator_COS, Register_COS());
AddBuiltin(BuiltinOperator_TRANSPOSE_CONV, Register_TRANSPOSE_CONV(),
Expand Down
2 changes: 2 additions & 0 deletions tensorflow/lite/toco/tflite/op_version.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ std::string GetMinimumRuntimeVersionForModel(const Model& model) {
{{OperatorType::kTranspose, 1}, "1.6.0"},
{{OperatorType::kTranspose, 2}, "1.14.0"},
{{OperatorType::kTranspose, 3}, "1.15.0"},
{{OperatorType::kTranspose, 5}, kPendingReleaseOpVersion},
{{OperatorType::kLstmCell, 1}, "1.7.0"},
{{OperatorType::kLstmCell, 2}, "1.10.0"},
{{OperatorType::kLstmCell, 3}, "1.14.0"},
Expand Down Expand Up @@ -176,6 +177,7 @@ std::string GetMinimumRuntimeVersionForModel(const Model& model) {
{{OperatorType::kSlice, 1}, "1.14.0"},
{{OperatorType::kSlice, 2}, "1.14.0"},
{{OperatorType::kSlice, 3}, "1.14.0"},
{{OperatorType::kSlice, 4}, kPendingReleaseOpVersion},
{{OperatorType::kTanh, 1}, "1.14.0"},
{{OperatorType::kTanh, 2}, "1.14.0"},
{{OperatorType::kTanh, 3}, kPendingReleaseOpVersion},
Expand Down
6 changes: 6 additions & 0 deletions tensorflow/lite/tools/versioning/op_version.cc
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ int GetBuiltinOperatorVersion(const OpSignature& op_sig) {
return 1;

case BuiltinOperator_TRANSPOSE:
if (op_sig.input_types.at(0) == TensorType_INT16) {
return 5;
}
if (op_sig.options.single_input_op.num_dims > 4) {
return 4;
}
Expand Down Expand Up @@ -320,6 +323,9 @@ int GetBuiltinOperatorVersion(const OpSignature& op_sig) {
return 1;

case BuiltinOperator_SLICE:
if (op_sig.input_types.at(0) == TensorType_INT16) {
return 4;
}
// Version 3 supports string input types.
if (op_sig.input_types.at(0) == TensorType_STRING) {
return 3;
Expand Down
12 changes: 12 additions & 0 deletions tensorflow/lite/tools/versioning/op_version_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ TEST(OpVersionTest, VersioningSpaceToDepthTest) {

TEST(OpVersionTest, VersioningSliceTest) {
OpSignature fake_op_sig = {
.op = BuiltinOperator_SLICE,
.input_types = std::vector<TensorType>{TensorType_INT16},
};
EXPECT_EQ(GetBuiltinOperatorVersion(fake_op_sig), 4);

fake_op_sig = {
.op = BuiltinOperator_SLICE,
.input_types = std::vector<TensorType>{TensorType_STRING},
};
Expand Down Expand Up @@ -587,6 +593,12 @@ TEST(OpVersionTest, VersioningTileOperatorTest) {
}
TEST(OpVersionTest, VersioningTransposeTest) {
OpSignature fake_op_sig = {
.op = BuiltinOperator_TRANSPOSE,
.input_types = std::vector<TensorType>{TensorType_INT16},
};
EXPECT_EQ(GetBuiltinOperatorVersion(fake_op_sig), 5);

fake_op_sig = {
.op = BuiltinOperator_TRANSPOSE,
.input_types = std::vector<TensorType>{TensorType_BOOL},
};
Expand Down
2 changes: 2 additions & 0 deletions tensorflow/lite/tools/versioning/runtime_version.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ std::string FindMinimumRuntimeVersionForOp(tflite::BuiltinOperator op_code,
{{BuiltinOperator_TRANSPOSE, 2}, "1.14.0"},
{{BuiltinOperator_TRANSPOSE, 3}, "1.15.0"},
{{BuiltinOperator_TRANSPOSE, 4}, "2.3.0"},
{{BuiltinOperator_TRANSPOSE, 5}, kPendingReleaseVersion},
{{BuiltinOperator_LSTM, 1}, "1.7.0"},
{{BuiltinOperator_LSTM, 2}, "1.10.0"},
{{BuiltinOperator_LSTM, 3}, "1.14.0"},
Expand Down Expand Up @@ -223,6 +224,7 @@ std::string FindMinimumRuntimeVersionForOp(tflite::BuiltinOperator op_code,
{{BuiltinOperator_SLICE, 1}, "1.14.0"},
{{BuiltinOperator_SLICE, 2}, "1.14.0"},
{{BuiltinOperator_SLICE, 3}, "1.14.0"},
{{BuiltinOperator_SLICE, 4}, kPendingReleaseVersion},
{{BuiltinOperator_TANH, 1}, "1.14.0"},
{{BuiltinOperator_TANH, 2}, "1.14.0"},
{{BuiltinOperator_TANH, 3}, "2.3.0"},
Expand Down

0 comments on commit f81de27

Please sign in to comment.