From 8714ada4ea5d56f8023b348bb31de73612a73c3f Mon Sep 17 00:00:00 2001 From: Jian Li <jianlijianli@google.com> Date: Mon, 12 Oct 2020 08:39:44 -0700 Subject: [PATCH] Separate the model build and tensor allocation call for integer LSTM test. PiperOrigin-RevId: 336669565 Change-Id: I13437f34cbe4a1461b724d91fae934757bc903ab --- tensorflow/lite/kernels/lstm_test.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tensorflow/lite/kernels/lstm_test.cc b/tensorflow/lite/kernels/lstm_test.cc index ccdc8193f09..9e0084e813d 100644 --- a/tensorflow/lite/kernels/lstm_test.cc +++ b/tensorflow/lite/kernels/lstm_test.cc @@ -1458,9 +1458,13 @@ class LSTMIntegerOpModel : public SingleOpModel { BuiltinOperator_LSTM, BuiltinOptions_LSTMOptions, CreateLSTMOptions(builder_, ActivationFunctionType_TANH).Union()); - BuildInterpreter({}); // Input sizes are already set + BuildInterpreter(/*input_shapes=*/{}, /*num_threads=*/-1, + /*allow_fp32_relax_to_fp16=*/false, + /*apply_delegate=*/true, /*allocate_and_delegate=*/false); } + void PerformAllocateAndDelegate() { AllocateAndDelegate(true); } + void SetInputToInputWeights(const std::vector<float>& f) { QuantizeAndPopulate<int8_t>(input_to_input_weights_, f); } @@ -1692,6 +1696,8 @@ TEST(IntegerLstmOpTest, NoCifg_NoPeephole_Projection_LayerNorm) { /*use_layer_norm=*/true, /*use_8x8_8_implementation=*/false, ranges, intermediates); + // Do allocate. + lstm.PerformAllocateAndDelegate(); // Set weights. lstm.SetInputToInputWeights(input_to_input_weights); @@ -1859,6 +1865,9 @@ TEST(IntegerLstmOpTest, NoCifg_Peephole_Projection_LayerNorm) { /*use_8x8_8_implementation=*/false, ranges, intermediates); + // Do allocate. + lstm.PerformAllocateAndDelegate(); + // Set weights. lstm.SetInputToInputWeights(input_to_input_weights); lstm.SetInputToCellWeights(input_to_cell_weights); @@ -2026,6 +2035,9 @@ TEST(IntegerLstmOpTest, Cifg_NoPeephole_Projection_LayerNorm_8x8_8) { /*use_8x8_8_implementation=*/true, ranges, intermediates); + // Do allocate. + lstm.PerformAllocateAndDelegate(); + // Set weights. // lstm.SetInputToInputWeights(input_to_input_weights); lstm.SetInputToCellWeights(input_to_cell_weights);