diff options
author | Michele Di Giorgio <michele.digiorgio@arm.com> | 2018-04-13 14:28:08 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:49:54 +0000 |
commit | 164b65d3c8f61f1d6d404fb484c1998a20a2cbda (patch) | |
tree | b60b9f49066ca8c008726dd193e4e0bd56ac1168 /arm_compute/core | |
parent | 0cbb927ac309e332ac6e6f1ab9170f041f0138ab (diff) | |
download | ComputeLibrary-164b65d3c8f61f1d6d404fb484c1998a20a2cbda.tar.gz |
COMPMID-1043: Rework GCGEMMMatrixMultiplyKernel interface and allow auto initialization of the tensors
This patch also:
- removes support for already reshaped weights in GCConvolutionLayer
- makes GCConvolutionLayer similar to CLGEMMConvolutionLayer
- enables usage of the GCGEMM function in GCConvolution instead of calling the
GEMM kernels directly
Change-Id: I3e4a64335555e86e18585d38d8fda4bfdb44e265
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/127696
Tested-by: Jenkins <bsgcomp@arm.com>
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'arm_compute/core')
-rw-r--r-- | arm_compute/core/CL/CLTypes.h | 22 | ||||
-rw-r--r-- | arm_compute/core/GLES_COMPUTE/kernels/GCGEMMMatrixMultiplyKernel.h | 23 | ||||
-rw-r--r-- | arm_compute/core/GPUTarget.h | 49 |
3 files changed, 69 insertions, 25 deletions
diff --git a/arm_compute/core/CL/CLTypes.h b/arm_compute/core/CL/CLTypes.h index ca487814a7..4a03cc9637 100644 --- a/arm_compute/core/CL/CLTypes.h +++ b/arm_compute/core/CL/CLTypes.h @@ -24,6 +24,8 @@ #ifndef __ARM_COMPUTE_CL_TYPES_H__ #define __ARM_COMPUTE_CL_TYPES_H__ +#include "arm_compute/core/GPUTarget.h" + #include <string> namespace arm_compute @@ -31,26 +33,6 @@ namespace arm_compute /** Default string for the CLKernel configuration id */ static const std::string default_config_id = "no_config_id"; -/** Available GPU Targets */ -enum class GPUTarget -{ - UNKNOWN = 0x101, - GPU_ARCH_MASK = 0xF00, - MIDGARD = 0x100, - BIFROST = 0x200, - T600 = 0x110, - T700 = 0x120, - T800 = 0x130, - G71 = 0x210, - G72 = 0x220, - G51 = 0x230, - G51BIG = 0x231, - G51LIT = 0x232, - TNOX = 0x240, - TTRX = 0x250, - TBOX = 0x260 -}; - /** Available OpenCL Version */ enum class CLVersion { diff --git a/arm_compute/core/GLES_COMPUTE/kernels/GCGEMMMatrixMultiplyKernel.h b/arm_compute/core/GLES_COMPUTE/kernels/GCGEMMMatrixMultiplyKernel.h index 3a0b22f148..cea03a9357 100644 --- a/arm_compute/core/GLES_COMPUTE/kernels/GCGEMMMatrixMultiplyKernel.h +++ b/arm_compute/core/GLES_COMPUTE/kernels/GCGEMMMatrixMultiplyKernel.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -25,6 +25,7 @@ #define __ARM_COMPUTE_GCGEMMMATRIXMULTIPLYKERNEL_H__ #include "arm_compute/core/GLES_COMPUTE/IGCKernel.h" +#include "arm_compute/core/GPUTarget.h" namespace arm_compute { @@ -32,9 +33,6 @@ class IGCTensor; /** GLES Compute kernel to multiply two input matrices "A" and "B" or to multiply a vector "A" by a matrix "B". All elements of the output matrix/vector will be multiplied by alpha * - * @note If the output tensor is a matrix, the implementation assumes that the input tensors @p input0 and @p input1 are both matrices and reshaped respectively with @ref GCGEMMInterleave4x4Kernel" and @ref GCGEMMTranspose1xWKernel - * @note If the output tensor is a vector and the data type is F32, the implementation assumes that the first input tensor @p input0 is a vector and the second input tensor @p input1 a matrix. The implementation also assumes that both tensors have not been reshaped - * * @attention The second input tensor must have at least 2 dimensions (matrix) * */ @@ -64,8 +62,23 @@ public: * @param[out] output Output tensor to store the result of matrix multiplication. Data type supported: same as @p input0 * @param[in] alpha Weight of the matrix product * @param[in] is_interleaved_transposed (Optional) True if input0 and input1 have been reshaped respectively using @ref GCGEMMInterleave4x4Kernel and @ref GCGEMMTranspose1xWKernel + * @param[in] reshape_info (Optional) GEMM reshape info. If is_interleaved_transposed = true, this object must contain the information to understand how the matrix A and matrix B have been reshaped + */ + void configure(const IGCTensor *input0, const IGCTensor *input1, IGCTensor *output, float alpha, bool is_interleaved_transposed = true, const GEMMReshapeInfo &reshape_info = GEMMReshapeInfo()); + /** Static function to check if given info will lead to a valid configuration of @ref GCGEMMMatrixMultiplyKernel + * + * @param[in] input0 Input tensor containing the Matrix A. Data types supported: F16/F32 + * @param[in] input1 Input tensor containing the Matrix B. Data type supported: same as @p input0 + * @param[in] output Output tensor to store the result of matrix multiplication. Data type supported: same as @p input0 + * @param[in] alpha Weight of the matrix product + * @param[in] is_interleaved_transposed True if input0 and input1 have been reshaped respectively using @ref GCGEMMInterleave4x4Kernel and @ref GCGEMMTranspose1xWKernel + * @param[in] reshape_info GEMM reshape info. If is_interleaved_transposed = true, this object must contain the information to understand how the matrix A and matrix B have been reshaped + * @param[in] gpu_target GPU Target + * + * @return a status */ - void configure(const IGCTensor *input0, const IGCTensor *input1, IGCTensor *output, float alpha, bool is_interleaved_transposed = true); + static Status validate(const ITensorInfo *input0, const ITensorInfo *input1, const ITensorInfo *output, float alpha, bool is_interleaved_transposed, const GEMMReshapeInfo &reshape_info, + GPUTarget gpu_target); // Inherited methods overridden: void run(const Window &window) override; diff --git a/arm_compute/core/GPUTarget.h b/arm_compute/core/GPUTarget.h new file mode 100644 index 0000000000..8a5ca80f49 --- /dev/null +++ b/arm_compute/core/GPUTarget.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2018 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_GPUTARGET_H__ +#define __ARM_COMPUTE_GPUTARGET_H__ + +namespace arm_compute +{ +/** Available GPU Targets */ +enum class GPUTarget +{ + UNKNOWN = 0x101, + GPU_ARCH_MASK = 0xF00, + MIDGARD = 0x100, + BIFROST = 0x200, + T600 = 0x110, + T700 = 0x120, + T800 = 0x130, + G71 = 0x210, + G72 = 0x220, + G51 = 0x230, + G51BIG = 0x231, + G51LIT = 0x232, + TNOX = 0x240, + TTRX = 0x250, + TBOX = 0x260 +}; +} // namespace arm_compute +#endif /* __ARM_COMPUTE_GPUTARGET_H__ */ |