Skip to content

Commit

Permalink
[CLDNN] Add unittests for Permute optimized kernel (openvinotoolkit#9)
Browse files Browse the repository at this point in the history
* Add cldnn unittests for Permute optimized kernel
* Add transpose functional tests for permute_tile_8x8_4x4
  • Loading branch information
Eunsoo Sheen authored and yeonbok committed Feb 20, 2021
1 parent d3d1267 commit 9f23a8a
Show file tree
Hide file tree
Showing 4 changed files with 823 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,24 @@ const std::vector<InferenceEngine::Precision> netPrecisions = {
InferenceEngine::Precision::FP32,
};

/**
* 4D permute tests
*/
const std::vector<std::vector<size_t>> inputShapes = {
std::vector<size_t>{1, 3, 100, 100},
// use permute_8x8_4x4 kernel
std::vector<size_t>{2, 8, 64, 64},
std::vector<size_t>{2, 5, 64, 64},
std::vector<size_t>{2, 8, 64, 5},
std::vector<size_t>{2, 5, 64, 5},
};

const std::vector<std::vector<size_t>> inputOrder = {
// use permute_ref
std::vector<size_t>{0, 3, 2, 1},
std::vector<size_t>{},
// use permute_8x8_4x4 kernel
std::vector<size_t>{0, 2, 3, 1},
};

const auto params = testing::Combine(
Expand All @@ -42,4 +53,77 @@ INSTANTIATE_TEST_CASE_P(
TransposeLayerTest::getTestCaseName
);

/**
* 5D permute tests
*/
const std::vector<std::vector<size_t>> inputShapes5D = {
std::vector<size_t>{2, 8, 64, 32, 64},
std::vector<size_t>{2, 5, 64, 32, 64},
std::vector<size_t>{2, 8, 64, 32, 5},
std::vector<size_t>{2, 5, 64, 32, 5},
};

const std::vector<std::vector<size_t>> inputOrder5D = {
// use permute_ref
std::vector<size_t>{0, 3, 4, 2, 1},
std::vector<size_t>{},
// use permute_8x8_4x4 kernel
std::vector<size_t>{0, 2, 3, 4, 1},
};

const auto params5D = testing::Combine(
testing::ValuesIn(inputOrder5D),
testing::ValuesIn(netPrecisions),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Layout::ANY),
testing::Values(InferenceEngine::Layout::ANY),
testing::ValuesIn(inputShapes5D),
testing::Values(CommonTestUtils::DEVICE_GPU)
);

INSTANTIATE_TEST_CASE_P(
smoke_Transpose_5D,
TransposeLayerTest,
params5D,
TransposeLayerTest::getTestCaseName
);

/**
* 6D permute tests
*/
const std::vector<std::vector<size_t>> inputShapes6D = {
std::vector<size_t>{2, 8, 64, 32, 32, 64},
std::vector<size_t>{2, 5, 64, 32, 32, 64},
std::vector<size_t>{2, 8, 64, 32, 32, 5},
std::vector<size_t>{2, 5, 64, 32, 32, 5},
};

const std::vector<std::vector<size_t>> inputOrder6D = {
// use permute_ref
std::vector<size_t>{0, 4, 3, 5, 2, 1},
std::vector<size_t>{},
// use permute_8x8_4x4 kernel
std::vector<size_t>{0, 2, 3, 4, 5, 1},
};

const auto params6D = testing::Combine(
testing::ValuesIn(inputOrder6D),
testing::ValuesIn(netPrecisions),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Layout::ANY),
testing::Values(InferenceEngine::Layout::ANY),
testing::ValuesIn(inputShapes6D),
testing::Values(CommonTestUtils::DEVICE_GPU)
);

INSTANTIATE_TEST_CASE_P(
smoke_Transpose_6D,
TransposeLayerTest,
params6D,
TransposeLayerTest::getTestCaseName
);


} // namespace
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ JitConstants PermuteKernel_tile_8x8_4x4::GetJitConstants(const permute_params& p
JitConstants jit = MakeBaseParamsJitConstants(params);

#if VECTORWIDTH_SAME_AS_TILE_SIZE
int32_t vector_width = tile_size;
size_t vector_width = tile_size;
#endif
// Note: this is default mode and different vector width is not being used now.
uint64_t total_lws = dispatchData.lws[0] * dispatchData.lws[1] * dispatchData.lws[2];
Expand Down Expand Up @@ -220,7 +220,7 @@ static std::vector<size_t> GetBestLwsFromGws(const permute_params& params, const
// SLM size: elemsize * tile_size * tile_size * work_items <= 64K
size_t elem_size = sizeof(params.output.GetDType());
size_t max_local_mem_size = 64 * 1024;
size_t max_num_work_items = std::min(256lu, max_local_mem_size / (elem_size * tile_size * tile_size));
size_t max_num_work_items = std::min((size_t)256, (size_t)max_local_mem_size / (elem_size * tile_size * tile_size));

for (size_t i = 0; i < dims.size(); ++i) {
size_t dim = dims[i];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6047,6 +6047,21 @@ struct permute_params {
#define CASE_PERMUTE_U8_3D_2 {2, 16, 4, 4, 3}, {4, 2, 4, 3, 16}, {3, 0, 2, 4, 1}, tensor{0}, data_types::u8, format::bfzyx, data_types::f32, format::bfzyx
#define CASE_PERMUTE_U8_3D_3 {1, 32, 4, 2, 1}, {1, 2, 32, 1, 4}, {4, 3, 1, 0, 2}, tensor{0}, data_types::u8, format::bfzyx, data_types::f32, format::bfzyx

// permute_tile_8x8_4x4
#define CASE_PERMUTE_TILE_8x8_4x4_4D_0 {1, 8, 8, 2}, {1, 2, 8, 8}, {0, 3, 1, 2}, tensor{0}, data_types::f32, format::bfyx, data_types::f32, format::bfyx
#define CASE_PERMUTE_TILE_8x8_4x4_4D_1 {1, 5, 8, 2}, {1, 2, 5, 8}, {0, 3, 1, 2}, tensor{0}, data_types::f32, format::bfyx, data_types::f32, format::bfyx
#define CASE_PERMUTE_TILE_8x8_4x4_4D_2 {1, 8, 5, 2}, {1, 2, 8, 5}, {0, 3, 1, 2}, tensor{0}, data_types::f32, format::bfyx, data_types::f32, format::bfyx
#define CASE_PERMUTE_TILE_8x8_4x4_4D_3 {1, 5, 5, 2}, {1, 2, 5, 5}, {0, 3, 1, 2}, tensor{0}, data_types::f32, format::bfyx, data_types::f32, format::bfyx
#define CASE_PERMUTE_TILE_8x8_4x4_5D_0 {1, 8, 8, 2, 2}, {1, 2, 8, 8, 2}, {0, 4, 1, 2, 3}, tensor{0}, data_types::f32, format::bfzyx, data_types::f32, format::bfzyx
#define CASE_PERMUTE_TILE_8x8_4x4_5D_1 {1, 5, 8, 2, 2}, {1, 2, 5, 8, 2}, {0, 4, 1, 2, 3}, tensor{0}, data_types::f32, format::bfzyx, data_types::f32, format::bfzyx
#define CASE_PERMUTE_TILE_8x8_4x4_5D_2 {1, 8, 5, 2, 2}, {1, 2, 8, 5, 2}, {0, 4, 1, 2, 3}, tensor{0}, data_types::f32, format::bfzyx, data_types::f32, format::bfzyx
#define CASE_PERMUTE_TILE_8x8_4x4_5D_3 {1, 5, 5, 2, 2}, {1, 2, 5, 5, 2}, {0, 4, 1, 2, 3}, tensor{0}, data_types::f32, format::bfzyx, data_types::f32, format::bfzyx
#define CASE_PERMUTE_TILE_8x8_4x4_6D_0 {1, 8, 8, 2, 2, 2}, {1, 2, 8, 8, 2, 2}, {0, 5, 1, 2, 3, 4}, tensor{0}, data_types::f32, format::bfwzyx, data_types::f32, format::bfwzyx
#define CASE_PERMUTE_TILE_8x8_4x4_6D_1 {1, 5, 8, 2, 2, 2}, {1, 2, 5, 8, 2, 2}, {0, 5, 1, 2, 3, 4}, tensor{0}, data_types::f32, format::bfwzyx, data_types::f32, format::bfwzyx
#define CASE_PERMUTE_TILE_8x8_4x4_6D_2 {1, 8, 5, 2, 2, 2}, {1, 2, 8, 5, 2, 2}, {0, 5, 1, 2, 3, 4}, tensor{0}, data_types::f32, format::bfwzyx, data_types::f32, format::bfwzyx
#define CASE_PERMUTE_TILE_8x8_4x4_6D_3 {1, 5, 5, 2, 2, 2}, {1, 2, 5, 5, 2, 2}, {0, 5, 1, 2, 3, 4}, tensor{0}, data_types::f32, format::bfwzyx, data_types::f32, format::bfwzyx


class PermuteFusingTest : public ::BaseFusingTest<permute_params> {
public:

Expand Down Expand Up @@ -6138,6 +6153,20 @@ INSTANTIATE_TEST_CASE_P(fusings_gpu, permute_activation_scale_eltwise,
permute_params{CASE_PERMUTE_U8_3D_1, 2, 5},
permute_params{CASE_PERMUTE_U8_3D_2, 2, 5},
permute_params{CASE_PERMUTE_U8_3D_3, 2, 5},

// Fusing tests for permute_tile_8x8_4x4
permute_params{CASE_PERMUTE_TILE_8x8_4x4_4D_0, 2, 5},
permute_params{CASE_PERMUTE_TILE_8x8_4x4_4D_1, 2, 5},
permute_params{CASE_PERMUTE_TILE_8x8_4x4_4D_2, 2, 5},
permute_params{CASE_PERMUTE_TILE_8x8_4x4_4D_3, 2, 5},
permute_params{CASE_PERMUTE_TILE_8x8_4x4_5D_0, 2, 5},
permute_params{CASE_PERMUTE_TILE_8x8_4x4_5D_1, 2, 5},
permute_params{CASE_PERMUTE_TILE_8x8_4x4_5D_2, 2, 5},
permute_params{CASE_PERMUTE_TILE_8x8_4x4_5D_3, 2, 5},
permute_params{CASE_PERMUTE_TILE_8x8_4x4_6D_0, 2, 5},
permute_params{CASE_PERMUTE_TILE_8x8_4x4_6D_1, 2, 5},
permute_params{CASE_PERMUTE_TILE_8x8_4x4_6D_2, 2, 5},
permute_params{CASE_PERMUTE_TILE_8x8_4x4_6D_3, 2, 5},
}), );

class permute_quant_u8: public PermuteFusingTest {};
Expand Down Expand Up @@ -6317,6 +6346,20 @@ INSTANTIATE_TEST_CASE_P(fusings_gpu, permute_scale_eltwise_actv_scale_actv,
permute_params{CASE_PERMUTE_U8_3D_1, 2, 7},
permute_params{CASE_PERMUTE_U8_3D_2, 2, 7},
permute_params{CASE_PERMUTE_U8_3D_3, 2, 7},

// Fusing tests for permute_tile_8x8_4x4
permute_params{CASE_PERMUTE_TILE_8x8_4x4_4D_0, 2, 7},
permute_params{CASE_PERMUTE_TILE_8x8_4x4_4D_1, 2, 7},
permute_params{CASE_PERMUTE_TILE_8x8_4x4_4D_2, 2, 7},
permute_params{CASE_PERMUTE_TILE_8x8_4x4_4D_3, 2, 7},
permute_params{CASE_PERMUTE_TILE_8x8_4x4_5D_0, 2, 7},
permute_params{CASE_PERMUTE_TILE_8x8_4x4_5D_1, 2, 7},
permute_params{CASE_PERMUTE_TILE_8x8_4x4_5D_2, 2, 7},
permute_params{CASE_PERMUTE_TILE_8x8_4x4_5D_3, 2, 7},
permute_params{CASE_PERMUTE_TILE_8x8_4x4_6D_0, 2, 7},
permute_params{CASE_PERMUTE_TILE_8x8_4x4_6D_1, 2, 7},
permute_params{CASE_PERMUTE_TILE_8x8_4x4_6D_2, 2, 7},
permute_params{CASE_PERMUTE_TILE_8x8_4x4_6D_3, 2, 7},
}), );

class NormalizeFusingTest : public ::BaseFusingTest<normalize_test_params> {
Expand Down
Loading

0 comments on commit 9f23a8a

Please sign in to comment.