ArmNN
 22.05
ClBackendTests.cpp File Reference
#include <cl/ClBackend.hpp>
#include <cl/ClTensorHandleFactory.hpp>
#include <cl/ClImportTensorHandleFactory.hpp>
#include <cl/test/ClContextControlFixture.hpp>
#include <doctest/doctest.h>

Go to the source code of this file.

Functions

 TEST_SUITE ("ClBackendTests")
 

Function Documentation

◆ TEST_SUITE()

TEST_SUITE ( "ClBackendTests"  )

Definition at line 15 of file ClBackendTests.cpp.

References ClTensorHandleFactory::GetIdStatic(), ClImportTensorHandleFactory::GetIdStatic(), armnn::Malloc, and TEST_CASE_FIXTURE().

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()) ==
26  ClImportTensorHandleFactory::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()) ==
40  ClImportTensorHandleFactory::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()) ==
52  ClImportTensorHandleFactory::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()) ==
65  ClImportTensorHandleFactory::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()) ==
81  ClImportTensorHandleFactory::GetIdStatic()));
82 }
83 }
std::vector< BackendOptions > ModelOptions
TEST_CASE_FIXTURE(ClContextControlFixture, "CopyBetweenNeonAndGpu")