-
Notifications
You must be signed in to change notification settings - Fork 875
Add INT32 support to SUB #3037
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
base: main
Are you sure you want to change the base?
Add INT32 support to SUB #3037
Changes from 2 commits
1541736
b2a8b94
a726500
80082a1
5bc3e4d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,6 +105,27 @@ void TestSubFloat(int* input1_dims_data, const float* input1_data, | |
ElementCount(*output_dims), activation); | ||
} | ||
|
||
void TestSubInt32(int* input1_dims_data, const int32_t* input1_data, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You will need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done @ddavis-2015 . |
||
int* input2_dims_data, const int32_t* input2_data, | ||
int* output_dims_data, const int32_t* expected_output, | ||
TfLiteFusedActivation activation, int32_t* output_data) { | ||
TfLiteIntArray* input1_dims = IntArrayFromInts(input1_dims_data); | ||
TfLiteIntArray* input2_dims = IntArrayFromInts(input2_dims_data); | ||
TfLiteIntArray* output_dims = IntArrayFromInts(output_dims_data); | ||
|
||
constexpr int inputs_size = 2; | ||
constexpr int outputs_size = 1; | ||
constexpr int tensors_size = inputs_size + outputs_size; | ||
TfLiteTensor tensors[tensors_size] = { | ||
CreateTensor(input1_data, input1_dims), | ||
CreateTensor(input2_data, input2_dims), | ||
CreateTensor(output_data, output_dims), | ||
}; | ||
|
||
ValidateSubGoldens(tensors, tensors_size, expected_output, output_data, | ||
ElementCount(*output_dims), activation); | ||
} | ||
|
||
template <typename T> | ||
void TestSubQuantized(int* input1_dims_data, const float* input1_data, | ||
T* input1_quantized, float input1_scale, | ||
|
@@ -219,6 +240,18 @@ TF_LITE_MICRO_TEST(FloatSubWithScalarBroadcast) { | |
} | ||
} | ||
|
||
TF_LITE_MICRO_TEST(Int32SubNoActivation) { | ||
int inout_shape[] = {4, 1, 2, 2, 1}; | ||
const int32_t input1_values[] = {-2, 2147483646, -1, 1146622854}; | ||
const int32_t input2_values[] = {3, 1, -2147483647, -726978367}; | ||
const int32_t golden_values[] = {-5, 2147483645, 2147483646, 1873601221}; | ||
const int kOutputDimsCount = 4; | ||
int32_t output_data[kOutputDimsCount]; | ||
tflite::testing::TestSubInt32(inout_shape, input1_values, inout_shape, | ||
input2_values, inout_shape, golden_values, | ||
kTfLiteActNone, output_data); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code will need |
||
TF_LITE_MICRO_TEST(QuantizedSubNoActivationInt8) { | ||
const float scales[] = {0.25, 0.5, 1.0}; | ||
const int zero_points[] = {-10, 4, 13}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a
TF_LITE_ENSURE_OK
check here (line 188). It will make the code more consistent.