| 88 | } |
| 89 | |
| 90 | inline void EvalFloatSVDF(TfLiteContext* context, TfLiteNode* node, |
| 91 | const TfLiteTensor* input, |
| 92 | const TfLiteTensor* weights_feature, |
| 93 | const TfLiteTensor* weights_time, |
| 94 | const TfLiteTensor* bias, |
| 95 | const TfLiteSVDFParams* params, TfLiteTensor* scratch, |
| 96 | TfLiteTensor* state, TfLiteTensor* output) { |
| 97 | const int rank = params->rank; |
| 98 | const int batch_size = input->dims->data[0]; |
| 99 | const int input_size = input->dims->data[1]; |
| 100 | const int num_filters = weights_feature->dims->data[0]; |
| 101 | const int num_units = num_filters / rank; |
| 102 | const int memory_size = weights_time->dims->data[1]; |
| 103 | |
| 104 | // Clear the activation (state's leftmost column). |
| 105 | // TODO(ghodrat): Add a test which initialize activation_state with invalid |
| 106 | // values in leftmost column and make sure it passes. |
| 107 | for (int b = 0; b < batch_size; ++b) { |
| 108 | float* state_ptr_batch = |
| 109 | GetTensorData<float>(state) + b * memory_size * num_filters; |
| 110 | for (int c = 0; c < num_filters; ++c) { |
| 111 | float* state_ptr = state_ptr_batch + c * memory_size; |
| 112 | state_ptr[memory_size - 1] = 0.0f; |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | // Compute conv1d(inputs, weights_feature). |
| 117 | // The state's rightmost column is used to save current cycle activation. This |
| 118 | // is achieved by starting at GetTensorData<float>(state)[memory_size - 1] and |
| 119 | // having the stride equal to memory_size. |
| 120 | tensor_utils::MatrixBatchVectorMultiplyAccumulate( |
| 121 | GetTensorData<float>(weights_feature), num_filters, input_size, |
| 122 | GetTensorData<float>(input), batch_size, |
| 123 | &GetTensorData<float>(state)[memory_size - 1], memory_size); |
| 124 | |
| 125 | ApplyTimeWeightsBiasAndActivation(batch_size, memory_size, num_filters, |
| 126 | num_units, rank, weights_time, bias, |
| 127 | params->activation, state, scratch, output); |
| 128 | } |
| 129 | |
| 130 | inline void EvalHybridSVDF( |
| 131 | TfLiteContext* context, TfLiteNode* node, const TfLiteTensor* input, |
no test coverage detected