aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Liang <joel.liang@arm.com>2017-12-28 10:09:51 +0800
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:42:33 +0000
commit1c5ffd612979d40730feecc4f43fa6c9f177f2e3 (patch)
tree510367ba70fcad4374d2cf9cdccdb3bc715c216c
parentc5a7e59655b61ad617fa34a4fb00e1a007c8255a (diff)
downloadComputeLibrary-1c5ffd612979d40730feecc4f43fa6c9f177f2e3.tar.gz
APPBROWSER-359: Sync tensor in GC benchmark tests
Change-Id: I22c1aa92e70d6143bbcec90e9e7de9f1ce1c1e55 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/114635 Tested-by: Jenkins <bsgcomp@arm.com> Reviewed-by: Pablo Tello <pablo.tello@arm.com>
-rw-r--r--arm_compute/core/GLES_COMPUTE/GCHelpers.h5
-rw-r--r--src/core/GLES_COMPUTE/kernels/GCGEMMInterleave4x4Kernel.cpp1
-rw-r--r--src/core/GLES_COMPUTE/kernels/GCGEMMMatrixAdditionKernel.cpp1
-rw-r--r--src/core/GLES_COMPUTE/kernels/GCGEMMMatrixMultiplyKernel.cpp1
-rw-r--r--src/runtime/GLES_COMPUTE/functions/GCGEMM.cpp1
-rw-r--r--tests/GLES_COMPUTE/Helper.h17
-rw-r--r--tests/Utils.h46
-rw-r--r--tests/benchmark/fixtures/ActivationLayerFixture.h6
-rw-r--r--tests/benchmark/fixtures/AlexNetFixture.h5
-rw-r--r--tests/benchmark/fixtures/BatchNormalizationLayerFixture.h18
-rw-r--r--tests/benchmark/fixtures/ConvolutionLayerFixture.h19
-rw-r--r--tests/benchmark/fixtures/DepthConcatenateLayerFixture.h6
-rw-r--r--tests/benchmark/fixtures/DepthwiseConvolutionLayerFixture.h6
-rw-r--r--tests/benchmark/fixtures/DepthwiseSeparableConvolutionLayerFixture.h6
-rw-r--r--tests/benchmark/fixtures/DequantizationLayerFixture.h6
-rw-r--r--tests/benchmark/fixtures/FlattenLayerFixture.h6
-rw-r--r--tests/benchmark/fixtures/FloorFixture.h6
-rw-r--r--tests/benchmark/fixtures/FullyConnectedLayerFixture.h19
-rw-r--r--tests/benchmark/fixtures/GEMMFixture.h6
-rw-r--r--tests/benchmark/fixtures/GEMMInterleave4x4Fixture.h6
-rw-r--r--tests/benchmark/fixtures/GEMMLowpFixture.h6
-rw-r--r--tests/benchmark/fixtures/L2NormalizeLayerFixture.h6
-rw-r--r--tests/benchmark/fixtures/LeNet5Fixture.h5
-rw-r--r--tests/benchmark/fixtures/MobileNetFixture.h5
-rw-r--r--tests/benchmark/fixtures/MobileNetV1Fixture.h5
-rw-r--r--tests/benchmark/fixtures/NormalizationLayerFixture.h6
-rw-r--r--tests/benchmark/fixtures/NormalizePlanarYUVLayerFixture.h18
-rw-r--r--tests/benchmark/fixtures/PoolingLayerFixture.h6
-rw-r--r--tests/benchmark/fixtures/QuantizationLayerFixture.h6
-rw-r--r--tests/benchmark/fixtures/ROIPoolingLayerFixture.h6
-rw-r--r--tests/benchmark/fixtures/ReshapeLayerFixture.h6
-rw-r--r--tests/benchmark/fixtures/ScaleFixture.h6
-rw-r--r--tests/benchmark/fixtures/ScaleLayerFixture.h19
-rw-r--r--tests/benchmark/fixtures/SoftmaxLayerFixture.h19
-rw-r--r--tests/benchmark/fixtures/TransposeFixture.h6
-rw-r--r--tests/framework/Framework.cpp23
-rw-r--r--tests/framework/Macros.h7
-rw-r--r--tests/framework/TestCase.h1
-rw-r--r--tests/networks/AlexNetNetwork.h7
-rw-r--r--tests/networks/LeNet5Network.h7
-rw-r--r--tests/networks/MobileNetNetwork.h7
-rw-r--r--tests/networks/MobileNetV1Network.h7
42 files changed, 255 insertions, 116 deletions
diff --git a/arm_compute/core/GLES_COMPUTE/GCHelpers.h b/arm_compute/core/GLES_COMPUTE/GCHelpers.h
index 475554f2be..8fbb5bbb2e 100644
--- a/arm_compute/core/GLES_COMPUTE/GCHelpers.h
+++ b/arm_compute/core/GLES_COMPUTE/GCHelpers.h
@@ -32,6 +32,8 @@
namespace arm_compute
{
+namespace gles_compute
+{
/** Helper function to create and return a unique_ptr pointed to a GLES kernel object
* It also calls the kernel's configuration.
*
@@ -60,5 +62,6 @@ std::unique_ptr<Kernel> create_kernel()
/** Max vector width of an GLES vector */
static constexpr unsigned int max_gc_vector_width = 16;
-}
+} // namespace gles_compute
+} // namespace arm_compute
#endif /* __ARM_COMPUTE_GCHELPERS_H__ */
diff --git a/src/core/GLES_COMPUTE/kernels/GCGEMMInterleave4x4Kernel.cpp b/src/core/GLES_COMPUTE/kernels/GCGEMMInterleave4x4Kernel.cpp
index 4bc6731064..ef47e7fd8c 100644
--- a/src/core/GLES_COMPUTE/kernels/GCGEMMInterleave4x4Kernel.cpp
+++ b/src/core/GLES_COMPUTE/kernels/GCGEMMInterleave4x4Kernel.cpp
@@ -35,6 +35,7 @@
#include "arm_compute/core/Window.h"
using namespace arm_compute;
+using namespace arm_compute::gles_compute;
GCGEMMInterleave4x4Kernel::GCGEMMInterleave4x4Kernel()
: _input(nullptr), _output(nullptr)
diff --git a/src/core/GLES_COMPUTE/kernels/GCGEMMMatrixAdditionKernel.cpp b/src/core/GLES_COMPUTE/kernels/GCGEMMMatrixAdditionKernel.cpp
index cf5d37811f..43846dcf32 100644
--- a/src/core/GLES_COMPUTE/kernels/GCGEMMMatrixAdditionKernel.cpp
+++ b/src/core/GLES_COMPUTE/kernels/GCGEMMMatrixAdditionKernel.cpp
@@ -34,6 +34,7 @@
#include "arm_compute/core/Window.h"
using namespace arm_compute;
+using namespace arm_compute::gles_compute;
GCGEMMMatrixAdditionKernel::GCGEMMMatrixAdditionKernel()
: _input(nullptr), _output(nullptr)
diff --git a/src/core/GLES_COMPUTE/kernels/GCGEMMMatrixMultiplyKernel.cpp b/src/core/GLES_COMPUTE/kernels/GCGEMMMatrixMultiplyKernel.cpp
index 8179525470..baf1a9b85e 100644
--- a/src/core/GLES_COMPUTE/kernels/GCGEMMMatrixMultiplyKernel.cpp
+++ b/src/core/GLES_COMPUTE/kernels/GCGEMMMatrixMultiplyKernel.cpp
@@ -40,6 +40,7 @@
#include <string>
using namespace arm_compute;
+using namespace arm_compute::gles_compute;
GCGEMMMatrixMultiplyKernel::GCGEMMMatrixMultiplyKernel()
: _input0(nullptr), _input1(nullptr), _output(nullptr)
diff --git a/src/runtime/GLES_COMPUTE/functions/GCGEMM.cpp b/src/runtime/GLES_COMPUTE/functions/GCGEMM.cpp
index c47a0e71fb..1c34c038b8 100644
--- a/src/runtime/GLES_COMPUTE/functions/GCGEMM.cpp
+++ b/src/runtime/GLES_COMPUTE/functions/GCGEMM.cpp
@@ -38,6 +38,7 @@
#include "arm_compute/runtime/ITensorAllocator.h"
using namespace arm_compute;
+using namespace arm_compute::gles_compute;
GCGEMM::GCGEMM()
: _interleave_kernel(), _transpose_kernel(), _mm_kernel(), _ma_kernel(), _tmp_a(), _tmp_b(), _is_interleaved_transposed(false), _run_addition(false)
diff --git a/tests/GLES_COMPUTE/Helper.h b/tests/GLES_COMPUTE/Helper.h
index 5f6460aa61..c2cd7c0dc8 100644
--- a/tests/GLES_COMPUTE/Helper.h
+++ b/tests/GLES_COMPUTE/Helper.h
@@ -91,23 +91,6 @@ inline void print_tensor(ITensor &tensor, const std::string &name, IOFormatInfo
std::cout << name << ":" << std::endl;
std::cout << s.str().c_str();
t.unmap();
-
- return;
-}
-
-/** Helper to sync tensor, if tensor is not used, GPU have optimized the operation.
- *
- * @param[in] tensor Tensor to be sync.
- *
- * @return Empty @ref GCTensor with the specified shape and data type.
- */
-inline void force_sync_tensor(ITensor &tensor)
-{
- IGCTensor &t = dynamic_cast<IGCTensor &>(tensor);
- t.map();
- t.unmap();
-
- return;
}
} // namespace gles_compute
} // namespace test
diff --git a/tests/Utils.h b/tests/Utils.h
index df1d7a543a..bee30af2e8 100644
--- a/tests/Utils.h
+++ b/tests/Utils.h
@@ -32,6 +32,16 @@
#include "arm_compute/core/Types.h"
#include "support/ToolchainSupport.h"
+#ifdef ARM_COMPUTE_CL
+#include "arm_compute/core/CL/OpenCL.h"
+#include "arm_compute/runtime/CL/CLScheduler.h"
+#endif /* ARM_COMPUTE_CL */
+
+#ifdef ARM_COMPUTE_GC
+#include "arm_compute/core/GLES_COMPUTE/OpenGLES.h"
+#include "arm_compute/runtime/GLES_COMPUTE/GCTensor.h"
+#endif /* ARM_COMPUTE_GC */
+
#include <cmath>
#include <cstddef>
#include <limits>
@@ -44,6 +54,9 @@
namespace arm_compute
{
+#ifdef ARM_COMPUTE_CL
+class CLTensor;
+#endif /* ARM_COMPUTE_CL */
namespace test
{
/** Round floating-point value with half value rounding to positive infinity.
@@ -566,6 +579,39 @@ inline std::string get_typestring(DataType data_type)
ARM_COMPUTE_ERROR("NOT SUPPORTED!");
}
}
+
+/** Sync if necessary.
+ */
+template <typename TensorType>
+inline void sync_if_necessary()
+{
+#ifdef ARM_COMPUTE_CL
+ if(opencl_is_available() && std::is_same<typename std::decay<TensorType>::type, arm_compute::CLTensor>::value)
+ {
+ CLScheduler::get().sync();
+ }
+#endif /* ARM_COMPUTE_CL */
+}
+
+/** Sync tensor if necessary.
+ *
+ * @note: If the destination tensor not being used on OpenGL ES, GPU will optimize out the operation.
+ *
+ * @param[in] tensor Tensor to be sync.
+ */
+template <typename TensorType>
+inline void sync_tensor_if_necessary(TensorType &tensor)
+{
+#ifdef ARM_COMPUTE_GC
+ if(opengles31_is_available() && std::is_same<typename std::decay<TensorType>::type, arm_compute::GCTensor>::value)
+ {
+ // Force sync the tensor by calling map and unmap.
+ IGCTensor &t = dynamic_cast<IGCTensor &>(tensor);
+ t.map();
+ t.unmap();
+ }
+#endif /* ARM_COMPUTE_GC */
+}
} // namespace test
} // namespace arm_compute
#endif /* __ARM_COMPUTE_TEST_UTILS_H__ */
diff --git a/tests/benchmark/fixtures/ActivationLayerFixture.h b/tests/benchmark/fixtures/ActivationLayerFixture.h
index 9ded063a37..11fabf8765 100644
--- a/tests/benchmark/fixtures/ActivationLayerFixture.h
+++ b/tests/benchmark/fixtures/ActivationLayerFixture.h
@@ -66,6 +66,12 @@ public:
act_layer.run();
}
+ void sync()
+ {
+ sync_if_necessary<TensorType>();
+ sync_tensor_if_necessary<TensorType>(dst);
+ }
+
void teardown()
{
src.allocator()->free();
diff --git a/tests/benchmark/fixtures/AlexNetFixture.h b/tests/benchmark/fixtures/AlexNetFixture.h
index 961f4e889f..a543ba2af2 100644
--- a/tests/benchmark/fixtures/AlexNetFixture.h
+++ b/tests/benchmark/fixtures/AlexNetFixture.h
@@ -65,6 +65,11 @@ public:
network.run();
}
+ void sync()
+ {
+ network.sync();
+ }
+
void teardown()
{
network.clear();
diff --git a/tests/benchmark/fixtures/BatchNormalizationLayerFixture.h b/tests/benchmark/fixtures/BatchNormalizationLayerFixture.h
index 55411a44d1..5f32e77e55 100644
--- a/tests/benchmark/fixtures/BatchNormalizationLayerFixture.h
+++ b/tests/benchmark/fixtures/BatchNormalizationLayerFixture.h
@@ -29,12 +29,6 @@
#include "tests/Globals.h"
#include "tests/Utils.h"
#include "tests/framework/Fixture.h"
-#ifdef ARM_COMPUTE_GC
-#include "arm_compute/runtime/GLES_COMPUTE/GCScheduler.h"
-#include "tests/GLES_COMPUTE/Helper.h"
-
-using namespace arm_compute::test::gles_compute;
-#endif /* ARM_COMPUTE_GC */
namespace arm_compute
{
@@ -82,12 +76,12 @@ public:
void run()
{
batch_norm_layer.run();
-#ifdef ARM_COMPUTE_GC
- if(opengles31_is_available() && std::is_same<typename std::decay<TensorType>::type, arm_compute::GCTensor>::value)
- {
- force_sync_tensor(dst);
- }
-#endif /* ARM_COMPUTE_GC */
+ }
+
+ void sync()
+ {
+ sync_if_necessary<TensorType>();
+ sync_tensor_if_necessary<TensorType>(dst);
}
void teardown()
diff --git a/tests/benchmark/fixtures/ConvolutionLayerFixture.h b/tests/benchmark/fixtures/ConvolutionLayerFixture.h
index b526cc3870..403160782d 100644
--- a/tests/benchmark/fixtures/ConvolutionLayerFixture.h
+++ b/tests/benchmark/fixtures/ConvolutionLayerFixture.h
@@ -30,13 +30,6 @@
#include "tests/Utils.h"
#include "tests/framework/Fixture.h"
-#ifdef ARM_COMPUTE_GC
-#include "arm_compute/runtime/GLES_COMPUTE/GCScheduler.h"
-#include "tests/GLES_COMPUTE/Helper.h"
-
-using namespace arm_compute::test::gles_compute;
-#endif /* ARM_COMPUTE_GC */
-
namespace arm_compute
{
namespace test
@@ -78,12 +71,12 @@ public:
void run()
{
conv_layer.run();
-#ifdef ARM_COMPUTE_GC
- if(opengles31_is_available() && std::is_same<typename std::decay<TensorType>::type, arm_compute::GCTensor>::value)
- {
- force_sync_tensor(dst);
- }
-#endif /* ARM_COMPUTE_GC */
+ }
+
+ void sync()
+ {
+ sync_if_necessary<TensorType>();
+ sync_tensor_if_necessary<TensorType>(dst);
}
void teardown()
diff --git a/tests/benchmark/fixtures/DepthConcatenateLayerFixture.h b/tests/benchmark/fixtures/DepthConcatenateLayerFixture.h
index 221f34c6fd..523a41b8be 100644
--- a/tests/benchmark/fixtures/DepthConcatenateLayerFixture.h
+++ b/tests/benchmark/fixtures/DepthConcatenateLayerFixture.h
@@ -123,6 +123,12 @@ public:
_depth_concat.run();
}
+ void sync()
+ {
+ sync_if_necessary<TensorType>();
+ sync_tensor_if_necessary<TensorType>(_dst);
+ }
+
void teardown()
{
for(auto &src : _srcs)
diff --git a/tests/benchmark/fixtures/DepthwiseConvolutionLayerFixture.h b/tests/benchmark/fixtures/DepthwiseConvolutionLayerFixture.h
index 19ebb4e3dd..d505ba3006 100644
--- a/tests/benchmark/fixtures/DepthwiseConvolutionLayerFixture.h
+++ b/tests/benchmark/fixtures/DepthwiseConvolutionLayerFixture.h
@@ -72,6 +72,12 @@ public:
depth_conv.run();
}
+ void sync()
+ {
+ sync_if_necessary<TensorType>();
+ sync_tensor_if_necessary<TensorType>(dst);
+ }
+
void teardown()
{
src.allocator()->free();
diff --git a/tests/benchmark/fixtures/DepthwiseSeparableConvolutionLayerFixture.h b/tests/benchmark/fixtures/DepthwiseSeparableConvolutionLayerFixture.h
index fa1544042f..c841996c6c 100644
--- a/tests/benchmark/fixtures/DepthwiseSeparableConvolutionLayerFixture.h
+++ b/tests/benchmark/fixtures/DepthwiseSeparableConvolutionLayerFixture.h
@@ -83,6 +83,12 @@ public:
depth_sep_conv_layer.run();
}
+ void sync()
+ {
+ sync_if_necessary<TensorType>();
+ sync_tensor_if_necessary<TensorType>(dst);
+ }
+
void teardown()
{
src.allocator()->free();
diff --git a/tests/benchmark/fixtures/DequantizationLayerFixture.h b/tests/benchmark/fixtures/DequantizationLayerFixture.h
index 30e05f9c3b..4251a96881 100644
--- a/tests/benchmark/fixtures/DequantizationLayerFixture.h
+++ b/tests/benchmark/fixtures/DequantizationLayerFixture.h
@@ -73,6 +73,12 @@ public:
dequantization_func.run();
}
+ void sync()
+ {
+ sync_if_necessary<TensorType>();
+ sync_tensor_if_necessary<TensorType>(dst);
+ }
+
void teardown()
{
src.allocator()->free();
diff --git a/tests/benchmark/fixtures/FlattenLayerFixture.h b/tests/benchmark/fixtures/FlattenLayerFixture.h
index 67f5f01781..f6e44a2101 100644
--- a/tests/benchmark/fixtures/FlattenLayerFixture.h
+++ b/tests/benchmark/fixtures/FlattenLayerFixture.h
@@ -68,6 +68,12 @@ public:
flatten_func.run();
}
+ void sync()
+ {
+ sync_if_necessary<TensorType>();
+ sync_tensor_if_necessary<TensorType>(dst);
+ }
+
void teardown()
{
src.allocator()->free();
diff --git a/tests/benchmark/fixtures/FloorFixture.h b/tests/benchmark/fixtures/FloorFixture.h
index 8de87b886b..b6bb89642d 100644
--- a/tests/benchmark/fixtures/FloorFixture.h
+++ b/tests/benchmark/fixtures/FloorFixture.h
@@ -62,6 +62,12 @@ public:
floor_func.run();
}
+ void sync()
+ {
+ sync_if_necessary<TensorType>();
+ sync_tensor_if_necessary<TensorType>(dst);
+ }
+
void teardown()
{
src.allocator()->free();
diff --git a/tests/benchmark/fixtures/FullyConnectedLayerFixture.h b/tests/benchmark/fixtures/FullyConnectedLayerFixture.h
index ef08c4ad8b..08c2ef9104 100644
--- a/tests/benchmark/fixtures/FullyConnectedLayerFixture.h
+++ b/tests/benchmark/fixtures/FullyConnectedLayerFixture.h
@@ -30,13 +30,6 @@
#include "tests/Utils.h"
#include "tests/framework/Fixture.h"
-#ifdef ARM_COMPUTE_GC
-#include "arm_compute/runtime/GLES_COMPUTE/GCScheduler.h"
-#include "tests/GLES_COMPUTE/Helper.h"
-
-using namespace arm_compute::test::gles_compute;
-#endif /* ARM_COMPUTE_GC */
-
namespace arm_compute
{
namespace test
@@ -78,12 +71,12 @@ public:
void run()
{
fc_layer.run();
-#ifdef ARM_COMPUTE_GC
- if(opengles31_is_available() && std::is_same<typename std::decay<TensorType>::type, arm_compute::GCTensor>::value)
- {
- force_sync_tensor(dst);
- }
-#endif /* ARM_COMPUTE_GC */
+ }
+
+ void sync()
+ {
+ sync_if_necessary<TensorType>();
+ sync_tensor_if_necessary<TensorType>(dst);
}
void teardown()
diff --git a/tests/benchmark/fixtures/GEMMFixture.h b/tests/benchmark/fixtures/GEMMFixture.h
index 0c41c67af1..d1eded074c 100644
--- a/tests/benchmark/fixtures/GEMMFixture.h
+++ b/tests/benchmark/fixtures/GEMMFixture.h
@@ -69,6 +69,12 @@ public:
gemm.run();
}
+ void sync()
+ {
+ sync_if_necessary<TensorType>();
+ sync_tensor_if_necessary<TensorType>(dst);
+ }
+
void teardown()
{
a.allocator()->free();
diff --git a/tests/benchmark/fixtures/GEMMInterleave4x4Fixture.h b/tests/benchmark/fixtures/GEMMInterleave4x4Fixture.h
index e55e092240..293ceff5d1 100644
--- a/tests/benchmark/fixtures/GEMMInterleave4x4Fixture.h
+++ b/tests/benchmark/fixtures/GEMMInterleave4x4Fixture.h
@@ -69,6 +69,12 @@ public:
gemm.run();
}
+ void sync()
+ {
+ sync_if_necessary<TensorType>();
+ sync_tensor_if_necessary<TensorType>(b);
+ }
+
void teardown()
{
a.allocator()->free();
diff --git a/tests/benchmark/fixtures/GEMMLowpFixture.h b/tests/benchmark/fixtures/GEMMLowpFixture.h
index 4bd7dfd42f..1b64591191 100644
--- a/tests/benchmark/fixtures/GEMMLowpFixture.h
+++ b/tests/benchmark/fixtures/GEMMLowpFixture.h
@@ -72,6 +72,12 @@ public:
gemmlowp.run();
}
+ void sync()
+ {
+ sync_if_necessary<TensorType>();
+ sync_tensor_if_necessary<TensorType>(c);
+ }
+
void teardown()
{
a.allocator()->free();
diff --git a/tests/benchmark/fixtures/L2NormalizeLayerFixture.h b/tests/benchmark/fixtures/L2NormalizeLayerFixture.h
index 296a2e9fac..ae5b1a1cd3 100644
--- a/tests/benchmark/fixtures/L2NormalizeLayerFixture.h
+++ b/tests/benchmark/fixtures/L2NormalizeLayerFixture.h
@@ -64,6 +64,12 @@ public:
l2norm_func.run();
}
+ void sync()
+ {
+ sync_if_necessary<TensorType>();
+ sync_tensor_if_necessary<TensorType>(dst);
+ }
+
void teardown()
{
src.allocator()->free();
diff --git a/tests/benchmark/fixtures/LeNet5Fixture.h b/tests/benchmark/fixtures/LeNet5Fixture.h
index 77a09d3025..191daa2aff 100644
--- a/tests/benchmark/fixtures/LeNet5Fixture.h
+++ b/tests/benchmark/fixtures/LeNet5Fixture.h
@@ -57,6 +57,11 @@ public:
network.run();
}
+ void sync()
+ {
+ network.sync();
+ }
+
void teardown()
{
network.clear();
diff --git a/tests/benchmark/fixtures/MobileNetFixture.h b/tests/benchmark/fixtures/MobileNetFixture.h
index 660205c7ec..165b269b59 100644
--- a/tests/benchmark/fixtures/MobileNetFixture.h
+++ b/tests/benchmark/fixtures/MobileNetFixture.h
@@ -58,6 +58,11 @@ public:
network.run();
}
+ void sync()
+ {
+ network.sync();
+ }
+
void teardown()
{
network.clear();
diff --git a/tests/benchmark/fixtures/MobileNetV1Fixture.h b/tests/benchmark/fixtures/MobileNetV1Fixture.h
index 07333dde0e..54b0d09a32 100644
--- a/tests/benchmark/fixtures/MobileNetV1Fixture.h
+++ b/tests/benchmark/fixtures/MobileNetV1Fixture.h
@@ -61,6 +61,11 @@ public:
network.run();
}
+ void sync()
+ {
+ network.sync();
+ }
+
void teardown()
{
network.clear();
diff --git a/tests/benchmark/fixtures/NormalizationLayerFixture.h b/tests/benchmark/fixtures/NormalizationLayerFixture.h
index 41dd8a7b27..cbe20d59da 100644
--- a/tests/benchmark/fixtures/NormalizationLayerFixture.h
+++ b/tests/benchmark/fixtures/NormalizationLayerFixture.h
@@ -66,6 +66,12 @@ public:
norm_layer.run();
}
+ void sync()
+ {
+ sync_if_necessary<TensorType>();
+ sync_tensor_if_necessary<TensorType>(dst);
+ }
+
void teardown()
{
src.allocator()->free();
diff --git a/tests/benchmark/fixtures/NormalizePlanarYUVLayerFixture.h b/tests/benchmark/fixtures/NormalizePlanarYUVLayerFixture.h
index 92343534dc..a84aa26023 100644
--- a/tests/benchmark/fixtures/NormalizePlanarYUVLayerFixture.h
+++ b/tests/benchmark/fixtures/NormalizePlanarYUVLayerFixture.h
@@ -29,12 +29,6 @@
#include "tests/Globals.h"
#include "tests/Utils.h"
#include "tests/framework/Fixture.h"
-#ifdef ARM_COMPUTE_GC
-#include "arm_compute/runtime/GLES_COMPUTE/GCScheduler.h"
-#include "tests/GLES_COMPUTE/Helper.h"
-
-using namespace arm_compute::test::gles_compute;
-#endif /* ARM_COMPUTE_GC */
namespace arm_compute
{
@@ -75,12 +69,12 @@ public:
void run()
{
normalize_planar_yuv_layer.run();
-#ifdef ARM_COMPUTE_GC
- if(opengles31_is_available() && std::is_same<typename std::decay<TensorType>::type, arm_compute::GCTensor>::value)
- {
- force_sync_tensor(dst);
- }
-#endif /* ARM_COMPUTE_GC */
+ }
+
+ void sync()
+ {
+ sync_if_necessary<TensorType>();
+ sync_tensor_if_necessary<TensorType>(dst);
}
void teardown()
diff --git a/tests/benchmark/fixtures/PoolingLayerFixture.h b/tests/benchmark/fixtures/PoolingLayerFixture.h
index 2060301531..47deda93ec 100644
--- a/tests/benchmark/fixtures/PoolingLayerFixture.h
+++ b/tests/benchmark/fixtures/PoolingLayerFixture.h
@@ -67,6 +67,12 @@ public:
pool_layer.run();
}
+ void sync()
+ {
+ sync_if_necessary<TensorType>();
+ sync_tensor_if_necessary<TensorType>(dst);
+ }
+
void teardown()
{
src.allocator()->free();
diff --git a/tests/benchmark/fixtures/QuantizationLayerFixture.h b/tests/benchmark/fixtures/QuantizationLayerFixture.h
index 5981f9995c..0843962edf 100644
--- a/tests/benchmark/fixtures/QuantizationLayerFixture.h
+++ b/tests/benchmark/fixtures/QuantizationLayerFixture.h
@@ -63,6 +63,12 @@ public:
quantization_func.run();
}
+ void sync()
+ {
+ sync_if_necessary<TensorType>();
+ sync_tensor_if_necessary<TensorType>(dst);
+ }
+
void teardown()
{
src.allocator()->free();
diff --git a/tests/benchmark/fixtures/ROIPoolingLayerFixture.h b/tests/benchmark/fixtures/ROIPoolingLayerFixture.h
index 76c2280b74..9013218712 100644
--- a/tests/benchmark/fixtures/ROIPoolingLayerFixture.h
+++ b/tests/benchmark/fixtures/ROIPoolingLayerFixture.h
@@ -78,6 +78,12 @@ public:
roi_pool.run();
}
+ void sync()
+ {
+ sync_if_necessary<TensorType>();
+ sync_tensor_if_necessary<TensorType>(dst);
+ }
+
void teardown()
{
src.allocator()->free();
diff --git a/tests/benchmark/fixtures/ReshapeLayerFixture.h b/tests/benchmark/fixtures/ReshapeLayerFixture.h
index 4f65e9d6c5..b92377c58c 100644
--- a/tests/benchmark/fixtures/ReshapeLayerFixture.h
+++ b/tests/benchmark/fixtures/ReshapeLayerFixture.h
@@ -64,6 +64,12 @@ public:
reshape_func.run();
}
+ void sync()
+ {
+ sync_if_necessary<TensorType>();
+ sync_tensor_if_necessary<TensorType>(dst);
+ }
+
void teardown()
{
src.allocator()->free();
diff --git a/tests/benchmark/fixtures/ScaleFixture.h b/tests/benchmark/fixtures/ScaleFixture.h
index 1ba191be5a..21a6391953 100644
--- a/tests/benchmark/fixtures/ScaleFixture.h
+++ b/tests/benchmark/fixtures/ScaleFixture.h
@@ -81,6 +81,12 @@ public:
scale_func.run();
}
+ void sync()
+ {
+ sync_if_necessary<TensorType>();
+ sync_tensor_if_necessary<TensorType>(dst);
+ }
+
void teardown()
{
src.allocator()->free();
diff --git a/tests/benchmark/fixtures/ScaleLayerFixture.h b/tests/benchmark/fixtures/ScaleLayerFixture.h
index 94cc678b7f..f34a0033c1 100644
--- a/tests/benchmark/fixtures/ScaleLayerFixture.h
+++ b/tests/benchmark/fixtures/ScaleLayerFixture.h
@@ -31,13 +31,6 @@
#include "tests/framework/Asserts.h"
#include "tests/framework/Fixture.h"
-#ifdef ARM_COMPUTE_GC
-#include "arm_compute/runtime/GLES_COMPUTE/GCScheduler.h"
-#include "tests/GLES_COMPUTE/Helper.h"
-
-using namespace arm_compute::test::gles_compute;
-#endif /* ARM_COMPUTE_GC */
-
namespace arm_compute
{
namespace test
@@ -83,12 +76,12 @@ public:
void run()
{
scale_layer.run();
-#ifdef ARM_COMPUTE_GC
- if(opengles31_is_available() && std::is_same<typename std::decay<TensorType>::type, arm_compute::GCTensor>::value)
- {
- force_sync_tensor(dst);
- }
-#endif /* ARM_COMPUTE_GC */
+ }
+
+ void sync()
+ {
+ sync_if_necessary<TensorType>();
+ sync_tensor_if_necessary<TensorType>(dst);
}
void teardown()
diff --git a/tests/benchmark/fixtures/SoftmaxLayerFixture.h b/tests/benchmark/fixtures/SoftmaxLayerFixture.h
index 50b272621e..f3657daf75 100644
--- a/tests/benchmark/fixtures/SoftmaxLayerFixture.h
+++ b/tests/benchmark/fixtures/SoftmaxLayerFixture.h
@@ -31,13 +31,6 @@
#include "tests/framework/Asserts.h"
#include "tests/framework/Fixture.h"
-#ifdef ARM_COMPUTE_GC
-#include "arm_compute/runtime/GLES_COMPUTE/GCScheduler.h"
-#include "tests/GLES_COMPUTE/Helper.h"
-
-using namespace arm_compute::test::gles_compute;
-#endif /* ARM_COMPUTE_GC */
-
namespace arm_compute
{
namespace test
@@ -73,12 +66,12 @@ public:
void run()
{
smx_layer.run();
-#ifdef ARM_COMPUTE_GC
- if(opengles31_is_available() && std::is_same<typename std::decay<TensorType>::type, arm_compute::GCTensor>::value)
- {
- force_sync_tensor(dst);
- }
-#endif /* ARM_COMPUTE_GC */
+ }
+
+ void sync()
+ {
+ sync_if_necessary<TensorType>();
+ sync_tensor_if_necessary<TensorType>(dst);
}
void teardown()
diff --git a/tests/benchmark/fixtures/TransposeFixture.h b/tests/benchmark/fixtures/TransposeFixture.h
index 19d2194f63..bc2d6d613e 100644
--- a/tests/benchmark/fixtures/TransposeFixture.h
+++ b/tests/benchmark/fixtures/TransposeFixture.h
@@ -67,6 +67,12 @@ public:
transpose.run();
}
+ void sync()
+ {
+ sync_if_necessary<TensorType>();
+ sync_tensor_if_necessary<TensorType>(dst);
+ }
+
void teardown()
{
src.allocator()->free();
diff --git a/tests/framework/Framework.cpp b/tests/framework/Framework.cpp
index d1fb28d501..79a77d9e5e 100644
--- a/tests/framework/Framework.cpp
+++ b/tests/framework/Framework.cpp
@@ -25,16 +25,6 @@
#include "support/ToolchainSupport.h"
-#ifdef ARM_COMPUTE_CL
-#include "arm_compute/core/CL/OpenCL.h"
-#include "arm_compute/runtime/CL/CLScheduler.h"
-#endif /* ARM_COMPUTE_CL */
-
-#ifdef ARM_COMPUTE_GC
-#include "arm_compute/core/GLES_COMPUTE/OpenGLES.h"
-#include "arm_compute/runtime/GLES_COMPUTE/GCScheduler.h"
-#endif /* ARM_COMPUTE_GC */
-
#include <chrono>
#include <iostream>
#include <sstream>
@@ -310,18 +300,7 @@ void Framework::run_test(const TestInfo &info, TestCaseFactory &test_factory)
profiler.start();
}
test_case->do_run();
-#ifdef ARM_COMPUTE_CL
- if(opencl_is_available())
- {
- CLScheduler::get().sync();
- }
-#endif /* ARM_COMPUTE_CL */
-#ifdef ARM_COMPUTE_GC
- if(opengles31_is_available())
- {
- GCScheduler::get().sync();
- }
-#endif /* ARM_COMPUTE_GC */
+ test_case->do_sync();
if(_num_iterations == 1 || i != 0)
{
profiler.stop();
diff --git a/tests/framework/Macros.h b/tests/framework/Macros.h
index 7aabb75cfc..deca1ef51a 100644
--- a/tests/framework/Macros.h
+++ b/tests/framework/Macros.h
@@ -114,6 +114,11 @@
{ \
FIXTURE::run(); \
}
+#define FIXTURE_SYNC(FIXTURE) \
+ void do_sync() override \
+ { \
+ FIXTURE::sync(); \
+ }
#define FIXTURE_TEARDOWN(FIXTURE) \
void do_teardown() override \
{ \
@@ -223,6 +228,7 @@
TEST_CASE_CONSTRUCTOR(TEST_NAME) \
FIXTURE_SETUP(FIXTURE) \
FIXTURE_RUN(FIXTURE) \
+ FIXTURE_SYNC(FIXTURE) \
FIXTURE_TEARDOWN(FIXTURE) \
}; \
TEST_REGISTRAR(TEST_NAME, MODE, STATUS)
@@ -244,6 +250,7 @@
DATA_TEST_CASE_CONSTRUCTOR(TEST_NAME, DATASET) \
FIXTURE_DATA_SETUP(FIXTURE) \
FIXTURE_RUN(FIXTURE) \
+ FIXTURE_SYNC(FIXTURE) \
FIXTURE_TEARDOWN(FIXTURE) \
}; \
DATA_TEST_REGISTRAR(TEST_NAME, MODE, STATUS, DATASET)
diff --git a/tests/framework/TestCase.h b/tests/framework/TestCase.h
index dbb9312dee..18dd12e442 100644
--- a/tests/framework/TestCase.h
+++ b/tests/framework/TestCase.h
@@ -42,6 +42,7 @@ class TestCase
public:
virtual void do_setup() {};
virtual void do_run() {};
+ virtual void do_sync() {};
virtual void do_teardown() {};
/** Default destructor. */
diff --git a/tests/networks/AlexNetNetwork.h b/tests/networks/AlexNetNetwork.h
index 448cf31914..819111f897 100644
--- a/tests/networks/AlexNetNetwork.h
+++ b/tests/networks/AlexNetNetwork.h
@@ -564,6 +564,13 @@ public:
smx.run();
}
+ /** Sync the results */
+ void sync()
+ {
+ sync_if_necessary<TensorType>();
+ sync_tensor_if_necessary<TensorType>(output);
+ }
+
private:
struct DirectConv
{
diff --git a/tests/networks/LeNet5Network.h b/tests/networks/LeNet5Network.h
index f8aac30807..a46489f88c 100644
--- a/tests/networks/LeNet5Network.h
+++ b/tests/networks/LeNet5Network.h
@@ -230,6 +230,13 @@ public:
smx.run();
}
+ /** Sync the results */
+ void sync()
+ {
+ sync_if_necessary<TensorType>();
+ sync_tensor_if_necessary<TensorType>(output);
+ }
+
private:
unsigned int _batches{ 0 };
diff --git a/tests/networks/MobileNetNetwork.h b/tests/networks/MobileNetNetwork.h
index 1bc8ad9a0c..8c3cb1fb2d 100644
--- a/tests/networks/MobileNetNetwork.h
+++ b/tests/networks/MobileNetNetwork.h
@@ -251,6 +251,13 @@ public:
reshape.run();
}
+ /** Sync the results */
+ void sync()
+ {
+ sync_if_necessary<TensorType>();
+ sync_tensor_if_necessary<TensorType>(output);
+ }
+
private:
void depthwise_conv_block_init(unsigned int idx, unsigned int ifm, unsigned int ofm)
{
diff --git a/tests/networks/MobileNetV1Network.h b/tests/networks/MobileNetV1Network.h
index dbe3f491f0..0957c6b555 100644
--- a/tests/networks/MobileNetV1Network.h
+++ b/tests/networks/MobileNetV1Network.h
@@ -300,6 +300,13 @@ public:
smx.run();
}
+ /** Sync the results */
+ void sync()
+ {
+ sync_if_necessary<TensorType>();
+ sync_tensor_if_necessary<TensorType>(output);
+ }
+
private:
void depthwise_conv_block_init(unsigned int idx, unsigned int ifm, unsigned int ofm)
{