Browse Source

fix crash on non-arm82 build

tags/20200916
nihui 6 years ago
parent
commit
54e79a62d7
2 changed files with 28 additions and 10 deletions
  1. +12
    -8
      src/layer.cpp
  2. +16
    -2
      src/net.cpp

+ 12
- 8
src/layer.cpp View File

@@ -232,6 +232,8 @@ Layer* create_layer(int index)
if (index < 0 || index >= layer_registry_entry_count)
return 0;

// clang-format off
// *INDENT-OFF*
layer_creator_func layer_creator = 0;
#if NCNN_RUNTIME_CPU && NCNN_AVX2
if (ncnn::cpu_support_x86_avx2())
@@ -241,15 +243,17 @@ Layer* create_layer(int index)
else
#endif // NCNN_RUNTIME_CPU && NCNN_AVX2
#if NCNN_RUNTIME_CPU && NCNN_ARM82
if (ncnn::cpu_support_arm_asimdhp())
{
layer_creator = layer_registry_arm82[index].creator;
}
else
if (ncnn::cpu_support_arm_asimdhp())
{
layer_creator = layer_registry_arm82[index].creator;
}
else
#endif // NCNN_RUNTIME_CPU && NCNN_ARM82
{
layer_creator = layer_registry[index].creator;
}
{
layer_creator = layer_registry[index].creator;
}
// *INDENT-ON*
// clang-format on
if (!layer_creator)
return 0;



+ 16
- 2
src/net.cpp View File

@@ -1129,6 +1129,9 @@ int Net::forward_layer(int layer_index, std::vector<Mat>& blob_mats, const Optio
}
}

// clang-format off
// *INDENT-OFF*
#if NCNN_ARM82
if (opt.use_fp16_storage && cpu_support_arm_asimdhp())
{
if (bottom_blob.elemsize / bottom_blob.elempack == 4u && layer->support_fp16_storage)
@@ -1144,7 +1147,9 @@ int Net::forward_layer(int layer_index, std::vector<Mat>& blob_mats, const Optio
bottom_blob = bottom_blob_fp32;
}
}
else if (opt.use_bf16_storage)
else
#endif // NCNN_ARM82
if (opt.use_bf16_storage)
{
if (bottom_blob.elemsize / bottom_blob.elempack == 4u && layer->support_bf16_storage)
{
@@ -1159,6 +1164,8 @@ int Net::forward_layer(int layer_index, std::vector<Mat>& blob_mats, const Optio
bottom_blob = bottom_blob_fp32;
}
}
// *INDENT-ON*
// clang-format on

if (opt.use_packing_layout)
{
@@ -1255,6 +1262,9 @@ int Net::forward_layer(int layer_index, std::vector<Mat>& blob_mats, const Optio
}
}

// clang-format off
// *INDENT-OFF*
#if NCNN_ARM82
if (opt.use_fp16_storage && cpu_support_arm_asimdhp())
{
if (bottom_blobs[i].elemsize / bottom_blobs[i].elempack == 4u && layer->support_fp16_storage)
@@ -1270,7 +1280,9 @@ int Net::forward_layer(int layer_index, std::vector<Mat>& blob_mats, const Optio
bottom_blobs[i] = bottom_blob_fp32;
}
}
else if (opt.use_bf16_storage)
else
#endif // NCNN_ARM82
if (opt.use_bf16_storage)
{
if (bottom_blobs[i].elemsize / bottom_blobs[i].elempack == 4u && layer->support_bf16_storage)
{
@@ -1285,6 +1297,8 @@ int Net::forward_layer(int layer_index, std::vector<Mat>& blob_mats, const Optio
bottom_blobs[i] = bottom_blob_fp32;
}
}
// *INDENT-ON*
// clang-format on

if (opt.use_packing_layout)
{


Loading…
Cancel
Save