TF_LITE_ENSURE(context, params->cell_clip >= 0);
TF_LITE_ENSURE(context, params->proj_clip >= 0);
- TfLiteTensor* input_to_input_weights =
+ const TfLiteTensor* input_to_input_weights =
GetOptionalInputTensor(context, node, input_to_input_weights_tensor);
if (input_to_input_weights) {
TF_LITE_ENSURE_EQ(context, input_to_input_weights->dims->size, 2);
TF_LITE_ENSURE_EQ(context, input_to_cell_weights->dims->data[0], n_cell);
TF_LITE_ENSURE_EQ(context, input_to_cell_weights->dims->data[1], n_input);
- TfLiteTensor* recurrent_to_input_weights =
+ const TfLiteTensor* recurrent_to_input_weights =
GetOptionalInputTensor(context, node, recurrent_to_input_weights_tensor);
if (recurrent_to_input_weights) {
TF_LITE_ENSURE_EQ(context, recurrent_to_input_weights->dims->size, 2);
(recurrent_to_input_weights == nullptr));
TF_LITE_ENSURE(context, cifg_weights_all_or_none == true);
- TfLiteTensor* cell_to_input_weights =
+ const TfLiteTensor* cell_to_input_weights =
GetOptionalInputTensor(context, node, cell_to_input_weights_tensor);
if (cell_to_input_weights) {
TF_LITE_ENSURE_EQ(context, cell_to_input_weights->dims->size, 1);
TF_LITE_ENSURE_EQ(context, cell_to_input_weights->dims->data[0], n_cell);
}
- TfLiteTensor* cell_to_forget_weights =
+ const TfLiteTensor* cell_to_forget_weights =
GetOptionalInputTensor(context, node, cell_to_forget_weights_tensor);
if (cell_to_forget_weights) {
TF_LITE_ENSURE_EQ(context, cell_to_forget_weights->dims->size, 1);
TF_LITE_ENSURE_EQ(context, cell_to_forget_weights->dims->data[0], n_cell);
}
- TfLiteTensor* cell_to_output_weights =
+ const TfLiteTensor* cell_to_output_weights =
GetOptionalInputTensor(context, node, cell_to_output_weights_tensor);
if (cell_to_output_weights) {
TF_LITE_ENSURE_EQ(context, cell_to_output_weights->dims->size, 1);
TF_LITE_ENSURE(context, peephole_weights_all_or_none == true);
// Make sure the input gate bias is present only when not a CIFG-LSTM.
- TfLiteTensor* input_gate_bias =
+ const TfLiteTensor* input_gate_bias =
GetOptionalInputTensor(context, node, input_gate_bias_tensor);
if (use_cifg) {
TF_LITE_ENSURE_EQ(context, input_gate_bias, nullptr);
TF_LITE_ENSURE_EQ(context, output_gate_bias->dims->size, 1);
TF_LITE_ENSURE_EQ(context, output_gate_bias->dims->data[0], n_cell);
- TfLiteTensor* projection_weights =
+ const TfLiteTensor* projection_weights =
GetOptionalInputTensor(context, node, projection_weights_tensor);
if (projection_weights) {
TF_LITE_ENSURE_EQ(context, projection_weights->dims->size, 2);
TF_LITE_ENSURE_EQ(context, projection_weights->dims->data[1], n_cell);
}
- TfLiteTensor* projection_bias =
+ const TfLiteTensor* projection_bias =
GetOptionalInputTensor(context, node, projection_bias_tensor);
if (projection_bias) {
TF_LITE_ENSURE_EQ(context, projection_bias->dims->size, 1);
fw_output_state->allocation_type = kTfLiteArenaRwPersistent;
fw_cell_state->allocation_type = kTfLiteArenaRwPersistent;
- TfLiteTensor* fw_input_to_input_weights =
+ const TfLiteTensor* fw_input_to_input_weights =
GetOptionalInputTensor(context, node, kFwInputToInputWeightsTensor);
const bool fw_use_cifg = (fw_input_to_input_weights == nullptr);
TfLiteIntArray* fw_scratch_buffer_size = TfLiteIntArrayCreate(2);
bw_output_state->allocation_type = kTfLiteArenaRwPersistent;
bw_cell_state->allocation_type = kTfLiteArenaRwPersistent;
- TfLiteTensor* bw_input_to_input_weights =
+ const TfLiteTensor* bw_input_to_input_weights =
GetOptionalInputTensor(context, node, kBwInputToInputWeightsTensor);
const bool bw_use_cifg = (bw_input_to_input_weights == nullptr);
TfLiteIntArray* bw_scratch_buffer_size = TfLiteIntArrayCreate(2);
const int n_input = input->dims->data[2];
// Tensors for the forward cell.
- TfLiteTensor* fw_input_to_input_weights =
+ const TfLiteTensor* fw_input_to_input_weights =
GetOptionalInputTensor(context, node, kFwInputToInputWeightsTensor);
const TfLiteTensor* fw_input_to_forget_weights =
GetInput(context, node, kFwInputToForgetWeightsTensor);
const TfLiteTensor* fw_input_to_output_weights =
GetInput(context, node, kFwInputToOutputWeightsTensor);
- TfLiteTensor* fw_recurrent_to_input_weights =
+ const TfLiteTensor* fw_recurrent_to_input_weights =
GetOptionalInputTensor(context, node, kFwRecurrentToInputWeightsTensor);
const TfLiteTensor* fw_recurrent_to_forget_weights =
GetInput(context, node, kFwRecurrentToForgetWeightsTensor);
const TfLiteTensor* fw_recurrent_to_output_weights =
GetInput(context, node, kFwRecurrentToOutputWeightsTensor);
- TfLiteTensor* fw_cell_to_input_weights =
+ const TfLiteTensor* fw_cell_to_input_weights =
GetOptionalInputTensor(context, node, kFwCellToInputWeightsTensor);
- TfLiteTensor* fw_cell_to_forget_weights =
+ const TfLiteTensor* fw_cell_to_forget_weights =
GetOptionalInputTensor(context, node, kFwCellToForgetWeightsTensor);
- TfLiteTensor* fw_cell_to_output_weights =
+ const TfLiteTensor* fw_cell_to_output_weights =
GetOptionalInputTensor(context, node, kFwCellToOutputWeightsTensor);
- TfLiteTensor* fw_input_gate_bias =
+ const TfLiteTensor* fw_input_gate_bias =
GetOptionalInputTensor(context, node, kFwInputGateBiasTensor);
const TfLiteTensor* fw_forget_gate_bias =
GetInput(context, node, kFwForgetGateBiasTensor);
const TfLiteTensor* fw_output_gate_bias =
GetInput(context, node, kFwOutputGateBiasTensor);
- TfLiteTensor* fw_projection_weights =
+ const TfLiteTensor* fw_projection_weights =
GetOptionalInputTensor(context, node, kFwProjectionWeightsTensor);
- TfLiteTensor* fw_projection_bias =
+ const TfLiteTensor* fw_projection_bias =
GetOptionalInputTensor(context, node, kFwProjectionBiasTensor);
TfLiteTensor* fw_output_state =
TfLiteTensor* fw_output = GetOutput(context, node, kFwOutputTensor);
// Tensors for the backward cell.
- TfLiteTensor* bw_input_to_input_weights =
+ const TfLiteTensor* bw_input_to_input_weights =
GetOptionalInputTensor(context, node, kBwInputToInputWeightsTensor);
const TfLiteTensor* bw_input_to_forget_weights =
GetInput(context, node, kBwInputToForgetWeightsTensor);
const TfLiteTensor* bw_input_to_output_weights =
GetInput(context, node, kBwInputToOutputWeightsTensor);
- TfLiteTensor* bw_recurrent_to_input_weights =
+ const TfLiteTensor* bw_recurrent_to_input_weights =
GetOptionalInputTensor(context, node, kBwRecurrentToInputWeightsTensor);
const TfLiteTensor* bw_recurrent_to_forget_weights =
GetInput(context, node, kBwRecurrentToForgetWeightsTensor);
const TfLiteTensor* bw_recurrent_to_output_weights =
GetInput(context, node, kBwRecurrentToOutputWeightsTensor);
- TfLiteTensor* bw_cell_to_input_weights =
+ const TfLiteTensor* bw_cell_to_input_weights =
GetOptionalInputTensor(context, node, kBwCellToInputWeightsTensor);
- TfLiteTensor* bw_cell_to_forget_weights =
+ const TfLiteTensor* bw_cell_to_forget_weights =
GetOptionalInputTensor(context, node, kBwCellToForgetWeightsTensor);
- TfLiteTensor* bw_cell_to_output_weights =
+ const TfLiteTensor* bw_cell_to_output_weights =
GetOptionalInputTensor(context, node, kBwCellToOutputWeightsTensor);
- TfLiteTensor* bw_input_gate_bias =
+ const TfLiteTensor* bw_input_gate_bias =
GetOptionalInputTensor(context, node, kBwInputGateBiasTensor);
const TfLiteTensor* bw_forget_gate_bias =
GetInput(context, node, kBwForgetGateBiasTensor);
const TfLiteTensor* bw_output_gate_bias =
GetInput(context, node, kBwOutputGateBiasTensor);
- TfLiteTensor* bw_projection_weights =
+ const TfLiteTensor* bw_projection_weights =
GetOptionalInputTensor(context, node, kBwProjectionWeightsTensor);
- TfLiteTensor* bw_projection_bias =
+ const TfLiteTensor* bw_projection_bias =
GetOptionalInputTensor(context, node, kBwProjectionBiasTensor);
TfLiteTensor* bw_output_state =
const TfLiteTensor* input = GetInput(context, node, kInputTensor);
const TfLiteTensor* filter = GetInput(context, node, kWeightsTensor);
- TfLiteTensor* bias = GetOptionalInputTensor(context, node, kBiasTensor);
+ const TfLiteTensor* bias = GetOptionalInputTensor(context, node, kBiasTensor);
TfLiteTensor* output = GetOutput(context, node, kOutputTensor);
// Check all the parameters of tensor match within themselves and match the
const TfLiteTensor* input = GetInput(context, node, kInputTensor);
const TfLiteTensor* filter = GetInput(context, node, kWeightsTensor);
- TfLiteTensor* bias = GetOptionalInputTensor(context, node, kBiasTensor);
+ const TfLiteTensor* bias = GetOptionalInputTensor(context, node, kBiasTensor);
TfLiteTensor* output = GetOutput(context, node, kOutputTensor);
switch (filter->type) { // Already know in/out types are same.
return count;
}
-inline TfLiteTensor* GetOptionalInputTensor(TfLiteContext* context,
- const TfLiteNode* node, int index) {
+inline const TfLiteTensor* GetOptionalInputTensor(TfLiteContext* context,
+ const TfLiteNode* node,
+ int index) {
const bool use_tensor = node->inputs->data[index] != kOptionalTensor;
if (use_tensor) {
return &context->tensors[node->inputs->data[index]];
TF_LITE_ENSURE(context, params->cell_clip >= 0);
TF_LITE_ENSURE(context, params->proj_clip >= 0);
- TfLiteTensor* input_to_input_weights =
+ const TfLiteTensor* input_to_input_weights =
GetOptionalInputTensor(context, node, kInputToInputWeightsTensor);
if (input_to_input_weights) {
TF_LITE_ENSURE_EQ(context, input_to_input_weights->dims->size, 2);
TF_LITE_ENSURE_EQ(context, input_to_cell_weights->dims->data[0], n_cell);
TF_LITE_ENSURE_EQ(context, input_to_cell_weights->dims->data[1], n_input);
- TfLiteTensor* recurrent_to_input_weights =
+ const TfLiteTensor* recurrent_to_input_weights =
GetOptionalInputTensor(context, node, kRecurrentToInputWeightsTensor);
if (recurrent_to_input_weights) {
TF_LITE_ENSURE_EQ(context, recurrent_to_input_weights->dims->size, 2);
(recurrent_to_input_weights == nullptr));
TF_LITE_ENSURE(context, cifg_weights_all_or_none == true);
- TfLiteTensor* cell_to_input_weights =
+ const TfLiteTensor* cell_to_input_weights =
GetOptionalInputTensor(context, node, kCellToInputWeightsTensor);
if (cell_to_input_weights) {
TF_LITE_ENSURE_EQ(context, cell_to_input_weights->dims->size, 1);
TF_LITE_ENSURE_EQ(context, cell_to_input_weights->dims->data[0], n_cell);
}
- TfLiteTensor* cell_to_forget_weights =
+ const TfLiteTensor* cell_to_forget_weights =
GetOptionalInputTensor(context, node, kCellToForgetWeightsTensor);
if (cell_to_forget_weights) {
TF_LITE_ENSURE_EQ(context, cell_to_forget_weights->dims->size, 1);
TF_LITE_ENSURE_EQ(context, cell_to_forget_weights->dims->data[0], n_cell);
}
- TfLiteTensor* cell_to_output_weights =
+ const TfLiteTensor* cell_to_output_weights =
GetOptionalInputTensor(context, node, kCellToOutputWeightsTensor);
if (cell_to_output_weights) {
TF_LITE_ENSURE_EQ(context, cell_to_output_weights->dims->size, 1);
TF_LITE_ENSURE(context, peephole_weights_all_or_none == true);
// Make sure the input gate bias is present only when not a CIFG-LSTM.
- TfLiteTensor* input_gate_bias =
+ const TfLiteTensor* input_gate_bias =
GetOptionalInputTensor(context, node, kInputGateBiasTensor);
if (use_cifg) {
TF_LITE_ENSURE_EQ(context, input_gate_bias, nullptr);
TF_LITE_ENSURE_EQ(context, output_gate_bias->dims->size, 1);
TF_LITE_ENSURE_EQ(context, output_gate_bias->dims->data[0], n_cell);
- TfLiteTensor* projection_weights =
+ const TfLiteTensor* projection_weights =
GetOptionalInputTensor(context, node, kProjectionWeightsTensor);
if (projection_weights) {
TF_LITE_ENSURE_EQ(context, projection_weights->dims->size, 2);
TF_LITE_ENSURE_EQ(context, projection_weights->dims->data[1], n_cell);
}
- TfLiteTensor* projection_bias =
+ const TfLiteTensor* projection_bias =
GetOptionalInputTensor(context, node, kProjectionBiasTensor);
if (projection_bias) {
TF_LITE_ENSURE_EQ(context, projection_bias->dims->size, 1);
output_state->allocation_type = kTfLiteArenaRwPersistent;
cell_state->allocation_type = kTfLiteArenaRwPersistent;
- TfLiteTensor* input_to_input_weights =
+ const TfLiteTensor* input_to_input_weights =
GetOptionalInputTensor(context, node, kInputToInputWeightsTensor);
const bool use_cifg = (input_to_input_weights == nullptr);
if (use_cifg) {
auto* params = reinterpret_cast<TfLiteLSTMParams*>(node->builtin_data);
const TfLiteTensor* input = GetInput(context, node, kInputTensor);
- TfLiteTensor* input_to_input_weights =
+ const TfLiteTensor* input_to_input_weights =
GetOptionalInputTensor(context, node, kInputToInputWeightsTensor);
const TfLiteTensor* input_to_forget_weights =
GetInput(context, node, kInputToForgetWeightsTensor);
const TfLiteTensor* input_to_output_weights =
GetInput(context, node, kInputToOutputWeightsTensor);
- TfLiteTensor* recurrent_to_input_weights =
+ const TfLiteTensor* recurrent_to_input_weights =
GetOptionalInputTensor(context, node, kRecurrentToInputWeightsTensor);
const TfLiteTensor* recurrent_to_forget_weights =
GetInput(context, node, kRecurrentToForgetWeightsTensor);
const TfLiteTensor* recurrent_to_output_weights =
GetInput(context, node, kRecurrentToOutputWeightsTensor);
- TfLiteTensor* cell_to_input_weights =
+ const TfLiteTensor* cell_to_input_weights =
GetOptionalInputTensor(context, node, kCellToInputWeightsTensor);
- TfLiteTensor* cell_to_forget_weights =
+ const TfLiteTensor* cell_to_forget_weights =
GetOptionalInputTensor(context, node, kCellToForgetWeightsTensor);
- TfLiteTensor* cell_to_output_weights =
+ const TfLiteTensor* cell_to_output_weights =
GetOptionalInputTensor(context, node, kCellToOutputWeightsTensor);
- TfLiteTensor* input_gate_bias =
+ const TfLiteTensor* input_gate_bias =
GetOptionalInputTensor(context, node, kInputGateBiasTensor);
const TfLiteTensor* forget_gate_bias =
GetInput(context, node, kForgetGateBiasTensor);
const TfLiteTensor* output_gate_bias =
GetInput(context, node, kOutputGateBiasTensor);
- TfLiteTensor* projection_weights =
+ const TfLiteTensor* projection_weights =
GetOptionalInputTensor(context, node, kProjectionWeightsTensor);
- TfLiteTensor* projection_bias =
+ const TfLiteTensor* projection_bias =
GetOptionalInputTensor(context, node, kProjectionBiasTensor);
TfLiteTensor* output_state = GetOutput(context, node, kOutputStateTensor);
output = GetOutput(context, node, 0);
dims = NumDimensions(input);
}
- TfLiteTensor* constant_values;
+ const TfLiteTensor* constant_values;
const TfLiteTensor* input;
const TfLiteTensor* paddings;
TfLiteTensor* output;
TF_LITE_ASSERT_EQ(input->dims->data[1], weights_feature->dims->data[1]);
TF_LITE_ASSERT_EQ(weights_time->dims->data[0], num_filters);
- TfLiteTensor* bias = GetOptionalInputTensor(context, node, kBiasTensor);
+ const TfLiteTensor* bias = GetOptionalInputTensor(context, node, kBiasTensor);
if (bias) {
TF_LITE_ASSERT_EQ(bias->dims->data[0], num_units);
}
TfLiteTensor* output = GetOutput(context, node, kOutputTensor);
TfLiteTensor* scratch = GetTemporary(context, node, /*index=*/0);
- TfLiteTensor* bias = GetOptionalInputTensor(context, node, kBiasTensor);
+ const TfLiteTensor* bias = GetOptionalInputTensor(context, node, kBiasTensor);
const int rank = params->rank;
const int batch_size = input->dims->data[0];
TF_LITE_ENSURE(context, params->cell_clip >= 0);
TF_LITE_ENSURE(context, params->proj_clip >= 0);
- TfLiteTensor* input_to_input_weights =
+ const TfLiteTensor* input_to_input_weights =
GetOptionalInputTensor(context, node, kInputToInputWeightsTensor);
if (input_to_input_weights) {
TF_LITE_ENSURE_EQ(context, input_to_input_weights->dims->size, 2);
TF_LITE_ENSURE_EQ(context, input_to_cell_weights->dims->data[0], n_cell);
TF_LITE_ENSURE_EQ(context, input_to_cell_weights->dims->data[1], n_input);
- TfLiteTensor* recurrent_to_input_weights =
+ const TfLiteTensor* recurrent_to_input_weights =
GetOptionalInputTensor(context, node, kRecurrentToInputWeightsTensor);
if (recurrent_to_input_weights) {
TF_LITE_ENSURE_EQ(context, recurrent_to_input_weights->dims->size, 2);
(recurrent_to_input_weights == nullptr));
TF_LITE_ENSURE(context, cifg_weights_all_or_none == true);
- TfLiteTensor* cell_to_input_weights =
+ const TfLiteTensor* cell_to_input_weights =
GetOptionalInputTensor(context, node, kCellToInputWeightsTensor);
if (cell_to_input_weights) {
TF_LITE_ENSURE_EQ(context, cell_to_input_weights->dims->size, 1);
TF_LITE_ENSURE_EQ(context, cell_to_input_weights->dims->data[0], n_cell);
}
- TfLiteTensor* cell_to_forget_weights =
+ const TfLiteTensor* cell_to_forget_weights =
GetOptionalInputTensor(context, node, kCellToForgetWeightsTensor);
if (cell_to_forget_weights) {
TF_LITE_ENSURE_EQ(context, cell_to_forget_weights->dims->size, 1);
TF_LITE_ENSURE_EQ(context, cell_to_forget_weights->dims->data[0], n_cell);
}
- TfLiteTensor* cell_to_output_weights =
+ const TfLiteTensor* cell_to_output_weights =
GetOptionalInputTensor(context, node, kCellToOutputWeightsTensor);
if (cell_to_output_weights) {
TF_LITE_ENSURE_EQ(context, cell_to_output_weights->dims->size, 1);
TF_LITE_ENSURE(context, peephole_weights_all_or_none == true);
// Make sure the input gate bias is present only when not a CIFG-LSTM.
- TfLiteTensor* input_gate_bias =
+ const TfLiteTensor* input_gate_bias =
GetOptionalInputTensor(context, node, kInputGateBiasTensor);
if (use_cifg) {
TF_LITE_ENSURE_EQ(context, input_gate_bias, nullptr);
TF_LITE_ENSURE_EQ(context, output_gate_bias->dims->size, 1);
TF_LITE_ENSURE_EQ(context, output_gate_bias->dims->data[0], n_cell);
- TfLiteTensor* projection_weights =
+ const TfLiteTensor* projection_weights =
GetOptionalInputTensor(context, node, kProjectionWeightsTensor);
if (projection_weights) {
TF_LITE_ENSURE_EQ(context, projection_weights->dims->size, 2);
TF_LITE_ENSURE_EQ(context, projection_weights->dims->data[1], n_cell);
}
- TfLiteTensor* projection_bias =
+ const TfLiteTensor* projection_bias =
GetOptionalInputTensor(context, node, kProjectionBiasTensor);
if (projection_bias) {
TF_LITE_ENSURE_EQ(context, projection_bias->dims->size, 1);
output_state->allocation_type = kTfLiteArenaRwPersistent;
cell_state->allocation_type = kTfLiteArenaRwPersistent;
- TfLiteTensor* input_to_input_weights =
+ const TfLiteTensor* input_to_input_weights =
GetOptionalInputTensor(context, node, kInputToInputWeightsTensor);
const bool use_cifg = (input_to_input_weights == nullptr);
if (use_cifg) {
auto* params = reinterpret_cast<TfLiteLSTMParams*>(node->builtin_data);
const TfLiteTensor* input = GetInput(context, node, kInputTensor);
- TfLiteTensor* input_to_input_weights =
+ const TfLiteTensor* input_to_input_weights =
GetOptionalInputTensor(context, node, kInputToInputWeightsTensor);
const TfLiteTensor* input_to_forget_weights =
GetInput(context, node, kInputToForgetWeightsTensor);
const TfLiteTensor* input_to_output_weights =
GetInput(context, node, kInputToOutputWeightsTensor);
- TfLiteTensor* recurrent_to_input_weights =
+ const TfLiteTensor* recurrent_to_input_weights =
GetOptionalInputTensor(context, node, kRecurrentToInputWeightsTensor);
const TfLiteTensor* recurrent_to_forget_weights =
GetInput(context, node, kRecurrentToForgetWeightsTensor);
const TfLiteTensor* recurrent_to_output_weights =
GetInput(context, node, kRecurrentToOutputWeightsTensor);
- TfLiteTensor* cell_to_input_weights =
+ const TfLiteTensor* cell_to_input_weights =
GetOptionalInputTensor(context, node, kCellToInputWeightsTensor);
- TfLiteTensor* cell_to_forget_weights =
+ const TfLiteTensor* cell_to_forget_weights =
GetOptionalInputTensor(context, node, kCellToForgetWeightsTensor);
- TfLiteTensor* cell_to_output_weights =
+ const TfLiteTensor* cell_to_output_weights =
GetOptionalInputTensor(context, node, kCellToOutputWeightsTensor);
- TfLiteTensor* input_gate_bias =
+ const TfLiteTensor* input_gate_bias =
GetOptionalInputTensor(context, node, kInputGateBiasTensor);
const TfLiteTensor* forget_gate_bias =
GetInput(context, node, kForgetGateBiasTensor);
const TfLiteTensor* output_gate_bias =
GetInput(context, node, kOutputGateBiasTensor);
- TfLiteTensor* projection_weights =
+ const TfLiteTensor* projection_weights =
GetOptionalInputTensor(context, node, kProjectionWeightsTensor);
- TfLiteTensor* projection_bias =
+ const TfLiteTensor* projection_bias =
GetOptionalInputTensor(context, node, kProjectionBiasTensor);
TfLiteTensor* output_state = GetOutput(context, node, kOutputStateTensor);