nn: fix compatability with tensorflow 2.4.0

BUG=chromium:1162396
TEST=FEATURES=test emerge-betty aosp-frameworks-ml-nn

Cq-Depend: chromium:2607025
Change-Id: I643dd554a24f1a50923d4edcb5211a8d1d5e45f4
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/frameworks/ml/+/2612994
Tested-by: Jim Pollock <jmpollock@chromium.org>
Tested-by: Xinglong Luan <alanlxl@chromium.org>
Auto-Submit: Jim Pollock <jmpollock@chromium.org>
Reviewed-by: Xinglong Luan <alanlxl@chromium.org>
Reviewed-by: Michael Pishchagin <mblsha@google.com>
Commit-Queue: Xinglong Luan <alanlxl@chromium.org>
diff --git a/nn/common/operations/Activation.cpp b/nn/common/operations/Activation.cpp
index ff5a55d..6488cbf 100644
--- a/nn/common/operations/Activation.cpp
+++ b/nn/common/operations/Activation.cpp
@@ -258,7 +258,6 @@
         return false;
     }
 
-    int numElements = getNumberOfElements(inputShape);
     static constexpr int kInputIntegerBits = 4;
 
     const double input_real_multiplier =
@@ -274,7 +273,9 @@
 
     NNTRACE_COMP_SWITCH("reference_integer_ops::Tanh");
     tflite::reference_integer_ops::Tanh(inputShape.offset, input_range_radius, input_multiplier,
-                                        input_left_shift, numElements, inputData, outputData);
+                                        input_left_shift,
+                                        convertShapeToTflshape(inputShape), inputData,
+                                        convertShapeToTflshape(outputShape), outputData);
 
     return true;
 }
diff --git a/nn/common/operations/LSTM.cpp b/nn/common/operations/LSTM.cpp
index 942ff4a..a94df71 100644
--- a/nn/common/operations/LSTM.cpp
+++ b/nn/common/operations/LSTM.cpp
@@ -940,8 +940,7 @@
                 cell_scratch, input_gate_scratch, n_batch * n_cell, cell_state_out_buffer);
     }
     if (params.cell_clip > 0.0) {
-        tflite::tensor_utils::ClipVector(cell_state_out_buffer, n_batch * n_cell, params.cell_clip,
-                                         cell_state_out_buffer);
+        tflite::tensor_utils::CwiseClipping(cell_state_out_buffer, n_batch * n_cell, params.cell_clip);
     }
 
     // For each batch and cell: update the output gate.
@@ -978,8 +977,7 @@
                 projection_weights_buffer, n_output, n_cell, output_gate_scratch, n_batch,
                 output_buffer);
         if (params.proj_clip > 0.0) {
-            tflite::tensor_utils::ClipVector(output_buffer, n_batch * n_output, params.proj_clip,
-                                             output_buffer);
+            tflite::tensor_utils::CwiseClipping(output_buffer, n_batch * n_output, params.proj_clip);
         }
     } else {
         std::copy_n(output_gate_scratch, n_batch * n_output, output_buffer);