From d24affe0abefe8f4a83c7d4487386920895fd2e7 Mon Sep 17 00:00:00 2001 From: Sang-Hoon Park Date: Tue, 8 Oct 2019 18:07:23 +0100 Subject: COMPMID-2265 add support for Log Softmax to NEON Kernel (NEON/reference), validation tests, function and fixture are updated to add support for Log Softmax Change-Id: I641dbf1552f4128c691af8875949ebf88da71ee8 Signed-off-by: Sang-Hoon Park Reviewed-on: https://review.mlplatform.org/c/2075 Comments-Addressed: Arm Jenkins Reviewed-by: Michele Di Giorgio Tested-by: Arm Jenkins --- src/runtime/NEON/functions/NESoftmaxLayer.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'src/runtime/NEON/functions/NESoftmaxLayer.cpp') diff --git a/src/runtime/NEON/functions/NESoftmaxLayer.cpp b/src/runtime/NEON/functions/NESoftmaxLayer.cpp index 79a94961d8..f530a87d05 100644 --- a/src/runtime/NEON/functions/NESoftmaxLayer.cpp +++ b/src/runtime/NEON/functions/NESoftmaxLayer.cpp @@ -33,13 +33,15 @@ namespace arm_compute { -NESoftmaxLayer::NESoftmaxLayer(std::shared_ptr memory_manager) +template +NESoftmaxLayerGeneric::NESoftmaxLayerGeneric(std::shared_ptr memory_manager) : _memory_group(std::move(memory_manager)), _max_kernel(), _softmax_kernel(), _flat_or_reshape_kernel_ptr(nullptr), _fill_border_kernel(), _reshape_kernel(), _max(), _tmp(), _input_flattened(), _output_flattened(), _needs_flattening(false) { } -void NESoftmaxLayer::configure_reshape_input_kernel(const ITensor *input, const ITensor *output, size_t axis) +template +void NESoftmaxLayerGeneric::configure_reshape_input_kernel(const ITensor *input, const ITensor *output, size_t axis) { // Flatten the input const TensorShape shape_flatten = misc::shape_calculator::compute_softmax_shape(input->info(), axis); @@ -68,11 +70,12 @@ void NESoftmaxLayer::configure_reshape_input_kernel(const ITensor *input, const auto_init_if_empty(*output->info(), *input->info()->clone()); } -void NESoftmaxLayer::configure(ITensor *input, ITensor *output, float beta, size_t axis) +template +void NESoftmaxLayerGeneric::configure(ITensor *input, ITensor *output, float beta, size_t axis) { // Perform validation step ARM_COMPUTE_ERROR_ON_NULLPTR(input, output); - ARM_COMPUTE_ERROR_THROW_ON(NESoftmaxLayer::validate(input->info(), output->info(), beta, axis)); + ARM_COMPUTE_ERROR_THROW_ON(NESoftmaxLayerGeneric::validate(input->info(), output->info(), beta, axis)); // We don't need flattening only in the case the input is 2D and axis is 1 _needs_flattening = axis != 1; @@ -138,7 +141,8 @@ void NESoftmaxLayer::configure(ITensor *input, ITensor *output, float beta, size _tmp.allocator()->allocate(); } -Status NESoftmaxLayer::validate(const ITensorInfo *input, const ITensorInfo *output, float beta, size_t axis) +template +Status NESoftmaxLayerGeneric::validate(const ITensorInfo *input, const ITensorInfo *output, float beta, size_t axis) { // Perform validation step ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input, output); @@ -173,12 +177,13 @@ Status NESoftmaxLayer::validate(const ITensorInfo *input, const ITensorInfo *out } ARM_COMPUTE_RETURN_ON_ERROR(NELogits1DMaxKernel::validate(input, &tensor_info_max_sum)); - ARM_COMPUTE_RETURN_ON_ERROR(NELogits1DSoftmaxKernel::validate(&tensor_info_tmp, &tensor_info_max_sum, output, beta, &dont_care)); + ARM_COMPUTE_RETURN_ON_ERROR(NELogits1DSoftmaxKernel::validate(&tensor_info_tmp, &tensor_info_max_sum, output, beta, &dont_care)); return Status{}; } -void NESoftmaxLayer::run() +template +void NESoftmaxLayerGeneric::run() { MemoryGroupResourceScope scope_mg(_memory_group); @@ -196,4 +201,8 @@ void NESoftmaxLayer::run() NEScheduler::get().schedule(&_reshape_kernel, Window::DimY); } } + +template class NESoftmaxLayerGeneric; +template class NESoftmaxLayerGeneric; + } // namespace arm_compute \ No newline at end of file -- cgit v1.2.1