Jakub Sujak | 3274172 | 2022-11-25 16:43:18 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2022 Arm Limited. |
| 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to |
| 8 | * deal in the Software without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in all |
| 14 | * copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
| 24 | #include "ClComponentActivation.h" |
| 25 | |
| 26 | #include "src/core/CL/CLValidate.h" |
| 27 | #include "src/dynamic_fusion/sketch/gpu/template_writer/cl/ClTemplateActivation.h" |
| 28 | |
| 29 | namespace arm_compute |
| 30 | { |
| 31 | namespace experimental |
| 32 | { |
| 33 | namespace dynamic_fusion |
| 34 | { |
| 35 | |
| 36 | Status ClComponentActivation::validate(const Properties &properties, |
| 37 | const ArgumentPack<ITensorInfo> &tensors, |
| 38 | const Attributes &attributes) |
| 39 | { |
| 40 | ARM_COMPUTE_UNUSED(properties, attributes); |
| 41 | |
| 42 | const ITensorInfo *const src = tensors.get_const_tensor(TensorType::ACL_SRC); |
| 43 | const ITensorInfo *const dst = tensors.get_const_tensor(TensorType::ACL_DST); |
| 44 | |
| 45 | ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(src, dst); |
| 46 | |
| 47 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(src, 1, DataType::F16, DataType::F32); |
| 48 | |
| 49 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(src, dst); |
| 50 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(src, dst); |
| 51 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_LAYOUT(src, dst); |
| 52 | |
| 53 | // All tensor infos are initialized |
| 54 | ARM_COMPUTE_RETURN_ERROR_ON(src->tensor_shape().total_size() == 0); |
| 55 | ARM_COMPUTE_RETURN_ERROR_ON(dst->tensor_shape().total_size() == 0); |
| 56 | |
| 57 | // Device requirements are met |
| 58 | ARM_COMPUTE_RETURN_ERROR_ON_F16_UNSUPPORTED(src); |
| 59 | ARM_COMPUTE_RETURN_ERROR_ON_F16_UNSUPPORTED(dst); |
| 60 | |
| 61 | return Status{}; |
| 62 | } |
| 63 | |
| 64 | ClComponentActivation::ClComponentActivation(ComponentId id, |
| 65 | const IGpuKernelComponent::Properties &properties, |
| 66 | const ArgumentPack<ITensorInfo> &tensors, |
| 67 | const Attributes &attributes) |
| 68 | : IGpuKernelComponent{ id, properties, tensors }, |
| 69 | _component_writer{ std::make_unique<ClTemplateActivation>(id, tensors, attributes) } |
| 70 | { |
| 71 | } |
| 72 | |
| 73 | const IGpuTemplateComponentWriter *ClComponentActivation::template_writer() const |
| 74 | { |
| 75 | return _component_writer.get(); |
| 76 | } |
| 77 | } // namespace dynamic_fusion |
| 78 | } // namespace experimental |
| 79 | } // namespace arm_compute |