Skip to content

Commit

Permalink
Automated rollback of commit 1944e73. Revert tensorflow#25302.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 236332598
  • Loading branch information
tensorflower-gardener committed Mar 1, 2019
1 parent efcf007 commit 55211a9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 37 deletions.
6 changes: 2 additions & 4 deletions tensorflow/lite/kernels/kernel_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,9 @@ TfLiteStatus GetQuantizedConvolutionMultipler(TfLiteContext* context,
const TfLiteTensor* input,
const TfLiteTensor* filter,
const TfLiteTensor* bias,
const TfLiteTensor* output,
TfLiteTensor* output,
double* multiplier) {
const double input_scale = input->params.scale;
const double filter_scale = filter->params.scale;
const double input_product_scale = input_scale * filter_scale;
const double input_product_scale = input->params.scale * filter->params.scale;
const double bias_scale = bias->params.scale;
const double output_scale = output->params.scale;

Expand Down
2 changes: 1 addition & 1 deletion tensorflow/lite/kernels/kernel_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ TfLiteStatus GetQuantizedConvolutionMultipler(TfLiteContext* context,
const TfLiteTensor* input,
const TfLiteTensor* filter,
const TfLiteTensor* bias,
const TfLiteTensor* output,
TfLiteTensor* output,
double* multiplier);

// Calculates the useful quantized range of an activation layer given its
Expand Down
32 changes: 0 additions & 32 deletions tensorflow/lite/kernels/kernel_util_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,12 @@ class KernelUtilTest : public ::testing::Test {
memset(&tensor2_, 0, sizeof(TfLiteTensor));
tensor1_.dims = nullptr;
tensor2_.dims = nullptr;
tensor3_.dims = nullptr;
tensor4_.dims = nullptr;
tensor1_.allocation_type = kTfLiteMmapRo;
tensor2_.allocation_type = kTfLiteMmapRo;
tensor3_.allocation_type = kTfLiteMmapRo;
tensor4_.allocation_type = kTfLiteMmapRo;
}
~KernelUtilTest() override {
TfLiteTensorFree(&tensor1_);
TfLiteTensorFree(&tensor2_);
TfLiteTensorFree(&tensor3_);
TfLiteTensorFree(&tensor4_);
}

void SetShape(TfLiteTensor* tensor, std::initializer_list<int> dims) {
Expand All @@ -68,8 +62,6 @@ class KernelUtilTest : public ::testing::Test {
TfLiteContext context_;
TfLiteTensor tensor1_;
TfLiteTensor tensor2_;
TfLiteTensor tensor3_;
TfLiteTensor tensor4_;
};

TEST_F(KernelUtilTest, SameShapeEmpty) {
Expand Down Expand Up @@ -259,30 +251,6 @@ TEST_F(KernelUtilTest, CheckAndPopulate) {
TfLiteTensorFree(&output);
}

TEST_F(KernelUtilTest, QuantizedConvolutionMultipler) {
TfLiteTensor* input = &tensor1_;
TfLiteTensor* filter = &tensor2_;
TfLiteTensor* bias = &tensor3_;
TfLiteTensor* output = &tensor4_;

// from quantized MobileNetV1's third conv.
constexpr float input_output_scale = 0.023528477177023888;
constexpr float filter_scale = 0.015148180536925793;
constexpr float bias_scale = 0.00035641359863802791;
constexpr double multiplier_expected = static_cast<double>(filter_scale);

input->params.scale = input_output_scale;
output->params.scale = input_output_scale;
filter->params.scale = filter_scale;
bias->params.scale = bias_scale;

double multiplier = 0.0f;
EXPECT_EQ(kTfLiteOk,
GetQuantizedConvolutionMultipler(&context_, input, filter, bias,
output, &multiplier));
EXPECT_EQ(multiplier, multiplier_expected);
}

} // namespace
} // namespace tflite

Expand Down

0 comments on commit 55211a9

Please sign in to comment.