Skip to content

Commit

Permalink
zfh to zvfh
Browse files Browse the repository at this point in the history
  • Loading branch information
nihui committed Aug 21, 2024
1 parent 2092d66 commit d1ff67f
Show file tree
Hide file tree
Showing 54 changed files with 155 additions and 155 deletions.
10 changes: 5 additions & 5 deletions src/layer/riscv/absval_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ static inline vfloat32m8_t __riscv_vfabs_v_f32m8_absval(vfloat32m8_t op1, size_t
{
return __riscv_vfsgnjx_vv_f32m8(op1, op1, vl);
}
#if __riscv_zfh
#if __riscv_zvfh
static inline vfloat16m8_t __riscv_vfabs_v_f16m8_absval(vfloat16m8_t op1, size_t vl)
{
return __riscv_vfsgnjx_vv_f16m8(op1, op1, vl);
}
#endif // __riscv_zfh
#endif // __riscv_zvfh
#endif // __riscv_vector

namespace ncnn {
Expand All @@ -35,15 +35,15 @@ AbsVal_riscv::AbsVal_riscv()
{
#if __riscv_vector
support_packing = true;
#if __riscv_zfh
#if __riscv_zvfh
support_fp16_storage = true;
#endif
#endif // __riscv_vector
}

int AbsVal_riscv::forward_inplace(Mat& bottom_top_blob, const Option& opt) const
{
#if __riscv_vector && __riscv_zfh
#if __riscv_vector && __riscv_zvfh
int elembits = bottom_top_blob.elembits();

if (opt.use_fp16_storage && elembits == 16)
Expand Down Expand Up @@ -90,7 +90,7 @@ int AbsVal_riscv::forward_inplace(Mat& bottom_top_blob, const Option& opt) const
return 0;
}

#if __riscv_vector && __riscv_zfh
#if __riscv_vector && __riscv_zvfh
int AbsVal_riscv::forward_inplace_fp16s(Mat& bottom_top_blob, const Option& opt) const
{
int w = bottom_top_blob.w;
Expand Down
2 changes: 1 addition & 1 deletion src/layer/riscv/absval_riscv.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AbsVal_riscv : public AbsVal
virtual int forward_inplace(Mat& bottom_top_blob, const Option& opt) const;

protected:
#if __riscv_vector && __riscv_zfh
#if __riscv_vector && __riscv_zvfh
int forward_inplace_fp16s(Mat& bottom_top_blob, const Option& opt) const;
#endif
};
Expand Down
8 changes: 4 additions & 4 deletions src/layer/riscv/batchnorm_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ BatchNorm_riscv::BatchNorm_riscv()
{
#if __riscv_vector
support_packing = true;
#if __riscv_zfh
#if __riscv_zvfh
support_fp16_storage = true;
#endif
#endif // __riscv_vector
Expand All @@ -37,7 +37,7 @@ int BatchNorm_riscv::forward_inplace(Mat& bottom_top_blob, const Option& opt) co
#if __riscv_vector
int elembits = bottom_top_blob.elembits();

#if __riscv_zfh
#if __riscv_zvfh
if (opt.use_fp16_storage && elembits == 16)
{
if (opt.use_fp16_arithmetic)
Expand Down Expand Up @@ -224,7 +224,7 @@ int BatchNorm_riscv::forward_inplace(Mat& bottom_top_blob, const Option& opt) co
return 0;
}

#if __riscv_vector && __riscv_zfh
#if __riscv_vector && __riscv_zvfh
int BatchNorm_riscv::forward_inplace_fp16s(Mat& bottom_top_blob, const Option& opt) const
{
int dims = bottom_top_blob.dims;
Expand Down Expand Up @@ -533,5 +533,5 @@ int BatchNorm_riscv::forward_inplace_fp16sa(Mat& bottom_top_blob, const Option&
return 0;
}

#endif // __riscv_vector && __riscv_zfh
#endif // __riscv_vector && __riscv_zvfh
} // namespace ncnn
2 changes: 1 addition & 1 deletion src/layer/riscv/batchnorm_riscv.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class BatchNorm_riscv : public BatchNorm
virtual int forward_inplace(Mat& bottom_top_blob, const Option& opt) const;

protected:
#if __riscv_vector && __riscv_zfh
#if __riscv_vector && __riscv_zvfh
int forward_inplace_fp16s(Mat& bottom_top_blob, const Option& opt) const;
int forward_inplace_fp16sa(Mat& bottom_top_blob, const Option& opt) const;
#endif
Expand Down
12 changes: 6 additions & 6 deletions src/layer/riscv/binaryop_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#if __riscv_vector
#include <riscv_vector.h>
#include "rvv_mathfun.h"
#if __riscv_zfh
#if __riscv_zvfh
#include "rvv_mathfun_fp16s.h"
#endif
#endif // __riscv_vector
Expand All @@ -33,7 +33,7 @@ BinaryOp_riscv::BinaryOp_riscv()
{
#if __riscv_vector
support_packing = true;
#if __riscv_zfh
#if __riscv_zvfh
support_fp16_storage = true;
#endif
#endif
Expand Down Expand Up @@ -473,7 +473,7 @@ int BinaryOp_riscv::forward(const std::vector<Mat>& bottom_blobs, std::vector<Ma
{
int elembits = std::max(bottom_blobs[0].elembits(), bottom_blobs[1].elembits());

#if __riscv_vector && __riscv_zfh
#if __riscv_vector && __riscv_zvfh
if (opt.use_fp16_storage && elembits == 16)
{
return forward_fp16s(bottom_blobs, top_blobs, opt);
Expand Down Expand Up @@ -631,7 +631,7 @@ int BinaryOp_riscv::forward_inplace(Mat& bottom_top_blob, const Option& opt) con
{
int elembits = bottom_top_blob.elembits();

#if __riscv_zfh
#if __riscv_zvfh
if (opt.use_fp16_storage && elembits == 16)
{
return forward_inplace_fp16s(bottom_top_blob, opt);
Expand All @@ -643,7 +643,7 @@ int BinaryOp_riscv::forward_inplace(Mat& bottom_top_blob, const Option& opt) con
return 0;
}

#if __riscv_vector && __riscv_zfh
#if __riscv_vector && __riscv_zvfh
template<typename Op>
static void binary_op_vector_no_broadcast_fp16s(const __fp16* ptr, const __fp16* ptr1, __fp16* outptr, int size)
{
Expand Down Expand Up @@ -1205,6 +1205,6 @@ int BinaryOp_riscv::forward_inplace_fp16s(Mat& bottom_top_blob, const Option& op

return 0;
}
#endif // __riscv_vector && __riscv_zfh
#endif // __riscv_vector && __riscv_zvfh

} // namespace ncnn
2 changes: 1 addition & 1 deletion src/layer/riscv/binaryop_riscv.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class BinaryOp_riscv : public BinaryOp
virtual int forward_inplace(Mat& bottom_top_blob, const Option& opt) const;

protected:
#if __riscv_vector && __riscv_zfh
#if __riscv_vector && __riscv_zvfh
int forward_fp16s(const std::vector<Mat>& bottom_blobs, std::vector<Mat>& top_blobs, const Option& opt) const;
int forward_inplace_fp16s(Mat& bottom_top_blob, const Option& opt) const;
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/layer/riscv/cast_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Cast_riscv::Cast_riscv()
{
#if __riscv_vector
support_packing = true;
#if __riscv_zfh
#if __riscv_zvfh
support_fp16_storage = true;
#endif
#endif // __riscv_vector
Expand Down Expand Up @@ -89,7 +89,7 @@ int Cast_riscv::forward(const Mat& bottom_blob, Mat& top_blob, const Option& opt

int size = w * h * d * elempack;

#if __riscv_vector && __riscv_zfh
#if __riscv_vector && __riscv_zvfh
if (type_from == 1 && type_to == 2)
{
#pragma omp parallel for num_threads(opt.num_threads)
Expand Down Expand Up @@ -137,7 +137,7 @@ int Cast_riscv::forward(const Mat& bottom_blob, Mat& top_blob, const Option& opt
}
}
}
#endif // __riscv_vector && __riscv_zfh
#endif // __riscv_vector && __riscv_zvfh

if (type_from == 3 && type_to == 1)
{
Expand Down
10 changes: 5 additions & 5 deletions src/layer/riscv/clip_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#if __riscv_vector
#include <riscv_vector.h>
#include "rvv_mathfun.h"
#if __riscv_zfh
#if __riscv_zvfh
#include "rvv_mathfun_fp16s.h"
#endif
#endif // __riscv_vector
Expand All @@ -28,15 +28,15 @@ Clip_riscv::Clip_riscv()
{
#if __riscv_vector
support_packing = true;
#if __riscv_zfh
#if __riscv_zvfh
support_fp16_storage = true;
#endif
#endif // __riscv_vector
}

int Clip_riscv::forward_inplace(Mat& bottom_top_blob, const Option& opt) const
{
#if __riscv_vector && __riscv_zfh
#if __riscv_vector && __riscv_zvfh
int elembits = bottom_top_blob.elembits();

if (opt.use_fp16_storage && elembits == 16)
Expand Down Expand Up @@ -91,7 +91,7 @@ int Clip_riscv::forward_inplace(Mat& bottom_top_blob, const Option& opt) const
return 0;
}

#if __riscv_vector && __riscv_zfh
#if __riscv_vector && __riscv_zvfh
int Clip_riscv::forward_inplace_fp16s(Mat& bottom_top_blob, const Option& opt) const
{
int w = bottom_top_blob.w;
Expand Down Expand Up @@ -155,6 +155,6 @@ int Clip_riscv::forward_inplace_fp16sa(Mat& bottom_top_blob, const Option& opt)

return 0;
}
#endif // __riscv_vector && __riscv_zfh
#endif // __riscv_vector && __riscv_zvfh

} //namespace ncnn
2 changes: 1 addition & 1 deletion src/layer/riscv/clip_riscv.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Clip_riscv : public Clip
virtual int forward_inplace(Mat& bottom_top_blob, const Option& opt) const;

protected:
#if __riscv_vector && __riscv_zfh
#if __riscv_vector && __riscv_zvfh
int forward_inplace_fp16s(Mat& bottom_top_blob, const Option& opt) const;
int forward_inplace_fp16sa(Mat& bottom_top_blob, const Option& opt) const;
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/layer/riscv/concat_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Concat_riscv::Concat_riscv()
{
#if __riscv_vector
support_packing = true;
#if __riscv_zfh
#if __riscv_zvfh
support_fp16_storage = true;
#endif
#endif // __riscv_vector
Expand All @@ -40,7 +40,7 @@ int Concat_riscv::forward(const std::vector<Mat>& bottom_blobs, std::vector<Mat>
{
int elembits = bottom_blobs[0].elembits();

#if __riscv_vector && __riscv_zfh
#if __riscv_vector && __riscv_zvfh
if (opt.use_fp16_storage && elembits == 16)
return forward_bf16s_fp16s(bottom_blobs, top_blobs, opt);
#endif
Expand Down
10 changes: 5 additions & 5 deletions src/layer/riscv/convolution1d_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Convolution1D_riscv::Convolution1D_riscv()
{
#if __riscv_vector
support_packing = true;
#if __riscv_zfh
#if __riscv_zvfh
support_fp16_storage = true;
#endif
#endif // __riscv_vector
Expand All @@ -41,7 +41,7 @@ int Convolution1D_riscv::create_pipeline(const Option& opt)
if (dynamic_weight)
return 0;

#if __riscv_vector && __riscv_zfh
#if __riscv_vector && __riscv_zvfh
if (opt.use_fp16_storage)
{
return create_pipeline_fp16s(opt);
Expand Down Expand Up @@ -110,7 +110,7 @@ int Convolution1D_riscv::forward(const Mat& bottom_blob, Mat& top_blob, const Op
{
int elembits = bottom_blob.elembits();

#if __riscv_vector && __riscv_zfh
#if __riscv_vector && __riscv_zvfh
if (opt.use_fp16_storage && elembits == 16)
{
if (opt.use_fp16_arithmetic)
Expand Down Expand Up @@ -424,7 +424,7 @@ int Convolution1D_riscv::forward(const std::vector<Mat>& bottom_blobs, std::vect
return 0;
}

#if __riscv_vector && __riscv_zfh
#if __riscv_vector && __riscv_zvfh
int Convolution1D_riscv::create_pipeline_fp16s(const Option& opt)
{
const int packn = csrr_vlenb() / 2;
Expand Down Expand Up @@ -910,6 +910,6 @@ int Convolution1D_riscv::forward_fp16sa(const Mat& bottom_blob, Mat& top_blob, c

return 0;
}
#endif // __riscv_vector && __riscv_zfh
#endif // __riscv_vector && __riscv_zvfh

} // namespace ncnn
2 changes: 1 addition & 1 deletion src/layer/riscv/convolution1d_riscv.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Convolution1D_riscv : public Convolution1D
virtual int forward(const std::vector<Mat>& bottom_blobs, std::vector<Mat>& top_blobs, const Option& opt) const;

protected:
#if __riscv_vector && __riscv_zfh
#if __riscv_vector && __riscv_zvfh
int create_pipeline_fp16s(const Option& opt);
int forward_fp16s(const Mat& bottom_blob, Mat& top_blob, const Option& opt) const;
int forward_fp16sa(const Mat& bottom_blob, Mat& top_blob, const Option& opt) const;
Expand Down
12 changes: 6 additions & 6 deletions src/layer/riscv/convolution_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace ncnn {
#include "convolution_3x3_pack1ton.h"
#include "convolution_7x7_pack1ton.h"

#if __riscv_zfh
#if __riscv_zvfh
#include "convolution_fp16s.h"
#include "convolution_packn_fp16s.h"
#include "convolution_pack1ton_fp16s.h"
Expand All @@ -79,7 +79,7 @@ Convolution_riscv::Convolution_riscv()
{
#if __riscv_vector
support_packing = true;
#if __riscv_zfh
#if __riscv_zvfh
support_fp16_storage = true;
#endif
#endif // __riscv_vector
Expand Down Expand Up @@ -138,7 +138,7 @@ int Convolution_riscv::create_pipeline(const Option& opt)
}
#endif

#if __riscv_vector && __riscv_zfh
#if __riscv_vector && __riscv_zvfh
if (opt.use_fp16_storage)
{
return create_pipeline_fp16s(opt);
Expand Down Expand Up @@ -326,7 +326,7 @@ int Convolution_riscv::forward(const Mat& bottom_blob, Mat& top_blob, const Opti

int elembits = bottom_blob.elembits();

#if __riscv_vector && __riscv_zfh
#if __riscv_vector && __riscv_zvfh
if (opt.use_fp16_storage && elembits == 16)
{
if (opt.use_fp16_arithmetic)
Expand Down Expand Up @@ -715,7 +715,7 @@ int Convolution_riscv::forward(const std::vector<Mat>& bottom_blobs, std::vector
return 0;
}

#if __riscv_vector && __riscv_zfh
#if __riscv_vector && __riscv_zvfh
static void convolution_transform_kernel_packed_fp16s_rvv(const Mat& weight_data, Mat& weight_data_tm, int num_input, int num_output, int kernel_w, int kernel_h, int elempack, int out_elempack)
{
const int maxk = kernel_w * kernel_h;
Expand Down Expand Up @@ -1102,6 +1102,6 @@ int Convolution_riscv::forward_fp16sa(const Mat& bottom_blob, Mat& top_blob, con

return 0;
}
#endif // __riscv_vector && __riscv_zfh
#endif // __riscv_vector && __riscv_zvfh

} // namespace ncnn
2 changes: 1 addition & 1 deletion src/layer/riscv/convolution_riscv.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Convolution_riscv : public Convolution
virtual int forward(const std::vector<Mat>& bottom_blobs, std::vector<Mat>& top_blobs, const Option& opt) const;

protected:
#if __riscv_vector && __riscv_zfh
#if __riscv_vector && __riscv_zvfh
int create_pipeline_fp16s(const Option& opt);
int forward_fp16s(const Mat& bottom_blob, Mat& top_blob, const Option& opt) const;
int forward_fp16sa(const Mat& bottom_blob, Mat& top_blob, const Option& opt) const;
Expand Down
Loading

0 comments on commit d1ff67f

Please sign in to comment.