From 91d625c6f0377bb629b2509bb4f5cb040d870244 Mon Sep 17 00:00:00 2001 From: Yu-Cheng Ling Date: Tue, 9 Oct 2018 21:54:32 -0700 Subject: Fix lstm_test&layer_norm_lstm_test w/ Clang 8.0.0 PiperOrigin-RevId: 216475683 --- .../contrib/lite/kernels/layer_norm_lstm_test.cc | 116 ++++++++++----------- tensorflow/contrib/lite/kernels/lstm_test.cc | 92 ++++++++-------- 2 files changed, 102 insertions(+), 106 deletions(-) diff --git a/tensorflow/contrib/lite/kernels/layer_norm_lstm_test.cc b/tensorflow/contrib/lite/kernels/layer_norm_lstm_test.cc index 479f6a7d3c..1535f750f9 100644 --- a/tensorflow/contrib/lite/kernels/layer_norm_lstm_test.cc +++ b/tensorflow/contrib/lite/kernels/layer_norm_lstm_test.cc @@ -129,87 +129,85 @@ class LayerNormLSTMOpModel : public SingleOpModel { BuildInterpreter(input_shapes); } - void SetInputToInputWeights(std::initializer_list f) { + void SetInputToInputWeights(std::vector f) { PopulateTensor(input_to_input_weights_, f); } - void SetInputToForgetWeights(std::initializer_list f) { + void SetInputToForgetWeights(std::vector f) { PopulateTensor(input_to_forget_weights_, f); } - void SetInputToCellWeights(std::initializer_list f) { + void SetInputToCellWeights(std::vector f) { PopulateTensor(input_to_cell_weights_, f); } - void SetInputToOutputWeights(std::initializer_list f) { + void SetInputToOutputWeights(std::vector f) { PopulateTensor(input_to_output_weights_, f); } - void SetRecurrentToInputWeights(std::initializer_list f) { + void SetRecurrentToInputWeights(std::vector f) { PopulateTensor(recurrent_to_input_weights_, f); } - void SetRecurrentToForgetWeights(std::initializer_list f) { + void SetRecurrentToForgetWeights(std::vector f) { PopulateTensor(recurrent_to_forget_weights_, f); } - void SetRecurrentToCellWeights(std::initializer_list f) { + void SetRecurrentToCellWeights(std::vector f) { PopulateTensor(recurrent_to_cell_weights_, f); } - void SetRecurrentToOutputWeights(std::initializer_list f) { + void SetRecurrentToOutputWeights(std::vector f) { PopulateTensor(recurrent_to_output_weights_, f); } - void SetCellToInputWeights(std::initializer_list f) { + void SetCellToInputWeights(std::vector f) { PopulateTensor(cell_to_input_weights_, f); } - void SetCellToForgetWeights(std::initializer_list f) { + void SetCellToForgetWeights(std::vector f) { PopulateTensor(cell_to_forget_weights_, f); } - void SetCellToOutputWeights(std::initializer_list f) { + void SetCellToOutputWeights(std::vector f) { PopulateTensor(cell_to_output_weights_, f); } - void SetInputLayerNormWeights(std::initializer_list f) { + void SetInputLayerNormWeights(std::vector f) { PopulateTensor(input_layer_norm_weights_, f); } - void SetForgetLayerNormWeights(std::initializer_list f) { + void SetForgetLayerNormWeights(std::vector f) { PopulateTensor(forget_layer_norm_weights_, f); } - void SetCellLayerNormWeights(std::initializer_list f) { + void SetCellLayerNormWeights(std::vector f) { PopulateTensor(cell_layer_norm_weights_, f); } - void SetOutputLayerNormWeights(std::initializer_list f) { + void SetOutputLayerNormWeights(std::vector f) { PopulateTensor(output_layer_norm_weights_, f); } - void SetInputGateBias(std::initializer_list f) { + void SetInputGateBias(std::vector f) { PopulateTensor(input_gate_bias_, f); } - void SetForgetGateBias(std::initializer_list f) { + void SetForgetGateBias(std::vector f) { PopulateTensor(forget_gate_bias_, f); } - void SetCellBias(std::initializer_list f) { - PopulateTensor(cell_bias_, f); - } + void SetCellBias(std::vector f) { PopulateTensor(cell_bias_, f); } - void SetOutputGateBias(std::initializer_list f) { + void SetOutputGateBias(std::vector f) { PopulateTensor(output_gate_bias_, f); } - void SetProjectionWeights(std::initializer_list f) { + void SetProjectionWeights(std::vector f) { PopulateTensor(projection_weights_, f); } - void SetProjectionBias(std::initializer_list f) { + void SetProjectionBias(std::vector f) { PopulateTensor(projection_bias_, f); } @@ -278,67 +276,67 @@ class HybridLayerNormLSTMOpModel : public LayerNormLSTMOpModel { use_projection_bias, cell_clip, proj_clip, input_shapes, TensorType_UINT8) {} - void SetInputToInputWeights(std::initializer_list f) { + void SetInputToInputWeights(std::vector f) { SymmetricQuantizeAndPopulate(input_to_input_weights_, f); } - void SetInputToForgetWeights(std::initializer_list f) { + void SetInputToForgetWeights(std::vector f) { SymmetricQuantizeAndPopulate(input_to_forget_weights_, f); } - void SetInputToCellWeights(std::initializer_list f) { + void SetInputToCellWeights(std::vector f) { SymmetricQuantizeAndPopulate(input_to_cell_weights_, f); } - void SetInputToOutputWeights(std::initializer_list f) { + void SetInputToOutputWeights(std::vector f) { SymmetricQuantizeAndPopulate(input_to_output_weights_, f); } - void SetRecurrentToInputWeights(std::initializer_list f) { + void SetRecurrentToInputWeights(std::vector f) { SymmetricQuantizeAndPopulate(recurrent_to_input_weights_, f); } - void SetRecurrentToForgetWeights(std::initializer_list f) { + void SetRecurrentToForgetWeights(std::vector f) { SymmetricQuantizeAndPopulate(recurrent_to_forget_weights_, f); } - void SetRecurrentToCellWeights(std::initializer_list f) { + void SetRecurrentToCellWeights(std::vector f) { SymmetricQuantizeAndPopulate(recurrent_to_cell_weights_, f); } - void SetRecurrentToOutputWeights(std::initializer_list f) { + void SetRecurrentToOutputWeights(std::vector f) { SymmetricQuantizeAndPopulate(recurrent_to_output_weights_, f); } - void SetCellToInputWeights(std::initializer_list f) { + void SetCellToInputWeights(std::vector f) { SymmetricQuantizeAndPopulate(cell_to_input_weights_, f); } - void SetCellToForgetWeights(std::initializer_list f) { + void SetCellToForgetWeights(std::vector f) { SymmetricQuantizeAndPopulate(cell_to_forget_weights_, f); } - void SetCellToOutputWeights(std::initializer_list f) { + void SetCellToOutputWeights(std::vector f) { SymmetricQuantizeAndPopulate(cell_to_output_weights_, f); } - void SetInputLayerNormWeights(std::initializer_list f) { + void SetInputLayerNormWeights(std::vector f) { PopulateTensor(input_layer_norm_weights_, f); } - void SetForgetLayerNormWeights(std::initializer_list f) { + void SetForgetLayerNormWeights(std::vector f) { PopulateTensor(forget_layer_norm_weights_, f); } - void SetCellLayerNormWeights(std::initializer_list f) { + void SetCellLayerNormWeights(std::vector f) { PopulateTensor(cell_layer_norm_weights_, f); } - void SetOutputLayerNormWeights(std::initializer_list f) { + void SetOutputLayerNormWeights(std::vector f) { PopulateTensor(output_layer_norm_weights_, f); } - void SetProjectionWeights(std::initializer_list f) { + void SetProjectionWeights(std::vector f) { SymmetricQuantizeAndPopulate(projection_weights_, f); } }; @@ -346,26 +344,26 @@ class HybridLayerNormLSTMOpModel : public LayerNormLSTMOpModel { class BaseLayerNormLstmTest : public ::testing::Test { protected: // Weights of the Layer Norm LSTM model. Some are optional. - std::initializer_list input_to_input_weights_; - std::initializer_list input_to_cell_weights_; - std::initializer_list input_to_forget_weights_; - std::initializer_list input_to_output_weights_; - std::initializer_list input_gate_bias_; - std::initializer_list cell_gate_bias_; - std::initializer_list forget_gate_bias_; - std::initializer_list output_gate_bias_; - std::initializer_list recurrent_to_input_weights_; - std::initializer_list recurrent_to_cell_weights_; - std::initializer_list recurrent_to_forget_weights_; - std::initializer_list recurrent_to_output_weights_; - std::initializer_list cell_to_input_weights_; - std::initializer_list cell_to_forget_weights_; - std::initializer_list cell_to_output_weights_; - std::initializer_list input_layer_norm_weights_; - std::initializer_list forget_layer_norm_weights_; - std::initializer_list cell_layer_norm_weights_; - std::initializer_list output_layer_norm_weights_; - std::initializer_list projection_weights_; + std::vector input_to_input_weights_; + std::vector input_to_cell_weights_; + std::vector input_to_forget_weights_; + std::vector input_to_output_weights_; + std::vector input_gate_bias_; + std::vector cell_gate_bias_; + std::vector forget_gate_bias_; + std::vector output_gate_bias_; + std::vector recurrent_to_input_weights_; + std::vector recurrent_to_cell_weights_; + std::vector recurrent_to_forget_weights_; + std::vector recurrent_to_output_weights_; + std::vector cell_to_input_weights_; + std::vector cell_to_forget_weights_; + std::vector cell_to_output_weights_; + std::vector input_layer_norm_weights_; + std::vector forget_layer_norm_weights_; + std::vector cell_layer_norm_weights_; + std::vector output_layer_norm_weights_; + std::vector projection_weights_; // Layer Norm LSTM input is stored as num_batch x num_inputs vector. std::vector> layer_norm_lstm_input_; diff --git a/tensorflow/contrib/lite/kernels/lstm_test.cc b/tensorflow/contrib/lite/kernels/lstm_test.cc index e7ddfceb45..f8947db724 100644 --- a/tensorflow/contrib/lite/kernels/lstm_test.cc +++ b/tensorflow/contrib/lite/kernels/lstm_test.cc @@ -116,71 +116,69 @@ class LSTMOpModel : public SingleOpModel { BuildInterpreter(input_shapes); } - void SetInputToInputWeights(std::initializer_list f) { + void SetInputToInputWeights(std::vector f) { PopulateTensor(input_to_input_weights_, f); } - void SetInputToForgetWeights(std::initializer_list f) { + void SetInputToForgetWeights(std::vector f) { PopulateTensor(input_to_forget_weights_, f); } - void SetInputToCellWeights(std::initializer_list f) { + void SetInputToCellWeights(std::vector f) { PopulateTensor(input_to_cell_weights_, f); } - void SetInputToOutputWeights(std::initializer_list f) { + void SetInputToOutputWeights(std::vector f) { PopulateTensor(input_to_output_weights_, f); } - void SetRecurrentToInputWeights(std::initializer_list f) { + void SetRecurrentToInputWeights(std::vector f) { PopulateTensor(recurrent_to_input_weights_, f); } - void SetRecurrentToForgetWeights(std::initializer_list f) { + void SetRecurrentToForgetWeights(std::vector f) { PopulateTensor(recurrent_to_forget_weights_, f); } - void SetRecurrentToCellWeights(std::initializer_list f) { + void SetRecurrentToCellWeights(std::vector f) { PopulateTensor(recurrent_to_cell_weights_, f); } - void SetRecurrentToOutputWeights(std::initializer_list f) { + void SetRecurrentToOutputWeights(std::vector f) { PopulateTensor(recurrent_to_output_weights_, f); } - void SetCellToInputWeights(std::initializer_list f) { + void SetCellToInputWeights(std::vector f) { PopulateTensor(cell_to_input_weights_, f); } - void SetCellToForgetWeights(std::initializer_list f) { + void SetCellToForgetWeights(std::vector f) { PopulateTensor(cell_to_forget_weights_, f); } - void SetCellToOutputWeights(std::initializer_list f) { + void SetCellToOutputWeights(std::vector f) { PopulateTensor(cell_to_output_weights_, f); } - void SetInputGateBias(std::initializer_list f) { + void SetInputGateBias(std::vector f) { PopulateTensor(input_gate_bias_, f); } - void SetForgetGateBias(std::initializer_list f) { + void SetForgetGateBias(std::vector f) { PopulateTensor(forget_gate_bias_, f); } - void SetCellBias(std::initializer_list f) { - PopulateTensor(cell_bias_, f); - } + void SetCellBias(std::vector f) { PopulateTensor(cell_bias_, f); } - void SetOutputGateBias(std::initializer_list f) { + void SetOutputGateBias(std::vector f) { PopulateTensor(output_gate_bias_, f); } - void SetProjectionWeights(std::initializer_list f) { + void SetProjectionWeights(std::vector f) { PopulateTensor(projection_weights_, f); } - void SetProjectionBias(std::initializer_list f) { + void SetProjectionBias(std::vector f) { PopulateTensor(projection_bias_, f); } @@ -243,51 +241,51 @@ class HybridLSTMOpModel : public LSTMOpModel { use_projection_weights, use_projection_bias, cell_clip, proj_clip, input_shapes, TensorType_UINT8) {} - void SetInputToInputWeights(std::initializer_list f) { + void SetInputToInputWeights(std::vector f) { SymmetricQuantizeAndPopulate(input_to_input_weights_, f); } - void SetInputToForgetWeights(std::initializer_list f) { + void SetInputToForgetWeights(std::vector f) { SymmetricQuantizeAndPopulate(input_to_forget_weights_, f); } - void SetInputToCellWeights(std::initializer_list f) { + void SetInputToCellWeights(std::vector f) { SymmetricQuantizeAndPopulate(input_to_cell_weights_, f); } - void SetInputToOutputWeights(std::initializer_list f) { + void SetInputToOutputWeights(std::vector f) { SymmetricQuantizeAndPopulate(input_to_output_weights_, f); } - void SetRecurrentToInputWeights(std::initializer_list f) { + void SetRecurrentToInputWeights(std::vector f) { SymmetricQuantizeAndPopulate(recurrent_to_input_weights_, f); } - void SetRecurrentToForgetWeights(std::initializer_list f) { + void SetRecurrentToForgetWeights(std::vector f) { SymmetricQuantizeAndPopulate(recurrent_to_forget_weights_, f); } - void SetRecurrentToCellWeights(std::initializer_list f) { + void SetRecurrentToCellWeights(std::vector f) { SymmetricQuantizeAndPopulate(recurrent_to_cell_weights_, f); } - void SetRecurrentToOutputWeights(std::initializer_list f) { + void SetRecurrentToOutputWeights(std::vector f) { SymmetricQuantizeAndPopulate(recurrent_to_output_weights_, f); } - void SetCellToInputWeights(std::initializer_list f) { + void SetCellToInputWeights(std::vector f) { SymmetricQuantizeAndPopulate(cell_to_input_weights_, f); } - void SetCellToForgetWeights(std::initializer_list f) { + void SetCellToForgetWeights(std::vector f) { SymmetricQuantizeAndPopulate(cell_to_forget_weights_, f); } - void SetCellToOutputWeights(std::initializer_list f) { + void SetCellToOutputWeights(std::vector f) { SymmetricQuantizeAndPopulate(cell_to_output_weights_, f); } - void SetProjectionWeights(std::initializer_list f) { + void SetProjectionWeights(std::vector f) { SymmetricQuantizeAndPopulate(projection_weights_, f); } }; @@ -295,22 +293,22 @@ class HybridLSTMOpModel : public LSTMOpModel { class BaseLstmTest : public ::testing::Test { protected: // Weights of the LSTM model. Some are optional. - std::initializer_list input_to_input_weights_; - std::initializer_list input_to_cell_weights_; - std::initializer_list input_to_forget_weights_; - std::initializer_list input_to_output_weights_; - std::initializer_list input_gate_bias_; - std::initializer_list cell_gate_bias_; - std::initializer_list forget_gate_bias_; - std::initializer_list output_gate_bias_; - std::initializer_list recurrent_to_input_weights_; - std::initializer_list recurrent_to_cell_weights_; - std::initializer_list recurrent_to_forget_weights_; - std::initializer_list recurrent_to_output_weights_; - std::initializer_list cell_to_input_weights_; - std::initializer_list cell_to_forget_weights_; - std::initializer_list cell_to_output_weights_; - std::initializer_list projection_weights_; + std::vector input_to_input_weights_; + std::vector input_to_cell_weights_; + std::vector input_to_forget_weights_; + std::vector input_to_output_weights_; + std::vector input_gate_bias_; + std::vector cell_gate_bias_; + std::vector forget_gate_bias_; + std::vector output_gate_bias_; + std::vector recurrent_to_input_weights_; + std::vector recurrent_to_cell_weights_; + std::vector recurrent_to_forget_weights_; + std::vector recurrent_to_output_weights_; + std::vector cell_to_input_weights_; + std::vector cell_to_forget_weights_; + std::vector cell_to_output_weights_; + std::vector projection_weights_; // LSTM input is stored as num_batch x num_inputs vector. std::vector> lstm_input_; -- cgit v1.2.3