This website works better with JavaScript.
Home
Issues
Pull Requests
Milestones
AI流水线
Repositories
Datasets
Forum
实训
竞赛
大数据
AI开发
Register
Sign In
nihui
/
ncnn
Not watched
Unwatch
Watch all
Watch but not notify
1
Star
0
Fork
0
Code
Releases
46
Wiki
evaluate
Activity
Issues
0
Pull Requests
0
Datasets
Model
Cloudbrain
HPC
Browse Source
fix armv7 roundmode (
#3176
)
tags/20211122
nihui
GitHub
4 years ago
parent
ec561736a5
commit
e9b5bbcd2d
No known key found for this signature in database
GPG Key ID:
4AEE18F83AFDEB23
3 changed files
with
35 additions
and
0 deletions
Split View
Diff Options
Show Stats
Download Patch File
Download Diff File
+31
-0
src/layer/arm/arm_usability.h
+2
-0
src/layer/arm/quantize_arm.cpp
+2
-0
src/layer/arm/requantize_arm.cpp
+ 31
- 0
src/layer/arm/arm_usability.h
View File
@@ -15,6 +15,37 @@
#ifndef ARM_USABILITY_H
#define ARM_USABILITY_H
class FPSCRGuard
{
#if !__aarch64__
public:
FPSCRGuard()
{
// set round mode to round to nearest for armv7
// this impacts all vcvtr instructions in guarded scope
asm volatile(
"vmrs %0, FPSCR \n"
"bic r10, %0, #0x00c00000 \n"
"vmsr FPSCR, r10 \n"
: "=r"(FPSCR_value)
:
: "memory", "r10");
}
~FPSCRGuard()
{
asm volatile(
"vmsr FPSCR, %0 \n"
:
: "r"(FPSCR_value)
: "memory");
}
private:
int FPSCR_value;
#endif // !__aarch64__
};
static inline signed char float2int8(float v)
{
int int32 = round(v);
+ 2
- 0
src/layer/arm/quantize_arm.cpp
View File
@@ -41,6 +41,8 @@ Quantize_arm::Quantize_arm()
int Quantize_arm::forward(const Mat& bottom_blob, Mat& top_blob, const Option& opt) const
{
FPSCRGuard fpscr_guard;
int elembits = bottom_blob.elembits();
#if __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
+ 2
- 0
src/layer/arm/requantize_arm.cpp
View File
@@ -42,6 +42,8 @@ Requantize_arm::Requantize_arm()
int Requantize_arm::forward(const Mat& bottom_blob, Mat& top_blob, const Option& opt) const
{
FPSCRGuard fpscr_guard;
int dims = bottom_blob.dims;
int elempack = bottom_blob.elempack;
Write
Preview
Loading…
Cancel
Save