blob: d884f3022e5ffab7a05309059e4c77d217de691f [file] [log] [blame]
Teresa Charlinc1f6b092020-05-11 16:10:38 +01001//
Mike Kelly7cbe7812023-07-25 17:37:33 +01002// Copyright © 2020-2023 Arm Ltd and Contributors. All rights reserved.
Teresa Charlinc1f6b092020-05-11 16:10:38 +01003// SPDX-License-Identifier: MIT
4//
5
6#include "ClSoftmaxWorkload.hpp"
7#include "ClWorkloadUtils.hpp"
8
9#include <aclCommon/ArmComputeTensorUtils.hpp>
10#include <aclCommon/ArmComputeUtils.hpp>
11
12#include <cl/ClTensorHandle.hpp>
13
14namespace armnn
15{
16
17arm_compute::Status ClSoftmaxWorkloadValidate(const TensorInfo& input,
18 const TensorInfo& output,
19 const SoftmaxDescriptor& descriptor)
20{
21 const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input);
22 const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output);
23
Teresa Charline3866762020-08-28 15:13:05 +010024 int aclAxis = ComputeAclAxis(descriptor.m_Axis, input);
Teresa Charlinc1f6b092020-05-11 16:10:38 +010025 return arm_compute::CLSoftmaxLayer::validate(&aclInputInfo, &aclOutputInfo, descriptor.m_Beta, aclAxis);
26}
27
Sadik Armagane9444752020-12-02 11:28:58 +000028ClSoftmaxWorkload::ClSoftmaxWorkload(const SoftmaxQueueDescriptor& descriptor,
29 const WorkloadInfo& info,
30 std::shared_ptr<arm_compute::MemoryManagerOnDemand>& memoryManager,
31 const arm_compute::CLCompileContext& clCompileContext)
Teresa Charlin588cbdf2022-01-19 15:55:37 +000032 : ClBaseWorkload<SoftmaxQueueDescriptor>(descriptor, info)
Teresa Charlinc1f6b092020-05-11 16:10:38 +010033 , m_SoftmaxLayer(memoryManager)
34{
Keith Davisbcd860a2021-08-05 14:20:33 +010035 // Report Profiling Details
36 ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClSoftmaxWorkload_Construct",
37 descriptor.m_Parameters,
38 info,
39 this->GetGuid());
40
Teresa Charlinc1f6b092020-05-11 16:10:38 +010041 m_Data.ValidateInputsOutputs("ClSoftmaxWorkload", 1, 1);
42
43 arm_compute::ICLTensor& input = static_cast<ClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
44 arm_compute::ICLTensor& output = static_cast<ClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
45
Teresa Charline3866762020-08-28 15:13:05 +010046 int aclAxis = ComputeAclAxis(m_Data.m_Parameters.m_Axis, info.m_InputTensorInfos[0]);
Kevin May9f6862d2021-10-22 15:42:28 +010047 {
Mike Kelly7cbe7812023-07-25 17:37:33 +010048 ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID("ClSoftmaxWorkload_configure");
Kevin May9f6862d2021-10-22 15:42:28 +010049 m_SoftmaxLayer.configure(clCompileContext, &input, &output, m_Data.m_Parameters.m_Beta, aclAxis);
50 }
Teresa Charlinc1f6b092020-05-11 16:10:38 +010051}
52
53void ClSoftmaxWorkload::Execute() const
54{
Mike Kelly7cbe7812023-07-25 17:37:33 +010055 ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID("ClSoftmaxWorkload_Execute");
Teresa Charlinc1f6b092020-05-11 16:10:38 +010056 RunClFunction(m_SoftmaxLayer, CHECK_LOCATION());
57}
58
59} // namespace armnn