aboutsummaryrefslogtreecommitdiff
path: root/tests/validation/CL/UNIT/dynamic_fusion/ClCompositeKernel.cpp
blob: cb365901da30a52608a8a809270dcd39bcae9646 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
/*
 * Copyright (c) 2022 Arm Limited.
 *
 * SPDX-License-Identifier: MIT
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to
 * deal in the Software without restriction, including without limitation the
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 * sell copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
#if defined(ENABLE_EXPERIMENTAL_DYNAMIC_FUSION)

#include "src/gpu/cl/kernels/experimental/dynamic_fusion/ClCompositeKernel.h"

#include "src/core/utils/helpers/float_ops.h"
#include "src/gpu/cl/kernels/ClElementwiseKernel.h"
#include "src/gpu/cl/kernels/ClGemmMatrixMultiplyNativeKernel.h"
#include "tests/CL/CLAccessor.h"
#include "tests/framework/Macros.h"
#include "tests/framework/datasets/Datasets.h"
#include "tests/validation/Validation.h"
#include "tests/validation/reference/ElementwiseOperations.h"
#include "tests/validation/reference/GEMM.h"

#include "arm_compute/core/utils/misc/ShapeCalculator.h"
#include "src/core/AccessWindowStatic.h"
#include "src/core/helpers/AutoConfiguration.h"
#include "src/core/helpers/WindowHelpers.h"

#include <chrono>

using namespace arm_compute::experimental::dynamic_fusion;

namespace arm_compute
{
namespace test
{
namespace validation
{
namespace
{
/** Macros which measures the wall clock time, and records it into a map measurement_map with name clock_name */
#define TICK(clock_name) \
    auto clock_name##_tick = std::chrono::high_resolution_clock::now();
#define TOCK(clock_name, measurement_map)                                               \
    auto clock_name##_tock                 = std::chrono::high_resolution_clock::now(); \
    measurement_map["\"" #clock_name "\""] = duration_cast<microseconds>(clock_name##_tock - clock_name##_tick);
#define TOCK_AVG(clock_name, measurement_map, num_iterations)                           \
    auto clock_name##_tock                 = std::chrono::high_resolution_clock::now(); \
    measurement_map["\"" #clock_name "\""] = duration_cast<microseconds>((clock_name##_tock - clock_name##_tick) / (num_iterations));

template <typename T, typename U>
void fill(U &&tensor, int seed)
{
    static_assert(std::is_floating_point<T>::value || std::is_same<T, half>::value, "Only floating point data types supported.");
    using DistributionType = typename std::conditional<std::is_same<T, half>::value, arm_compute::utils::uniform_real_distribution_16bit<T>, std::uniform_real_distribution<T>>::type;

    DistributionType distribution{ T(-1.0f), T(1.0f) };
    library->fill(tensor, distribution, seed);

    // Fill border with infinity in order to check the presence of NaN values (i.e. inf * 0)
    DistributionType distribution_inf{ T(std::numeric_limits<float>::infinity()), T(std::numeric_limits<float>::infinity()) };
    library->fill_borders_with_garbage(tensor, distribution_inf, seed);
}
} // namespace

TEST_SUITE(CL)
TEST_SUITE(UNIT)
TEST_SUITE(DYNAMIC_FUSION)
TEST_SUITE(ClCompositeKernel)
TEST_SUITE(Validate)

TEST_CASE(MoveNet_SubGraph_1, framework::DatasetMode::ALL)
{
    /* Computation:
     * out = add(addend, gemm_native(lhs, rhs, bias)) (non-broadcast)
     */
    const auto data_type   = DataType::F32;
    const auto m           = 5U;
    const auto n           = 4U;
    const auto k           = 3U;
    const auto t_lhs_shape = TensorShape(k, m);
    const auto t_rhs_shape = TensorShape(n, k);
    const auto t_dst_shape = TensorShape(n, m);
    auto       t_lhs_info  = TensorInfo(t_lhs_shape, 1, data_type);
    auto       t_rhs_info  = TensorInfo(t_rhs_shape, 1, data_type);
    auto       t_bias_info = TensorInfo(TensorShape(), 1, DataType::F32);
    auto       t_dst_info  = TensorInfo(t_dst_shape, 1, data_type);

    const ClTensorDescriptor t_lhs_desc{ &t_lhs_info, 2 };
    const ClTensorDescriptor t_rhs_desc{ &t_rhs_info, 2 };
    const ClTensorDescriptor t_bias_desc{ &t_bias_info, 2 };
    const ClTensorDescriptor t_addend_desc{ &t_dst_info, 2 };
    const ClTensorDescriptor t_dst_desc{ &t_dst_info, 2 };

    ClKernelBlueprint bp;
    ArgumentID        tid_lhs;
    ArgumentID        tid_rhs;
    ArgumentID        tid_l0_bias = g_arg_placeholder;
    ArgumentID        tid_l1_addend;
    ArgumentID        tid_dst;
    auto              st = add_tensor_argument(bp, t_lhs_desc, tid_lhs);
    st                   = add_tensor_argument(bp, t_rhs_desc, tid_rhs);
    st                   = add_tensor_argument(bp, t_addend_desc, tid_l1_addend);
    st                   = add_tensor_argument(bp, t_dst_desc, tid_dst);

    const auto                 common_kernel_desc = ClKernelComponentDescriptor{};
    const GemmNativeDescriptor gemm_native_desc{ 1.0, 1.0, m, n, k };
    const GEMMKernelInfo       gemm_info{ m, n, k, 0, false, false, false, false, ActivationLayerInfo{}, 1, 1, gemm_native_desc.lhs_info, gemm_native_desc.rhs_info, 0, 0 };
    const EltwiseAddDescriptor eltwise_add_desc{ ConvertPolicy::WRAP };
    const TileDescriptor       store_tile_info{ Size2D(gemm_info.rhs_info.n0, gemm_info.lhs_info.m0), Size2D(gemm_info.n, gemm_info.m), ClippingStrategy::TOP_LEFT };

    ArgumentID tid_acc;
    st = add_tensor_intermed(bp, tid_acc);
    st = add_kcomp_gemm_native(bp, common_kernel_desc, gemm_native_desc, tid_lhs, tid_rhs, tid_l0_bias, tid_acc);
    st = add_kcomp_eltwise_add(bp, common_kernel_desc, EltwiseAddDescriptor{}, tid_l1_addend, tid_acc, tid_acc);
    st = add_kcomp_store(bp, common_kernel_desc, tid_acc, tid_dst, StoreType::StoreBlockBoundaryAware);

    ClKernelCode cl_code;

    st = set_tile_info(bp, store_tile_info);
    st = build(cl_code, ClCodeBuilderContext{ GpuInfo{ GPUTarget::G71 } }, bp);

    ClExecutionDescriptor exec_desc;
    st = tune_static(exec_desc, cl_code);

    CLScheduler::get().default_init();
    ClCompositeKernel kernel;
    kernel.configure(CLKernelLibrary::get().get_compile_context(), cl_code);

    // Construct tensors
    CLTensor t_lhs{};
    CLTensor t_rhs{};
    CLTensor t_l1_addend{};
    CLTensor t_dst{};
    // Init tensors
    {
        t_lhs.allocator()->init(t_lhs_info);
        t_rhs.allocator()->init(t_rhs_info);
        t_l1_addend.allocator()->init(t_dst_info);
        t_dst.allocator()->init(t_dst_info);
    }
    // "Pack" tensors
    TensorBinding tensors({ { tid_lhs, &t_lhs },
        { tid_rhs, &t_rhs },
        { tid_l1_addend, &t_l1_addend },
        { tid_dst, &t_dst }
    });
    // Allocate and fill tensors
    {
        t_lhs.allocator()->allocate();
        t_rhs.allocator()->allocate();
        t_l1_addend.allocator()->allocate();
        t_dst.allocator()->allocate();
        fill<float>(CLAccessor(t_lhs), 0);
        fill<float>(CLAccessor(t_rhs), 1);
        fill<float>(CLAccessor(t_l1_addend), 2);
    }

    CLScheduler::get().enqueue_op(kernel, tensors, exec_desc, true);

    // Create reference
    SimpleTensor<float> ref_t_lhs{ t_lhs_shape, data_type, 1 };
    SimpleTensor<float> ref_t_rhs{ t_rhs_shape, data_type, 1 };
    SimpleTensor<float> ref_t_bias_placeholder{ t_dst_shape, data_type, 1 };
    SimpleTensor<float> ref_t_l1_addend{ t_dst_shape, data_type, 1 };

    // Fill reference
    fill<float>(ref_t_lhs, 0);
    fill<float>(ref_t_rhs, 1);
    fill<float>(ref_t_l1_addend, 2);
    const auto ref_t_dst = reference::arithmetic_operation(
                               ArithmeticOperation::ADD,
                               ref_t_l1_addend,
                               reference::gemm(ref_t_lhs, ref_t_rhs, ref_t_bias_placeholder, gemm_native_desc.alpha, 0.f /* To disable bias */),
                               data_type,
                               eltwise_add_desc.convert_policy);

    RelativeTolerance<float> tolerance_f32(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for floating point data types */
    validate(CLAccessor(t_dst), ref_t_dst, tolerance_f32);
}

TEST_SUITE_END() // Validate

TEST_SUITE(Benchmark)
TEST_CASE(MoveNet_SubGraph_1, framework::DatasetMode::ALL)
{
    using std::chrono::duration_cast;
    using std::chrono::microseconds;
    const int num_iterations = 200;
    std::map<std::string, std::chrono::microseconds> measurements;
    /* Computation:
     * out = add(addend, gemm_native(lhs, rhs, bias))
     */
    const auto         data_type     = DataType::F32;
    const unsigned int m             = 12 * 12;
    const unsigned int n             = 64;
    const unsigned int k             = 384;
    const auto         t_lhs_shape   = TensorShape(k, m);
    const auto         t_rhs_shape   = TensorShape(n, k);
    const auto         t_dst_shape   = TensorShape(n, m);
    auto               t_lhs_info    = TensorInfo(t_lhs_shape, 1, data_type);
    auto               t_rhs_info    = TensorInfo(t_rhs_shape, 1, data_type);
    auto               t_bias_info   = TensorInfo(TensorShape(), 1, data_type);
    auto               t_l0_dst_info = TensorInfo(t_dst_shape, 1, data_type); // Intermediate tensor for cond3
    auto               t_l1_rhs_info = TensorInfo(t_dst_shape, 1, data_type);
    auto               t_dst_info    = TensorInfo(t_dst_shape, 1, data_type);

    const auto                 common_kernel_desc = ClKernelComponentDescriptor{};
    const GemmNativeDescriptor gemm_native_desc{ 1.0, 0.0, m, n, k };
    const GEMMKernelInfo       gemm_info{ m, n, k, 0, false, false, false, false, ActivationLayerInfo{}, 1, 1, gemm_native_desc.lhs_info, gemm_native_desc.rhs_info, 0, 0 };
    const EltwiseAddDescriptor eltwise_add_desc{ ConvertPolicy::WRAP };
    const TileDescriptor       store_tile_info{ Size2D(gemm_info.rhs_info.n0, gemm_info.lhs_info.m0), Size2D(gemm_info.n, gemm_info.m), ClippingStrategy::TOP_LEFT };

    // Create reference
    SimpleTensor<float> ref_t_lhs{ t_lhs_shape, data_type, 1 };
    SimpleTensor<float> ref_t_rhs{ t_rhs_shape, data_type, 1 };
    SimpleTensor<float> ref_t_bias_placeholder{ t_dst_shape, data_type, 1 };
    SimpleTensor<float> ref_t_l1_addend{ t_dst_shape, data_type, 1 };

    // Fill reference
    fill<float>(ref_t_lhs, 0);
    fill<float>(ref_t_rhs, 1);
    fill<float>(ref_t_l1_addend, 2);
    const auto ref_t_dst = reference::arithmetic_operation(
                               ArithmeticOperation::ADD,
                               ref_t_l1_addend,
                               reference::gemm(ref_t_lhs, ref_t_rhs, ref_t_bias_placeholder, gemm_native_desc.alpha, 0.f /* To disable bias */),
                               data_type,
                               eltwise_add_desc.convert_policy);

    CLScheduler::get().default_init();

    /* Condition 0: Dynamic Fused Kernel */
    CLTensor cond0_t_dst{};
    {
        TICK(cond0_0_startup_time);

        ClKernelBlueprint bp;
        ArgumentID        tid_lhs;
        ArgumentID        tid_rhs;
        ArgumentID        tid_l0_bias = g_arg_placeholder;
        ArgumentID        tid_l1_addend;
        ArgumentID        tid_dst;

        const ClTensorDescriptor t_lhs_desc{ &t_lhs_info, 2 };
        const ClTensorDescriptor t_rhs_desc{ &t_rhs_info, 2 };
        const ClTensorDescriptor t_bias_desc{ &t_bias_info, 2 };
        const ClTensorDescriptor t_addend_desc{ &t_dst_info, 2 };
        const ClTensorDescriptor t_dst_desc{ &t_dst_info, 2 };

        ClKernelCode cl_code;
        TICK(cond0_build_time)
        auto st = add_tensor_argument(bp, t_lhs_desc, tid_lhs);
        st      = add_tensor_argument(bp, t_rhs_desc, tid_rhs);
        st      = add_tensor_argument(bp, t_addend_desc, tid_l1_addend);
        st      = add_tensor_argument(bp, t_dst_desc, tid_dst);

        ArgumentID tid_acc;
        st = add_tensor_intermed(bp, tid_acc);
        st = add_kcomp_gemm_native(bp, common_kernel_desc, gemm_native_desc, tid_lhs, tid_rhs, tid_l0_bias, tid_acc);

        st = add_kcomp_eltwise_add(bp, common_kernel_desc, EltwiseAddDescriptor{}, tid_l1_addend, tid_acc, tid_acc);

        st = add_kcomp_store(bp, common_kernel_desc, tid_acc, tid_dst, StoreType::StoreBlockBoundaryAware);

        st = set_tile_info(bp, store_tile_info);
        st = build(cl_code, ClCodeBuilderContext{ GpuInfo{ GPUTarget::G71 } }, bp);
        TOCK(cond0_build_time, measurements)

        TICK(cond0_tune_time)
        ClExecutionDescriptor exec_desc;
        st = tune_static(exec_desc, cl_code);
        TOCK(cond0_tune_time, measurements)

        TICK(cond0_configure_time)
        ClCompositeKernel kernel;
        kernel.configure(CLKernelLibrary::get().get_compile_context(), cl_code);
        TOCK(cond0_configure_time, measurements)

        // Construct tensors
        CLTensor t_lhs{};
        CLTensor t_rhs{};
        CLTensor t_l1_addend{};

        // Init tensors
        {
            t_lhs.allocator()->init(t_lhs_info);
            t_rhs.allocator()->init(t_rhs_info);
            t_l1_addend.allocator()->init(t_dst_info);
            cond0_t_dst.allocator()->init(t_dst_info);
        }
        // Allocate tensors
        {
            t_lhs.allocator()->allocate();
            t_rhs.allocator()->allocate();
            t_l1_addend.allocator()->allocate();
            cond0_t_dst.allocator()->allocate();
            fill<float>(CLAccessor(t_lhs), 0);
            fill<float>(CLAccessor(t_rhs), 1);
            fill<float>(CLAccessor(t_l1_addend), 2);
        }

        // "Pack" tensors
        TensorBinding tensors({ { tid_lhs, &t_lhs }, { tid_rhs, &t_rhs }, { tid_l1_addend, &t_l1_addend }, { tid_dst, &cond0_t_dst } });

        CLScheduler::get().enqueue_op(kernel, tensors, exec_desc, true);
        CLScheduler::get().sync();
        TOCK(cond0_0_startup_time, measurements)

        TICK(cond0_1_latency)
        for(int i = 0; i < num_iterations; ++i)
        {
            CLScheduler::get().enqueue_op(kernel, tensors, exec_desc, true);
        }
        CLScheduler::get().sync();
        TOCK_AVG(cond0_1_latency, measurements, num_iterations)
    }
    /* Condition 1: Dynamic Unfused Kernel */
    /* Condition 2: Static Fused Kernel (current) */
    CLTensor cond2_t_dst{};
    {
        TICK(cond2_0_startup_time);
        arm_compute::opencl::kernels::ClGemmMatrixMultiplyNativeKernel l0_gemm_mm;

        TICK(cond2_configure_time);
        experimental::PostOpList<ITensorInfo *> post_ops;
        post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo *>>(&t_dst_info, 1, eltwise_add_desc.convert_policy);
        GEMMKernelInfo gemm_info{ m, n, k, 0, false, false, false, false, ActivationLayerInfo{}, 1, 1, gemm_native_desc.lhs_info, gemm_native_desc.rhs_info, 0, 0, post_ops };
        l0_gemm_mm.configure(CLKernelLibrary::get().get_compile_context(), &t_lhs_info, &t_rhs_info, nullptr, &t_dst_info, gemm_native_desc.alpha, gemm_native_desc.beta, gemm_native_desc.lhs_info,
                             gemm_native_desc.rhs_info, gemm_info);
        TOCK(cond2_configure_time, measurements);

        // Construct tensors
        CLTensor t_lhs{};
        CLTensor t_rhs{};
        CLTensor t_l1_addend{};

        // Init tensors
        {
            t_lhs.allocator()->init(t_lhs_info);
            t_rhs.allocator()->init(t_rhs_info);
            t_l1_addend.allocator()->init(t_dst_info);
            cond2_t_dst.allocator()->init(t_dst_info);
        }
        // Allocate tensors
        {
            t_lhs.allocator()->allocate();
            t_rhs.allocator()->allocate();
            t_l1_addend.allocator()->allocate();
            cond2_t_dst.allocator()->allocate();
            fill<float>(CLAccessor(t_lhs), 0);
            fill<float>(CLAccessor(t_rhs), 1);
            fill<float>(CLAccessor(t_l1_addend), 2);
        }

        // "Pack" tensors
        ITensorPack tensors
        {
            { ACL_SRC_0, &t_lhs },
            { ACL_SRC_1, &t_rhs },
            { EXPERIMENTAL_ACL_POST_OP_ARG_FIRST, &t_l1_addend },
            { ACL_DST, &cond2_t_dst },
        };
        CLScheduler::get().enqueue_op(l0_gemm_mm, tensors, true);
        CLScheduler::get().sync();
        TOCK(cond2_0_startup_time, measurements);

        TICK(cond2_1_latency);
        for(int i = 0; i < num_iterations; ++i)
        {
            CLScheduler::get().enqueue_op(l0_gemm_mm, tensors, true);
        }
        CLScheduler::get().sync();
        TOCK_AVG(cond2_1_latency, measurements, num_iterations);
    }
    /* Condition 3: Static Unfused Kernel (current) */
    CLTensor cond3_t_dst{};
    {
        TICK(cond3_0_startup_time);
        arm_compute::opencl::kernels::ClGemmMatrixMultiplyNativeKernel l0_gemm_mm;
        arm_compute::opencl::kernels::ClSaturatedArithmeticKernel      l1_add;

        TICK(cond3_configure_time);
        GEMMKernelInfo gemm_info{ m, n, k, 0, false, false, false, false, ActivationLayerInfo{}, 1, 1, gemm_native_desc.lhs_info, gemm_native_desc.rhs_info, 0, 0 };
        l0_gemm_mm.configure(CLKernelLibrary::get().get_compile_context(), &t_lhs_info, &t_rhs_info, nullptr, &t_l0_dst_info, gemm_native_desc.alpha, gemm_native_desc.beta, gemm_native_desc.lhs_info,
                             gemm_native_desc.rhs_info, gemm_info);
        l1_add.configure(CLKernelLibrary::get().get_compile_context(), ArithmeticOperation::ADD, &t_l0_dst_info, &t_l1_rhs_info, &t_dst_info, eltwise_add_desc.convert_policy);
        TOCK(cond3_configure_time, measurements);

        // Construct tensors
        CLTensor t_lhs{};
        CLTensor t_rhs{};
        CLTensor t_l0_dst{};
        CLTensor t_l1_addend{};

        // Init tensors
        {
            t_lhs.allocator()->init(t_lhs_info);
            t_rhs.allocator()->init(t_rhs_info);
            t_l0_dst.allocator()->init(t_l0_dst_info);
            t_l1_addend.allocator()->init(t_dst_info);
            cond3_t_dst.allocator()->init(t_dst_info);
        }
        // Allocate tensors
        {
            t_lhs.allocator()->allocate();
            t_rhs.allocator()->allocate();
            t_l0_dst.allocator()->allocate();
            t_l1_addend.allocator()->allocate();
            cond3_t_dst.allocator()->allocate();
            fill<float>(CLAccessor(t_lhs), 0);
            fill<float>(CLAccessor(t_rhs), 1);
            fill<float>(CLAccessor(t_l1_addend), 2);
        }

        // "Pack" tensors
        ITensorPack tensors_l0
        {
            { ACL_SRC_0, &t_lhs },
            { ACL_SRC_1, &t_rhs },
            { ACL_DST, &t_l0_dst },
        };
        ITensorPack tensors_l1
        {
            { ACL_SRC_0, &t_l0_dst },
            { ACL_SRC_1, &t_l1_addend },
            { ACL_DST, &cond3_t_dst },
        };
        CLScheduler::get().enqueue_op(l0_gemm_mm, tensors_l0, true);
        CLScheduler::get().enqueue_op(l1_add, tensors_l1, true);
        CLScheduler::get().sync();
        TOCK(cond3_0_startup_time, measurements);

        TICK(cond3_1_latency);
        for(int i = 0; i < num_iterations; ++i)
        {
            CLScheduler::get().enqueue_op(l0_gemm_mm, tensors_l0, true);
            CLScheduler::get().enqueue_op(l1_add, tensors_l1, true);
        }
        CLScheduler::get().sync();
        TOCK_AVG(cond3_1_latency, measurements, num_iterations);
    }

    RelativeTolerance<float> tolerance_f32(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for floating point data types */
    std::cout << "cond0 validation: " << std::endl;
    validate(CLAccessor(cond0_t_dst), ref_t_dst, tolerance_f32);
    std::cout << "cond2 validation: " << std::endl;
    validate(CLAccessor(cond2_t_dst), ref_t_dst, tolerance_f32);
    std::cout << "cond3 validation: " << std::endl;
    validate(CLAccessor(cond3_t_dst), ref_t_dst, tolerance_f32);

    /* Report */
    std::cout << "Performance comparison (gemm native + add)" << std::endl;
    std::cout << "cond0: dynamic fusion module" << std::endl;
    std::cout << "cond2: static fused with post ops" << std::endl;
    std::cout << "cond3: static unfused" << std::endl;
    for(auto m : measurements)
    {
        std::cout << m.first << ": " << m.second.count() << "us" << std::endl;
    }
}
TEST_SUITE_END() // Benchmark
TEST_SUITE_END() // ClCompositeKernel
TEST_SUITE_END() // DYNAMIC_FUSION
TEST_SUITE_END() // UNIT
TEST_SUITE_END() // CL
} // namespace validation
} // namespace test
} // namespace arm_compute

#endif // defined(ENABLE_EXPERIMENTAL_DYNAMIC_FUSION)