Remove unnecessary switch case from ArgMinMax kernel (#4033)
authorShubham Gupta/SNAP /SRI-Bangalore/Engineer/삼성전자 <shub98.gupta@samsung.com>
Fri, 14 Dec 2018 01:35:50 +0000 (07:05 +0530)
committer오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Fri, 14 Dec 2018 01:35:50 +0000 (10:35 +0900)
Since axis is always less than input rank and in Host file
there is already an assertion of axis<rank.
this switch case is not req and hence reducing the unnecessary
switch arithematic.

This patch will remove this unnecessary switch case and reducing code
redundancy.

Signed-off-by: shubham <shub98.gupta@samsung.com>
libs/ARMComputeEx/src/core/CL/cl_kernels/arg_min_max.cl

index c4172b0..00f627d 100644 (file)
@@ -71,22 +71,8 @@ __kernel void arg_max(TENSOR4D_DECLARATION(input),
       value = max(value, *((__global DATA_TYPE *)tensor4D_offset(&in, indices[0], indices[1], indices[2], indices[3])));
       if(tval!=value)
       {
-        switch(axis)
-        {
-          case 0: idx = indices[0];
-                  tval = value;
-                  break;
-          case 1: idx = indices[1];
-                  tval = value;
-                  break;
-          case 2: idx = indices[2];
-                  tval = value;
-                  break;
-          case 3: idx = indices[3];
-                  tval = value;
-                  break;
-          default: break;
-        }
+        idx = indices[axis];
+        tval = value;
       }
     }
 
@@ -148,22 +134,8 @@ __kernel void arg_min(TENSOR4D_DECLARATION(input),
       value = min(value, *((__global DATA_TYPE *)tensor4D_offset(&in, indices[0], indices[1], indices[2], indices[3])));
       if(tval!=value)
       {
-        switch(axis)
-        {
-          case 0: idx = indices[0];
-                  tval = value;
-                  break;
-          case 1: idx = indices[1];
-                  tval = value;
-                  break;
-          case 2: idx = indices[2];
-                  tval = value;
-                  break;
-          case 3: idx = indices[3];
-                  tval = value;
-                  break;
-          default: break;
-        }
+        idx = indices[axis];
+        tval = value;
       }
     }