aboutsummaryrefslogtreecommitdiff
path: root/tests/validation
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2018-07-17 12:28:42 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:54:54 +0000
commit7d66a8e3f603f2cd363f04a750847e3f9eabdfd4 (patch)
tree0d7e1ad5bf0ecd32cd919074f756d27c351d7638 /tests/validation
parentae54e026c86aec7d6819ee3ef76372c1a3c92467 (diff)
downloadComputeLibrary-7d66a8e3f603f2cd363f04a750847e3f9eabdfd4.tar.gz
COMPMID-1386: Add support for converting weights for CL.
Change-Id: I62e3ead903366baeeb1488f233a9b8b0c388c9de Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/140403 Tested-by: Jenkins <bsgcomp@arm.com> Reviewed-by: Giorgio Arena <giorgio.arena@arm.com> Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'tests/validation')
-rw-r--r--tests/validation/CL/FullyConnectedLayer.cpp15
-rw-r--r--tests/validation/GLES_COMPUTE/FullyConnectedLayer.cpp7
-rw-r--r--tests/validation/NEON/FullyConnectedLayer.cpp14
-rw-r--r--tests/validation/fixtures/FullyConnectedLayerFixture.h7
-rw-r--r--tests/validation/fixtures/UNIT/MemoryManagerFixture.h14
-rw-r--r--tests/validation/reference/ConvertFullyConnectedWeights.cpp10
6 files changed, 55 insertions, 12 deletions
diff --git a/tests/validation/CL/FullyConnectedLayer.cpp b/tests/validation/CL/FullyConnectedLayer.cpp
index 9958a88419..cd050e378e 100644
--- a/tests/validation/CL/FullyConnectedLayer.cpp
+++ b/tests/validation/CL/FullyConnectedLayer.cpp
@@ -96,9 +96,14 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(frame
const QuantizationInfo src_quantization_info = src.info()->quantization_info();
const QuantizationInfo weights_quantization_info = weights.info()->quantization_info();
+ // Create Fully Connected layer info
+ FullyConnectedLayerInfo fc_info;
+ fc_info.transpose_weights = transpose_weights;
+ fc_info.are_weights_reshaped = !reshape_weights;
+
// Create and configure function.
CLFullyConnectedLayer fc;
- fc.configure(&src, &weights, &bias, &dst, transpose_weights, !reshape_weights);
+ fc.configure(&src, &weights, &bias, &dst, fc_info);
// Validate valid region
const ValidRegion dst_valid_region = shape_to_valid_region(dst_shape);
@@ -141,12 +146,16 @@ DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(
framework::dataset::make("Expected", { false, true, true, false, false })),
input_info, weights_info, bias_info, output_info, transpose_weights, reshaped_weights, expected)
{
+ // Create Fully Connected layer info
+ FullyConnectedLayerInfo fc_info;
+ fc_info.transpose_weights = transpose_weights;
+ fc_info.are_weights_reshaped = reshaped_weights;
+
Status status = CLFullyConnectedLayer::validate(&input_info.clone()->set_is_resizable(false),
&weights_info.clone()->set_is_resizable(false),
&bias_info.clone()->set_is_resizable(false),
&output_info.clone()->set_is_resizable(false),
- transpose_weights,
- reshaped_weights);
+ fc_info);
ARM_COMPUTE_EXPECT(bool(status) == expected, framework::LogLevel::ERRORS);
}
// clang-format on
diff --git a/tests/validation/GLES_COMPUTE/FullyConnectedLayer.cpp b/tests/validation/GLES_COMPUTE/FullyConnectedLayer.cpp
index 49716dc946..c82a8a1a43 100644
--- a/tests/validation/GLES_COMPUTE/FullyConnectedLayer.cpp
+++ b/tests/validation/GLES_COMPUTE/FullyConnectedLayer.cpp
@@ -87,9 +87,14 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(frame
ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS);
ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
+ // Create Fully Connected layer info
+ FullyConnectedLayerInfo fc_info;
+ fc_info.transpose_weights = transpose_weights;
+ fc_info.are_weights_reshaped = !reshape_weights;
+
// Create and configure function.
GCFullyConnectedLayer fc;
- fc.configure(&src, &weights, &bias, &dst, transpose_weights, !reshape_weights);
+ fc.configure(&src, &weights, &bias, &dst, fc_info);
// Validate valid region
const ValidRegion dst_valid_region = shape_to_valid_region(dst_shape);
diff --git a/tests/validation/NEON/FullyConnectedLayer.cpp b/tests/validation/NEON/FullyConnectedLayer.cpp
index 174778b8ef..80fdf1784e 100644
--- a/tests/validation/NEON/FullyConnectedLayer.cpp
+++ b/tests/validation/NEON/FullyConnectedLayer.cpp
@@ -99,9 +99,14 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(frame
ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS);
ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
+ // Create Fully Connected layer info
+ FullyConnectedLayerInfo fc_info;
+ fc_info.transpose_weights = transpose_weights;
+ fc_info.are_weights_reshaped = !reshape_weights;
+
// Create and configure function.
NEFullyConnectedLayer fc;
- fc.configure(&src, &weights, &bias, &dst, transpose_weights, !reshape_weights);
+ fc.configure(&src, &weights, &bias, &dst, fc_info);
// Validate valid region
const ValidRegion dst_valid_region = shape_to_valid_region(dst_shape);
@@ -144,7 +149,12 @@ DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(
framework::dataset::make("Expected", { false, true, true, false, false, true })),
input_info, weights_info, bias_info, output_info, transpose_weights, reshaped_weights, expected)
{
- Status status = NEFullyConnectedLayer::validate(&input_info.clone()->set_is_resizable(false), &weights_info.clone()->set_is_resizable(false), &bias_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), transpose_weights, reshaped_weights);
+ // Create Fully Connected layer info
+ FullyConnectedLayerInfo fc_info;
+ fc_info.transpose_weights = transpose_weights;
+ fc_info.are_weights_reshaped = reshaped_weights;
+
+ Status status = NEFullyConnectedLayer::validate(&input_info.clone()->set_is_resizable(false), &weights_info.clone()->set_is_resizable(false), &bias_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), fc_info);
ARM_COMPUTE_EXPECT(bool(status) == expected, framework::LogLevel::ERRORS);
}
// clang-format on
diff --git a/tests/validation/fixtures/FullyConnectedLayerFixture.h b/tests/validation/fixtures/FullyConnectedLayerFixture.h
index 895e43b735..18321480f8 100644
--- a/tests/validation/fixtures/FullyConnectedLayerFixture.h
+++ b/tests/validation/fixtures/FullyConnectedLayerFixture.h
@@ -130,9 +130,14 @@ protected:
TensorType bias = create_tensor<TensorType>(bias_shape, _bias_data_type, 1, _quantization_info);
TensorType dst = create_tensor<TensorType>(output_shape, _data_type, 1, _quantization_info);
+ // Create Fully Connected layer info
+ FullyConnectedLayerInfo fc_info;
+ fc_info.transpose_weights = transpose_weights;
+ fc_info.are_weights_reshaped = !reshape_weights;
+
// Create and configure function.
FunctionType fc;
- fc.configure(&src, &weights, &bias, &dst, transpose_weights, !reshape_weights);
+ fc.configure(&src, &weights, &bias, &dst, fc_info);
ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
ARM_COMPUTE_EXPECT(weights.info()->is_resizable(), framework::LogLevel::ERRORS);
diff --git a/tests/validation/fixtures/UNIT/MemoryManagerFixture.h b/tests/validation/fixtures/UNIT/MemoryManagerFixture.h
index 21ad42bf77..d8e2b0b427 100644
--- a/tests/validation/fixtures/UNIT/MemoryManagerFixture.h
+++ b/tests/validation/fixtures/UNIT/MemoryManagerFixture.h
@@ -239,9 +239,13 @@ protected:
dst.allocator()->info().set_tensor_shape(TensorShape(24U, _cur_batches)).set_is_resizable(true).extend_padding(new_dst_padding);
dst.allocator()->info().set_is_resizable(false);
+ // Configure FC info
+ FullyConnectedLayerInfo fc_info;
+ fc_info.retain_internal_weights = true;
+
// Configure functions (2nd iteration)
- fc_layer_1.configure(&src, &w1, &b1, &fc1, true, false, true);
- fc_layer_2.configure(&fc1, &w2, &b2, &dst, true, false, true);
+ fc_layer_1.configure(&src, &w1, &b1, &fc1, fc_info);
+ fc_layer_2.configure(&fc1, &w2, &b2, &dst, fc_info);
// Fill tensors (2nd iteration)
fill(AccessorType(src), 5);
@@ -357,6 +361,10 @@ protected:
// Get padding requirements
auto fc_padding = fc.allocator()->info().padding();
+ // Configure FC info
+ FullyConnectedLayerInfo fc_info;
+ fc_info.retain_internal_weights = true;
+
// Run rest iterations
for(int i = _max_batches; i >= static_cast<int>(_cur_batches); --i)
{
@@ -368,7 +376,7 @@ protected:
dst.allocator()->info().set_tensor_shape(TensorShape(8U, i));
// Configure functions
- fc_layer.configure(&src, &w, &b, &fc, true, false, true);
+ fc_layer.configure(&src, &w, &b, &fc, fc_info);
smx_layer.configure(&fc, &dst);
// Fill tensors
diff --git a/tests/validation/reference/ConvertFullyConnectedWeights.cpp b/tests/validation/reference/ConvertFullyConnectedWeights.cpp
index b0f537fa0c..e27846c726 100644
--- a/tests/validation/reference/ConvertFullyConnectedWeights.cpp
+++ b/tests/validation/reference/ConvertFullyConnectedWeights.cpp
@@ -36,9 +36,15 @@ SimpleTensor<T> convert_fully_connected_weights(const SimpleTensor<T> &src, cons
{
SimpleTensor<T> dst(src.shape(), src.data_type());
+ const DataLayout original_input_data_layout = (training_data_layout == DataLayout::NCHW) ? DataLayout::NHWC : DataLayout::NCHW;
+
+ const int width_idx = get_data_layout_dimension_index(original_input_data_layout, DataLayoutDimension::WIDTH);
+ const int height_idx = get_data_layout_dimension_index(original_input_data_layout, DataLayoutDimension::HEIGHT);
+ const int channel_idx = get_data_layout_dimension_index(original_input_data_layout, DataLayoutDimension::CHANNEL);
+
const bool is_nchw_to_nhwc = training_data_layout == DataLayout::NCHW;
- const unsigned int num_elems_per_input_plane = original_input_shape.x() * original_input_shape.y();
- const unsigned int num_channels = original_input_shape.z();
+ const unsigned int num_elems_per_input_plane = original_input_shape[width_idx] * original_input_shape[height_idx];
+ const unsigned int num_channels = original_input_shape[channel_idx];
const unsigned int factor_1 = is_nchw_to_nhwc ? num_elems_per_input_plane : num_channels;
const unsigned int factor_2 = is_nchw_to_nhwc ? num_channels : num_elems_per_input_plane;