telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1 | // |
Teresa Charlin | 588cbdf | 2022-01-19 15:55:37 +0000 | [diff] [blame] | 2 | // Copyright © 2017 Arm Ltd and Contributors. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4 | // |
| 5 | |
| 6 | #pragma once |
| 7 | |
Teresa Charlin | 588cbdf | 2022-01-19 15:55:37 +0000 | [diff] [blame] | 8 | #include "ClBaseWorkload.hpp" |
Matthew Bentham | 14e4669 | 2018-09-20 15:35:30 +0100 | [diff] [blame] | 9 | |
Matthew Bentham | 9b3e738 | 2020-02-05 21:39:55 +0000 | [diff] [blame] | 10 | #include <arm_compute/runtime/CL/CLTensor.h> |
| 11 | #include <arm_compute/runtime/CL/functions/CLBatchNormalizationLayer.h> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 12 | |
| 13 | namespace armnn |
| 14 | { |
| 15 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 16 | arm_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 Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 22 | const BatchNormalizationDescriptor& descriptor, |
Mike Kelly | 07810fc | 2020-11-12 10:58:48 +0000 | [diff] [blame] | 23 | const ActivationDescriptor* activationDescriptor = nullptr); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 24 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 25 | class ClBatchNormalizationFloatWorkload : public FloatWorkload<BatchNormalizationQueueDescriptor> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 26 | { |
| 27 | public: |
Sadik Armagan | e944475 | 2020-12-02 11:28:58 +0000 | [diff] [blame] | 28 | ClBatchNormalizationFloatWorkload(const BatchNormalizationQueueDescriptor& descriptor, |
| 29 | const WorkloadInfo& info, |
| 30 | const arm_compute::CLCompileContext& clCompileContext); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 31 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 32 | using FloatWorkload<BatchNormalizationQueueDescriptor>::FloatWorkload; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 33 | void Execute() const override; |
| 34 | |
David Monahan | ec81999 | 2022-02-10 14:47:13 +0000 | [diff] [blame] | 35 | // 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 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 41 | private: |
| 42 | mutable arm_compute::CLBatchNormalizationLayer m_Layer; |
| 43 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 44 | 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 Monahan | ec81999 | 2022-02-10 14:47:13 +0000 | [diff] [blame] | 50 | virtual void Reconfigure(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | } //namespace armnn |
| 54 | |
| 55 | |
| 56 | |
| 57 | |