diff options
author | Viet Dang <vddang@google.com> | 2020-02-06 11:07:10 +0000 |
---|---|---|
committer | Viet Dang <vddang@google.com> | 2020-02-06 11:15:27 +0000 |
commit | d134ca17f25c2657e99e45ee0b58b76802a4bfa8 (patch) | |
tree | 45c289d713918810bcd9d59752e6959c5b3c4d21 /nn/runtime/test/specs/V1_3 | |
parent | 8263b55a1bdd7ff49b8aa5578a1737d76b84f5cc (diff) | |
download | ml-d134ca17f25c2657e99e45ee0b58b76802a4bfa8.tar.gz |
Add a test for quantized LSTM op for CIFG, Layer Norm, Projection.
Bug: 148938903
Test: NeuralNetworksTest_static
Change-Id: Ia267a7f90bc49b79ef47121bed202ef81d982664
Diffstat (limited to 'nn/runtime/test/specs/V1_3')
-rw-r--r-- | nn/runtime/test/specs/V1_3/qlstm_projection.mod.py (renamed from nn/runtime/test/specs/V1_3/qlstm.mod.py) | 71 |
1 files changed, 64 insertions, 7 deletions
diff --git a/nn/runtime/test/specs/V1_3/qlstm.mod.py b/nn/runtime/test/specs/V1_3/qlstm_projection.mod.py index c00c61400..8895962cc 100644 --- a/nn/runtime/test/specs/V1_3/qlstm.mod.py +++ b/nn/runtime/test/specs/V1_3/qlstm_projection.mod.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2019 The Android Open Source Project +# Copyright (C) 2020 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -116,7 +116,7 @@ model = model.Operation( output_intermediate_scale, hidden_state_zero_point, hidden_state_scale).To([output_state_out, cell_state_out, output]) -# Example 1. Input in operand 0, +# Example 1. Layer Norm, Projection. input0 = { input_to_input_weights: [ 64, 77, 89, -102, -115, 13, 25, 38, -51, 64, -102, 89, -77, 64, -51, -64, -51, -38, -25, -13 @@ -154,6 +154,11 @@ input0 = { forget_layer_norm_weights: [6553, 6553, 13107, 9830], cell_layer_norm_weights: [22937, 6553, 9830, 26214], output_layer_norm_weights: [19660, 6553, 6553, 16384], + output_state_in: [ 0 for _ in range(batch_size * output_size) ], + cell_state_in: [ 0 for _ in range(batch_size * num_units) ], + cell_to_input_weights: [], + cell_to_forget_weights: [], + cell_to_output_weights: [], } test_input = [90, 102, 13, 26, 38, 102, 13, 26, 51, 64] @@ -169,10 +174,62 @@ output0 = { } input0[input] = test_input -input0[output_state_in] = [ 0 for _ in range(batch_size * output_size) ] -input0[cell_state_in] = [ 0 for _ in range(batch_size * num_units) ] -input0[cell_to_input_weights] = [0 for _ in range(num_units) ] -input0[cell_to_forget_weights] = [0 for _ in range(num_units) ] -input0[cell_to_output_weights] = [0 for _ in range(num_units) ] + +Example((input0, output0)) + +# Example 2. CIFG, Layer Norm, Projection. +input0 = { + input_to_input_weights: [], + input_to_forget_weights: [ + -77, -13, 38, 25, 115, -64, -25, -51, 38, -102, -51, 38, -64, -51, -77, 38, -51, -77, -64, -64 + ], + input_to_cell_weights: [ + -51, -38, -25, -13, -64, 64, -25, -38, -25, -77, 77, -13, -51, -38, -89, 89, -115, -64, 102, 77 + ], + input_to_output_weights: [ + -102, -51, -25, -115, -13, -89, 38, -38, -102, -25, 77, -25, 51, -89, -38, -64, 13, 64, -77, -51 + ], + input_gate_bias: [], + forget_gate_bias: [2147484, -6442451, -4294968, 2147484], + cell_gate_bias: [-1073742, 15461883, 5368709, 1717987], + output_gate_bias: [1073742, -214748, 4294968, 2147484], + recurrent_to_input_weights: [], + recurrent_to_forget_weights: [ + -64, -38, -64, -25, 77, 51, 115, 38, -13, 25, 64, 25 + ], + recurrent_to_cell_weights: [ + -38, 25, 13, -38, 102, -10, -25, 38, 102, -77, -13, 25 + ], + recurrent_to_output_weights: [ + 38, -13, 13, -25, -64, -89, -25, -77, -13, -51, -89, -25 + ], + projection_weights: [ + -25, 51, 3, -51, 25, 127, 77, 20, 18, 51, -102, 51 + ], + projection_bias: [ 0 for _ in range(output_size) ], + input_layer_norm_weights: [], + forget_layer_norm_weights: [6553, 6553, 13107, 9830], + cell_layer_norm_weights: [22937, 6553, 9830, 26214], + output_layer_norm_weights: [19660, 6553, 6553, 16384], + output_state_in: [ 0 for _ in range(batch_size * output_size) ], + cell_state_in: [ 0 for _ in range(batch_size * num_units) ], + cell_to_input_weights: [], + cell_to_forget_weights: [], + cell_to_output_weights: [], +} + +test_input = [90, 102, 13, 26, 38, 102, 13, 26, 51, 64] + +golden_output = [ + 127, 127, 127, -128, 127, 127 +] + +output0 = { + output_state_out: golden_output, + cell_state_out: [-11692, 9960, 5491, 8861, -9422, 7726, 2056, 13149], + output: golden_output, +} + +input0[input] = test_input Example((input0, output0)) |