Skip to content
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

Add Int32 and Int64 value support to SplitV. #28376

Merged
merged 1 commit into from Jun 27, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion tensorflow/lite/kernels/split_v.cc
Expand Up @@ -126,7 +126,9 @@ TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {
auto input_type = op_context.input->type;
TF_LITE_ENSURE(context, input_type == kTfLiteFloat32 ||
input_type == kTfLiteUInt8 ||
input_type == kTfLiteInt16);
input_type == kTfLiteInt16 ||
input_type == kTfLiteInt32 ||
input_type == kTfLiteInt64);
for (int i = 0; i < NumOutputs(node); ++i) {
GetOutput(context, node, i)->type = input_type;
}
Expand Down Expand Up @@ -182,6 +184,14 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
TF_LITE_SPLIT_V(int16_t);
break;
}
case kTfLiteInt32: {
TF_LITE_SPLIT_V(int32_t);
break;
}
case kTfLiteInt64: {
TF_LITE_SPLIT_V(int64_t);
break;
}
default:
context->ReportError(context, "Type %s currently not supported.",
TfLiteTypeGetName(op_context.input->type));
Expand Down
28 changes: 28 additions & 0 deletions tensorflow/lite/kernels/split_v_test.cc
Expand Up @@ -200,6 +200,34 @@ TEST(SplitVOpTest, TwoDimensionalInt16) {
{{1, 2, 3}, {4, 5, 6}, {7, 8, 9, 10, 11, 12}});
}

TEST(SplitVOpTest, TwoDimensionalInt32) {
// Input shape: {4, 3}
// size_splits: {1, 1, 2}
// axis: 0
// We should have 3 outpus with shapes respectively:
// output 1 : {1, 3}
// output 2 : {1, 3}
// output 3 : {2, 3}
Check<int32_t, TensorType_INT32>(
/*axis=*/0, {4, 3}, {3}, {{1, 3}, {1, 3}, {2, 3}},
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}, {1, 1, 2},
{{1, 2, 3}, {4, 5, 6}, {7, 8, 9, 10, 11, 12}});
}

TEST(SplitVOpTest, TwoDimensionalInt64) {
// Input shape: {4, 3}
// size_splits: {1, 1, 2}
// axis: 0
// We should have 3 outpus with shapes respectively:
// output 1 : {1, 3}
// output 2 : {1, 3}
// output 3 : {2, 3}
Check<int64_t, TensorType_INT64>(
/*axis=*/0, {4, 3}, {3}, {{1, 3}, {1, 3}, {2, 3}},
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}, {1, 1, 2},
{{1, 2, 3}, {4, 5, 6}, {7, 8, 9, 10, 11, 12}});
}

} // namespace
} // namespace tflite

Expand Down