Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 50 additions & 30 deletions tests/testutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,15 @@ int test_layer_gpu(int typeindex, const ncnn::ParamDict& pd, const std::vector<n
// FIXME fp16a may produce large error
opt.use_fp16_arithmetic = false;

// skip test for missed gpu capability
if ((_opt.use_fp16_storage && !opt.use_fp16_storage)
|| (_opt.use_fp16_arithmetic && !opt.use_fp16_arithmetic)
|| (_opt.use_bf16_storage && !opt.use_bf16_storage))
{
delete op;
return 233;
}

if (opt.use_bf16_packed || opt.use_bf16_storage)
{
// winograd produce large error
Expand Down Expand Up @@ -1502,6 +1511,15 @@ int test_layer_gpu(int typeindex, const ncnn::ParamDict& pd, const std::vector<n
// FIXME fp16a may produce large error
opt.use_fp16_arithmetic = false;

// skip test for missed gpu capability
if ((_opt.use_fp16_storage && !opt.use_fp16_storage)
|| (_opt.use_fp16_arithmetic && !opt.use_fp16_arithmetic)
|| (_opt.use_bf16_storage && !opt.use_bf16_storage))
{
delete op;
return 233;
}

if (opt.use_bf16_packed || opt.use_bf16_storage)
{
// winograd produce large error
Expand Down Expand Up @@ -2012,20 +2030,21 @@ int test_layer_opt(const char* layer_type, const ncnn::ParamDict& pd, const std:

int test_layer(const char* layer_type, const ncnn::ParamDict& pd, const std::vector<ncnn::Mat>& weights, const std::vector<ncnn::Mat>& a, int top_blob_count, float epsilon, int flag)
{
// pack fp16p fp16s fp16a bf16p/bf16s flag
const int options[][6] = {
{0, 0, 0, 0, 0, 0},
{0, 0, 1, 0, 0, 0},
{0, 0, 1, 1, 0, 0},
{0, 0, 0, 0, 1, 0},
{1, 0, 0, 0, 0, 0},
// pack fp16p fp16s fp16a bf16p bf16s flag
const int options[][7] = {
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 0, 0, 0, 0},
{0, 0, 1, 1, 0, 0, 0},
{0, 0, 0, 0, 0, 1, 0},
{1, 0, 0, 0, 0, 0, 0},
#if NCNN_VULKAN
{1, 1, 0, 0, 0, TEST_LAYER_DISABLE_CPU_TESTING},
{1, 1, 0, 1, 0, TEST_LAYER_DISABLE_CPU_TESTING},
{1, 1, 0, 0, 0, 0, TEST_LAYER_DISABLE_CPU_TESTING},
{1, 1, 0, 1, 0, 0, TEST_LAYER_DISABLE_CPU_TESTING},
{1, 0, 0, 0, 1, 0, TEST_LAYER_DISABLE_CPU_TESTING},
#endif // NCNN_VULKAN
{1, 0, 1, 0, 0, 0},
{1, 0, 1, 1, 0, 0},
{1, 0, 0, 0, 1, 0},
{1, 0, 1, 0, 0, 0, 0},
{1, 0, 1, 1, 0, 0, 0},
{1, 0, 0, 0, 0, 1, 0},
};

const int opt_count = sizeof(options) / sizeof(options[0]);
Expand All @@ -2039,9 +2058,9 @@ int test_layer(const char* layer_type, const ncnn::ParamDict& pd, const std::vec
opt.use_fp16_storage = options[i][2];
opt.use_fp16_arithmetic = options[i][3];
opt.use_bf16_packed = options[i][4];
opt.use_bf16_storage = options[i][4];
opt.use_bf16_storage = options[i][5];

int ret = test_layer_opt(layer_type, pd, weights, opt, a, top_blob_count, epsilon, flag | options[i][5]);
int ret = test_layer_opt(layer_type, pd, weights, opt, a, top_blob_count, epsilon, flag | options[i][6]);
if (ret != 0)
return ret;
}
Expand All @@ -2051,20 +2070,21 @@ int test_layer(const char* layer_type, const ncnn::ParamDict& pd, const std::vec

int test_layer(const char* layer_type, const ncnn::ParamDict& pd, const std::vector<ncnn::Mat>& weights, const ncnn::Mat& a, float epsilon, int flag)
{
// pack fp16p fp16s fp16a bf16p/bf16s flag
const int options[][6] = {
{0, 0, 0, 0, 0, 0},
{0, 0, 1, 0, 0, 0},
{0, 0, 1, 1, 0, 0},
{0, 0, 0, 0, 1, 0},
{1, 0, 0, 0, 0, 0},
// pack fp16p fp16s fp16a bf16p bf16s flag
const int options[][7] = {
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 0, 0, 0, 0},
{0, 0, 1, 1, 0, 0, 0},
{0, 0, 0, 0, 0, 1, 0},
{1, 0, 0, 0, 0, 0, 0},
#if NCNN_VULKAN
{1, 1, 0, 0, 0, TEST_LAYER_DISABLE_CPU_TESTING},
{1, 1, 0, 1, 0, TEST_LAYER_DISABLE_CPU_TESTING},
{1, 1, 0, 0, 0, 0, TEST_LAYER_DISABLE_CPU_TESTING},
{1, 1, 0, 1, 0, 0, TEST_LAYER_DISABLE_CPU_TESTING},
{1, 0, 0, 0, 1, 0, TEST_LAYER_DISABLE_CPU_TESTING},
#endif // NCNN_VULKAN
{1, 0, 1, 0, 0, 0},
{1, 0, 1, 1, 0, 0},
{1, 0, 0, 0, 1, 0},
{1, 0, 1, 0, 0, 0, 0},
{1, 0, 1, 1, 0, 0, 0},
{1, 0, 0, 0, 0, 1, 0},
};

const int opt_count = sizeof(options) / sizeof(options[0]);
Expand All @@ -2078,9 +2098,9 @@ int test_layer(const char* layer_type, const ncnn::ParamDict& pd, const std::vec
opt.use_fp16_storage = options[i][2];
opt.use_fp16_arithmetic = options[i][3];
opt.use_bf16_packed = options[i][4];
opt.use_bf16_storage = options[i][4];
opt.use_bf16_storage = options[i][5];

int ret = test_layer_opt(layer_type, pd, weights, opt, a, epsilon, flag | options[i][5]);
int ret = test_layer_opt(layer_type, pd, weights, opt, a, epsilon, flag | options[i][6]);
if (ret != 0)
return ret;
}
Expand Down Expand Up @@ -2463,7 +2483,7 @@ int test_layer_oom_opt(const char* layer_type, const ncnn::ParamDict& pd, const

int test_layer_oom(const char* layer_type, const ncnn::ParamDict& pd, const std::vector<ncnn::Mat>& weights, const std::vector<ncnn::Mat>& a, int top_blob_count, int flag)
{
// pack fp16p fp16s fp16a bf16s
// pack fp16p fp16s fp16a bf16p/bf16s
const int options[][5] = {
{0, 0, 0, 0, 0},
{0, 0, 1, 0, 0},
Expand Down Expand Up @@ -2498,7 +2518,7 @@ int test_layer_oom(const char* layer_type, const ncnn::ParamDict& pd, const std:

int test_layer_oom(const char* layer_type, const ncnn::ParamDict& pd, const std::vector<ncnn::Mat>& weights, const ncnn::Mat& a, int flag)
{
// pack fp16p fp16s fp16a bf16s
// pack fp16p fp16s fp16a bf16p/bf16s
const int options[][5] = {
{0, 0, 0, 0, 0},
{0, 0, 1, 0, 0},
Expand Down
Loading