aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSiCong Li <sicong.li@arm.com>2020-06-26 10:02:06 +0100
committerSiCong Li <sicong.li@arm.com>2020-07-13 11:17:35 +0000
commit3a50166ff71f8379682fe6ece2a94b7a4bb3daa3 (patch)
treef7730d5eb40e7d6e431f77b9c96611538eba0559 /tests
parenta0bf9130a266332eadb69139296c96c66d401e12 (diff)
downloadComputeLibrary-3a50166ff71f8379682fe6ece2a94b7a4bb3daa3.tar.gz
COMPMID-3338 COMPMID-3336 COMPMID-3584
COMPMID-3338 Remove store padding in CLGEMMMatrixMultiplyReshapedOnlyRHSKernel COMPMID-3336 Remove store padding in CLGEMMMatrixMultiplyNativeKernel COMPMID-3584 Fix VSTORE to correctly deal with scalar case * Implement STORE_BLOCK_BOUNDARY_AWARE, as part of the COMPMID-3332 investigation, with the following substantial changes: - Separate STORE_BLOCK_PARTIAL, STORE_ROW_PARTIAL and VSTORE_PARTIAL so that this change does not affect kernels not using STORE_BLOCK_BOUNDARY_AWARE. - Revamp vstore_ext_n to vstore_partial_n, and enhance VSTORE_PARTIAL to correctly handle both vector and scalar cases * Remove the store padding (dst tensor) in CLGEMMMatrixMultiplyReshapedOnlyRHSKernel and CLGEMMMatrixMultiplyNativeKernel * Add configuration tests to check no padding is added by the configuration. Signed-off-by: SiCong Li <sicong.li@arm.com> Change-Id: I4f0907867979d8dacedd03b4bcbd2fb19e4f1602 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3522 Comments-Addressed: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Gian Marco Iodice <gianmarco.iodice@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/validation/CL/GEMMMatrixMultiplyNative.cpp72
-rw-r--r--tests/validation/CL/GEMMMatrixMultiplyReshapedOnlyRHS.cpp89
2 files changed, 160 insertions, 1 deletions
diff --git a/tests/validation/CL/GEMMMatrixMultiplyNative.cpp b/tests/validation/CL/GEMMMatrixMultiplyNative.cpp
index 5e4a12ddb7..bdf8248bb2 100644
--- a/tests/validation/CL/GEMMMatrixMultiplyNative.cpp
+++ b/tests/validation/CL/GEMMMatrixMultiplyNative.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 Arm Limited.
+ * Copyright (c) 2019-2020 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -164,6 +164,54 @@ void validate_configuration(unsigned int m_value, unsigned int n_value, unsigned
CLGEMMMatrixMultiplyNative gemm;
gemm.configure(&lhs, &rhs, &bias, &dst, 1.0f, 1.0f, lhs_info, rhs_info, kernel_info);
}
+/** Zero padding test */
+bool validate_zero_padding(unsigned int m_value, unsigned int n_value, unsigned int k_value, unsigned int b_value, unsigned int m0_value, unsigned int n0_value, unsigned int k0_value, bool broadcast_bias, DataType data_type, const ActivationLayerInfo &act_info)
+{
+ const unsigned int M = m_value;
+ const unsigned int N = n_value;
+ const unsigned int K = k_value;
+
+ GEMMLHSMatrixInfo lhs_info;
+ lhs_info.m0 = m0_value;
+ lhs_info.k0 = k0_value;
+
+ GEMMRHSMatrixInfo rhs_info;
+ rhs_info.n0 = n0_value;
+ rhs_info.k0 = k0_value;
+
+ GEMMKernelInfo kernel_info;
+ kernel_info.m = M;
+ kernel_info.n = N;
+ kernel_info.k = K;
+ kernel_info.broadcast_bias = broadcast_bias;
+ kernel_info.activation_info = act_info;
+
+ const TensorShape lhs_shape(K, M, b_value);
+ const TensorShape rhs_shape(N, K, b_value);
+ const TensorShape bias_shape(N,
+ broadcast_bias? 1 : M,
+ broadcast_bias? 1 : b_value);
+ const TensorShape dst_shape = compute_mm_shape(TensorInfo(lhs_shape, 1, data_type),
+ TensorInfo(rhs_shape, 1, data_type),
+ kernel_info);
+
+ // Create tensors
+ CLTensor lhs = create_tensor<CLTensor>(lhs_shape, data_type);
+ CLTensor rhs = create_tensor<CLTensor>(rhs_shape, data_type);
+ CLTensor bias = create_tensor<CLTensor>(bias_shape, data_type);
+ CLTensor dst = create_tensor<CLTensor>(dst_shape, data_type);
+
+ ARM_COMPUTE_EXPECT(lhs.info()->is_resizable(), framework::LogLevel::ERRORS);
+ ARM_COMPUTE_EXPECT(rhs.info()->is_resizable(), framework::LogLevel::ERRORS);
+ ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS);
+ ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
+
+ // Create and configure function
+ CLGEMMMatrixMultiplyNative gemm;
+ gemm.configure(&lhs, &rhs, &bias, &dst, 1.0f, 1.0f, lhs_info, rhs_info, kernel_info);
+
+ return dst.info()->padding().empty();
+}
} // namespace
TEST_SUITE(CL)
@@ -185,6 +233,28 @@ m_value, n_value, k_value, b_value, m0_value, n0_value, k0_value, broadcast_bias
validate_configuration(m_value, n_value, k_value, b_value, m0_value, n0_value, k0_value, broadcast_bias, DataType::F32, act_value);
}
+/** Validate zero padding tests
+ *
+ * A series of validation tests to check that no padding is added as part of configuration for 4 different scenarios.
+ *
+ * Checks performed in order:
+ * - No partial blocks in both x and y dimensions
+ * - Partial blocks in x dimension
+ * - Partial blocks in y dimension
+ * - Partial blocks in both x and y dimensions
+ * - No blocks in both x and y dimensions, scalar store (N0==1)
+ */
+DATA_TEST_CASE(ValidateZeroPadding, framework::DatasetMode::ALL, zip(zip(zip(
+framework::dataset::make("M", { 24, 64, 101, 1, 50 }),
+framework::dataset::make("N", { 48, 29, 16, 122, 20 })),
+framework::dataset::make("M0", { 4, 8, 7, 2, 1 })),
+framework::dataset::make("N0", { 4, 4, 16, 3, 1 })),
+m_value, n_value, m0_value, n0_value)
+{
+ bool status = validate_zero_padding(m_value, n_value, 23, 1, m0_value, n0_value, 4, false, DataType::F32, ActivationLayerInfo());
+ ARM_COMPUTE_EXPECT(status, framework::LogLevel::ERRORS);
+}
+
FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyNativeFixture<float>, framework::DatasetMode::ALL,
combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
m_values,
diff --git a/tests/validation/CL/GEMMMatrixMultiplyReshapedOnlyRHS.cpp b/tests/validation/CL/GEMMMatrixMultiplyReshapedOnlyRHS.cpp
index 14b1c66e2c..0456ca2017 100644
--- a/tests/validation/CL/GEMMMatrixMultiplyReshapedOnlyRHS.cpp
+++ b/tests/validation/CL/GEMMMatrixMultiplyReshapedOnlyRHS.cpp
@@ -185,6 +185,69 @@ bool validate_configuration(unsigned int m_value, unsigned int n_value, unsigned
CLGEMMMatrixMultiplyReshapedOnlyRHS gemm;
return bool(gemm.validate(&lhs, &rhs_reshaped, &bias, &dst, alpha, beta, lhs_info, rhs_info, kernel_info));
}
+
+/** Zero padding test */
+bool validate_zero_padding(unsigned int m_value, unsigned int n_value, unsigned int k_value, unsigned int b_value,
+ unsigned int m0_value, unsigned int n0_value, unsigned int k0_value, unsigned int h0_value,
+ bool i_value_rhs, bool t_value_rhs, bool export_to_cl_image, bool broadcast_bias, bool input_as_3d, unsigned int depth_output_gemm3d, const ActivationLayerInfo &act_info,
+ DataType dt_input0, DataType dt_input1, DataType dt_input2, DataType dt_output, float alpha, float beta)
+{
+ const unsigned int M = m_value;
+ const unsigned int N = n_value;
+ const unsigned int K = k_value;
+
+ GEMMLHSMatrixInfo lhs_info;
+ lhs_info.m0 = m0_value;
+ lhs_info.k0 = k0_value;
+
+ GEMMRHSMatrixInfo rhs_info;
+ rhs_info.n0 = n0_value;
+ rhs_info.k0 = k0_value;
+ rhs_info.h0 = h0_value;
+ rhs_info.interleave = i_value_rhs;
+ rhs_info.transpose = t_value_rhs;
+ rhs_info.export_to_cl_image = export_to_cl_image;
+
+ GEMMKernelInfo kernel_info;
+ kernel_info.m = M;
+ kernel_info.n = N;
+ kernel_info.k = K;
+ kernel_info.depth_output_gemm3d = depth_output_gemm3d;
+ kernel_info.reinterpret_input_as_3d = input_as_3d;
+ kernel_info.broadcast_bias = broadcast_bias;
+ kernel_info.activation_info = act_info;
+
+ const TensorShape lhs_shape(K, M, b_value);
+ const TensorShape rhs_shape(N, K, b_value);
+ const TensorShape rhs_shape_reshaped = compute_rhs_reshaped_shape(TensorInfo(rhs_shape, 1, dt_input1),
+ rhs_info);
+
+ const TensorShape dst_shape = compute_mm_shape(TensorInfo(lhs_shape, 1, dt_input0),
+ TensorInfo(rhs_shape_reshaped, 1, dt_input1),
+ kernel_info);
+
+ const TensorShape bias_shape(N,
+ M, // Correct calculation should be: broadcast_bias? 1 : M, it's wrong here on purpose just for validation test
+ broadcast_bias? 1 : b_value);
+
+ // Create tensors
+ CLTensor lhs = create_tensor<CLTensor>(lhs_shape, dt_input0);
+ CLTensor rhs_reshaped = create_tensor<CLTensor>(rhs_shape_reshaped, dt_input1);
+ CLTensor bias = create_tensor<CLTensor>(bias_shape, dt_input2);
+ CLTensor dst = create_tensor<CLTensor>(dst_shape, dt_output);
+
+ ARM_COMPUTE_EXPECT(lhs.info()->is_resizable(), framework::LogLevel::ERRORS);
+ ARM_COMPUTE_EXPECT(rhs_reshaped.info()->is_resizable(), framework::LogLevel::ERRORS);
+ ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS);
+ ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
+
+ // Validate zero-padding
+ CLGEMMMatrixMultiplyReshapedOnlyRHS gemm;
+
+ gemm.configure(&lhs, &rhs_reshaped, &bias, &dst, alpha, beta, lhs_info, rhs_info, kernel_info);
+
+ return dst.info()->padding().empty();
+}
} // namespace
TEST_SUITE(CL)
@@ -236,6 +299,32 @@ b_value, m0_value, n0_value, k0_value, broadcast_bias, input_as_3d, depth_output
ARM_COMPUTE_EXPECT(status == expected_value, framework::LogLevel::ERRORS);
}
+/** Validate zero padding tests
+ *
+ * A series of validation tests to check that no padding is added as part of configuration for 4 different scenarios.
+ *
+ * Checks performed in order:
+ * - No partial blocks in both x and y dimensions
+ * - Partial blocks in x dimension
+ * - Partial blocks in y dimension
+ * - Partial blocks in both x and y dimensions
+ */
+DATA_TEST_CASE(ValidateZeroPadding, framework::DatasetMode::ALL, zip(zip(zip(zip(
+framework::dataset::make("M", { 24, 64, 101, 1 }),
+framework::dataset::make("N", { 48, 29, 16, 122 })),
+framework::dataset::make("M0", { 4, 8, 7, 2 })),
+framework::dataset::make("N0", { 4, 4, 16, 3 })),
+framework::dataset::make("export_to_cl_image", { false, true, true, false })),
+m_value, n_value, m0_value, n0_value, export_to_cl_image)
+{
+ constexpr DataType dt = DataType::F32;
+ // Disable export_to_cl_image if the target platform does not support the OpenCL cl_khr_image2d_from_buffer extension
+ bool actual_export_to_cl_image = image2d_from_buffer_supported(CLKernelLibrary::get().get_device()) && export_to_cl_image;
+
+ bool status = validate_zero_padding(m_value, n_value, 23, 1, m0_value, n0_value, 4, 1, false, false, actual_export_to_cl_image, false, 0, 0, ActivationLayerInfo(), dt, dt, dt, dt, 1.0f, 1.0f);
+ ARM_COMPUTE_EXPECT(status, framework::LogLevel::ERRORS);
+}
+
TEST_SUITE(Float)
TEST_SUITE(FP32)