Skip to content

Commit

Permalink
fix potential fp16s bf16s conflicts on armv7 vfpv4
Browse files Browse the repository at this point in the history
  • Loading branch information
nihui committed Jul 11, 2024
1 parent c59885a commit 6aa28af
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ int NetPrivate::convert_layout(Mat& bottom_blob, const Layer* layer, const Optio
// *INDENT-OFF*

#if NCNN_VFPV4
if (opt.use_fp16_storage && cpu_support_arm_vfpv4() && layer->support_fp16_storage)
if (opt.use_fp16_storage && !opt.use_bf16_storage && cpu_support_arm_vfpv4() && layer->support_fp16_storage)
{
Mat bottom_blob_fp16;
cast_float32_to_float16(bottom_blob, bottom_blob_fp16, opt);
Expand Down Expand Up @@ -741,7 +741,7 @@ int NetPrivate::convert_layout(Mat& bottom_blob, const Layer* layer, const Optio
// *INDENT-OFF*

#if NCNN_VFPV4
if (opt.use_fp16_storage && cpu_support_arm_vfpv4() && !layer->support_fp16_storage)
if (opt.use_fp16_storage && !opt.use_bf16_storage && cpu_support_arm_vfpv4() && !layer->support_fp16_storage)
{
Mat bottom_blob_fp32;
cast_float16_to_float32(bottom_blob, bottom_blob_fp32, opt);
Expand Down
4 changes: 2 additions & 2 deletions tests/testutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ static int convert_to_optimal_layout(const ncnn::Mat& a, ncnn::Mat& a4, const nc
// clang-format off
// *INDENT-OFF*
#if NCNN_VFPV4
if (opt.use_fp16_storage && ncnn::cpu_support_arm_vfpv4() && op->support_fp16_storage && !(flag & TEST_LAYER_DISABLE_AUTO_INPUT_CASTING))
if (opt.use_fp16_storage && !opt.use_bf16_storage && ncnn::cpu_support_arm_vfpv4() && op->support_fp16_storage && !(flag & TEST_LAYER_DISABLE_AUTO_INPUT_CASTING))
{
ncnn::cast_float32_to_float16(a, a4, opt);
}
Expand Down Expand Up @@ -450,7 +450,7 @@ static int convert_to_vanilla_layout(const ncnn::Mat& c4, ncnn::Mat& c, const nc
// clang-format off
// *INDENT-OFF*
#if NCNN_VFPV4
if (opt.use_fp16_storage && ncnn::cpu_support_arm_vfpv4() && op->support_fp16_storage && c4_unpacked.elembits() == 16)
if (opt.use_fp16_storage && !opt.use_bf16_storage && ncnn::cpu_support_arm_vfpv4() && op->support_fp16_storage && c4_unpacked.elembits() == 16)
{
ncnn::cast_float16_to_float32(c4_unpacked, c, opt);
}
Expand Down

0 comments on commit 6aa28af

Please sign in to comment.