blob: d47663671eb0e0b5f5a56625f7a9161277a76d1c [file] [log] [blame]
telsoa014fcda012018-03-09 14:13:49 +00001//
Teresa Charlin588cbdf2022-01-19 15:55:37 +00002// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
telsoa014fcda012018-03-09 14:13:49 +00004//
5
6#pragma once
7
Teresa Charlin588cbdf2022-01-19 15:55:37 +00008#include "ClBaseWorkload.hpp"
Matthew Bentham14e46692018-09-20 15:35:30 +01009
Matthew Bentham9b3e7382020-02-05 21:39:55 +000010#include <arm_compute/runtime/CL/CLTensor.h>
11#include <arm_compute/runtime/CL/functions/CLBatchNormalizationLayer.h>
telsoa014fcda012018-03-09 14:13:49 +000012
13namespace armnn
14{
15
telsoa01c577f2c2018-08-31 09:22:23 +010016arm_compute::Status ClBatchNormalizationValidate(const TensorInfo& input,
17 const TensorInfo& output,
18 const TensorInfo& mean,
19 const TensorInfo& var,
20 const TensorInfo& beta,
21 const TensorInfo& gamma,
Keith Davisbcd860a2021-08-05 14:20:33 +010022 const BatchNormalizationDescriptor& descriptor,
Mike Kelly07810fc2020-11-12 10:58:48 +000023 const ActivationDescriptor* activationDescriptor = nullptr);
telsoa01c577f2c2018-08-31 09:22:23 +010024
arovir019e53a352018-08-31 15:26:35 +010025class ClBatchNormalizationFloatWorkload : public FloatWorkload<BatchNormalizationQueueDescriptor>
telsoa014fcda012018-03-09 14:13:49 +000026{
27public:
Sadik Armagane9444752020-12-02 11:28:58 +000028 ClBatchNormalizationFloatWorkload(const BatchNormalizationQueueDescriptor& descriptor,
29 const WorkloadInfo& info,
30 const arm_compute::CLCompileContext& clCompileContext);
telsoa014fcda012018-03-09 14:13:49 +000031
telsoa01c577f2c2018-08-31 09:22:23 +010032 using FloatWorkload<BatchNormalizationQueueDescriptor>::FloatWorkload;
telsoa014fcda012018-03-09 14:13:49 +000033 void Execute() const override;
34
David Monahanec819992022-02-10 14:47:13 +000035 // Replace input tensor handle with the given TensorHandle
36 void ReplaceInputTensorHandle(ITensorHandle* tensorHandle, unsigned int slot) override;
37
38 // Replace output tensor handle with the given TensorHandle
39 void ReplaceOutputTensorHandle(ITensorHandle* tensorHandle, unsigned int slot) override;
40
telsoa014fcda012018-03-09 14:13:49 +000041private:
42 mutable arm_compute::CLBatchNormalizationLayer m_Layer;
43
telsoa01c577f2c2018-08-31 09:22:23 +010044 std::unique_ptr<arm_compute::CLTensor> m_Mean;
45 std::unique_ptr<arm_compute::CLTensor> m_Variance;
46 std::unique_ptr<arm_compute::CLTensor> m_Gamma;
47 std::unique_ptr<arm_compute::CLTensor> m_Beta;
48
49 void FreeUnusedTensors();
David Monahanec819992022-02-10 14:47:13 +000050 virtual void Reconfigure();
telsoa014fcda012018-03-09 14:13:49 +000051};
52
53} //namespace armnn
54
55
56
57