6 #include <arm_compute/runtime/CL/functions/CLActivationLayer.h> 18 #include <doctest/doctest.h> 20 using namespace armnn;
28 ClWorkloadFactoryHelper::GetTensorHandleFactory(ClWorkloadFactoryHelper::GetMemoryManager());
35 std::vector<float> inputData
47 arm_compute::CLTensor& tensor = PolymorphicDowncast<ClTensorHandle*>(handle.get())->GetTensor();
51 CHECK((iclTensorProxy.
info() == tensor.info()));
52 CHECK((iclTensorProxy.
buffer() == tensor.buffer()));
53 CHECK((iclTensorProxy.
cl_buffer() == tensor.cl_buffer()));
54 CHECK((iclTensorProxy.
quantization().scale == tensor.quantization().scale));
55 CHECK((iclTensorProxy.
quantization().offset == tensor.quantization().offset));
62 ClWorkloadFactoryHelper::GetTensorHandleFactory(ClWorkloadFactoryHelper::GetMemoryManager());
65 unsigned int numElements =
info.GetNumElements();
70 std::vector<float> inputData
77 std::vector<float> ExpectedOutput
89 arm_compute::CLTensor& tensor = PolymorphicDowncast<ClTensorHandle*>(handle.get())->GetTensor();
92 std::unique_ptr<ICLTensorProxy> iclTensorProxy;
93 iclTensorProxy = std::make_unique<ICLTensorProxy>(&tensor);
96 const arm_compute::ActivationLayerInfo act_info(arm_compute::ActivationLayerInfo::ActivationFunction::RELU);
97 arm_compute::CLActivationLayer act_func;
98 act_func.configure(iclTensorProxy.get(),
nullptr, act_info);
101 arm_compute::CLScheduler::get().sync();
103 std::vector<float> actualOutput(
info.GetNumElements());
108 for(
unsigned int i = 0; i < numElements; ++i)
110 CHECK((actualOutput[i] == ExpectedOutput[i]));
120 arm_compute::CLTensor& importTensor = PolymorphicDowncast<ClImportTensorHandle*>(importHandle.get())->GetTensor();
123 const size_t totalBytes = importTensor.info()->total_size();
124 const size_t alignment =
125 arm_compute::CLKernelLibrary::get().get_device().getInfo<CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE>();
126 size_t space = totalBytes + alignment + alignment;
127 auto testData = std::make_unique<uint8_t[]>(space);
128 void* alignedPtr = testData.get();
129 CHECK(std::align(alignment, totalBytes, alignedPtr, space));
135 auto* typedPtr =
reinterpret_cast<float*
>(alignedPtr);
136 std::fill_n(typedPtr, numElements, -5.0f);
139 iclTensorProxy->set(&importTensor);
143 arm_compute::CLScheduler::get().sync();
146 for(
unsigned int i = 0; i < numElements; ++i)
148 CHECK(typedPtr[i] == 0);
TEST_SUITE("TestConstTensorLayerVisitor")
Copyright (c) 2021 ARM Limited and Contributors.
arm_compute::CLQuantization quantization() const
TEST_CASE_FIXTURE(ClContextControlFixture, "CopyBetweenNeonAndGpu")
std::unique_ptr< ITensorHandle > CreateTensorHandle(const TensorInfo &tensorInfo) const override
void CopyDataFromITensorHandle(void *mem, const armnn::ITensorHandle *tensorHandle)
const cl::Buffer & cl_buffer() const
This factory creates ClImportTensorHandles that refer to imported memory tensors. ...
void CopyDataToITensorHandle(armnn::ITensorHandle *tensorHandle, const void *memory)
arm_compute::ITensorInfo * info() const
std::unique_ptr< ITensorHandle > CreateTensorHandle(const TensorInfo &tensorInfo) const override