Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tic
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenyuanbo
tic
Commits
975ab75c
Commit
975ab75c
authored
Aug 15, 2019
by
Wuwei Lin
Committed by
ziheng
Aug 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Relay][Quantization] Fix out-of-date realize (#3790)
parent
d3eb9cb8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
8 deletions
+13
-8
src/relay/pass/quantize/realize.cc
+13
-8
No files found.
src/relay/pass/quantize/realize.cc
View file @
975ab75c
...
...
@@ -110,7 +110,6 @@ inline Expr MulAndDiv(Expr data, float s1, float s2, DataType dtype) {
}
else
if
(
static_cast
<
int
>
(
factor
)
==
factor
)
{
return
Multiply
(
data
,
MakeConstantScalar
(
dtype
,
factor
));
}
else
{
LOG
(
FATAL
)
<<
"fall back to float computation"
;
data
=
Cast
(
data
,
Float
(
32
));
data
=
Multiply
(
data
,
MakeConstantScalar
(
Float
(
32
),
factor
));
return
Cast
(
Round
(
data
),
dtype
);
...
...
@@ -147,15 +146,21 @@ Expr QuantizeRealize(const Call& ref_call,
}
float
shift_nbit
=
std
::
log2
(
odom_scale_imm
/
idom_scale_imm
);
CHECK_
GT
(
shift_nbit
,
0
);
CHECK_
NE
(
shift_nbit
,
0
);
if
(
static_cast
<
int
>
(
shift_nbit
)
==
shift_nbit
)
{
// use right shift
if
(
cfg
->
round_for_shift
)
{
float
round_bias
=
std
::
pow
(
2.0
,
shift_nbit
-
1
);
data
=
Add
(
data
,
MakeConstantScalar
(
cfg
->
dtype_activation
,
static_cast
<
int
>
(
round_bias
)));
if
(
shift_nbit
>
0
)
{
// use right shift
if
(
cfg
->
round_for_shift
)
{
float
round_bias
=
std
::
pow
(
2.0
,
shift_nbit
-
1
);
data
=
Add
(
data
,
MakeConstantScalar
(
cfg
->
dtype_activation
,
static_cast
<
int
>
(
round_bias
)));
}
data
=
RightShift
(
data
,
MakeConstantScalar
(
cfg
->
dtype_activation
,
static_cast
<
int
>
(
shift_nbit
)));
}
else
{
data
=
LeftShift
(
data
,
MakeConstantScalar
(
cfg
->
dtype_activation
,
static_cast
<
int
>
(
shift_nbit
)));
}
data
=
RightShift
(
data
,
MakeConstantScalar
(
cfg
->
dtype_activation
,
static_cast
<
int
>
(
shift_nbit
)));
data
=
Clip
(
data
,
clip_min_imm
,
clip_max_imm
);
return
QRealizeIntExprNode
::
make
(
data
,
dom_scale
,
n
->
dtype
);
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment