ArmNN
 22.05.01
ClBackendTests.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2022 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include <cl/ClBackend.hpp>
10 
11 #include <doctest/doctest.h>
12 
13 using namespace armnn;
14 
15 TEST_SUITE("ClBackendTests")
16 {
17 TEST_CASE("ClRegisterTensorHandleFactoriesMatchingImportFactoryId")
18 {
19  auto clBackend = std::make_unique<ClBackend>();
21  clBackend->RegisterTensorHandleFactories(registry);
22 
23  // When calling RegisterTensorHandleFactories, CopyAndImportFactoryPair is registered
24  // Get ClImportTensorHandleFactory id as the matching import factory id
25  CHECK((registry.GetMatchingImportFactoryId(ClTensorHandleFactory::GetIdStatic()) ==
27 }
28 
29 TEST_CASE("ClRegisterTensorHandleFactoriesWithMemorySourceFlagsMatchingImportFactoryId")
30 {
31  auto clBackend = std::make_unique<ClBackend>();
33  clBackend->RegisterTensorHandleFactories(registry,
34  static_cast<MemorySourceFlags>(MemorySource::Malloc),
35  static_cast<MemorySourceFlags>(MemorySource::Malloc));
36 
37  // When calling RegisterTensorHandleFactories with MemorySourceFlags, CopyAndImportFactoryPair is registered
38  // Get ClImportTensorHandleFactory id as the matching import factory id
39  CHECK((registry.GetMatchingImportFactoryId(ClTensorHandleFactory::GetIdStatic()) ==
41 }
42 
43 TEST_CASE_FIXTURE(ClContextControlFixture, "ClCreateWorkloadFactoryMatchingImportFactoryId")
44 {
45  auto clBackend = std::make_unique<ClBackend>();
47  clBackend->CreateWorkloadFactory(registry);
48 
49  // When calling CreateWorkloadFactory, CopyAndImportFactoryPair is registered
50  // Get ClImportTensorHandleFactory id as the matching import factory id
51  CHECK((registry.GetMatchingImportFactoryId(ClTensorHandleFactory::GetIdStatic()) ==
53 }
54 
55 TEST_CASE_FIXTURE(ClContextControlFixture, "ClCreateWorkloadFactoryWithOptionsMatchingImportFactoryId")
56 {
57  auto clBackend = std::make_unique<ClBackend>();
59  ModelOptions modelOptions;
60  clBackend->CreateWorkloadFactory(registry, modelOptions);
61 
62  // When calling CreateWorkloadFactory with ModelOptions, CopyAndImportFactoryPair is registered
63  // Get ClImportTensorHandleFactory id as the matching import factory id
64  CHECK((registry.GetMatchingImportFactoryId(ClTensorHandleFactory::GetIdStatic()) ==
66 }
67 
68 TEST_CASE_FIXTURE(ClContextControlFixture, "ClCreateWorkloadFactoryWitMemoryFlagsMatchingImportFactoryId")
69 {
70  auto clBackend = std::make_unique<ClBackend>();
72  ModelOptions modelOptions;
73  clBackend->CreateWorkloadFactory(registry, modelOptions,
74  static_cast<MemorySourceFlags>(MemorySource::Malloc),
75  static_cast<MemorySourceFlags>(MemorySource::Malloc));
76 
77  // When calling CreateWorkloadFactory with ModelOptions and MemorySourceFlags,
78  // CopyAndImportFactoryPair is registered
79  // Get ClImportTensorHandleFactory id as the matching import factory id
80  CHECK((registry.GetMatchingImportFactoryId(ClTensorHandleFactory::GetIdStatic()) ==
82 }
83 }
TEST_SUITE("TestConstTensorLayerVisitor")
static const FactoryId & GetIdStatic()
std::vector< BackendOptions > ModelOptions
Copyright (c) 2021 ARM Limited and Contributors.
TEST_CASE_FIXTURE(ClContextControlFixture, "CopyBetweenNeonAndGpu")