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
fed79b3a
Commit
fed79b3a
authored
Nov 13, 2019
by
Animesh Jain
Committed by
Zhi
Nov 13, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[QNN] Quantize - Fixing the sequence of lowering. (#4316)
parent
dc5f70ad
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
src/relay/qnn/op/quantize.cc
+5
-5
No files found.
src/relay/qnn/op/quantize.cc
View file @
fed79b3a
...
...
@@ -48,8 +48,8 @@ bool QuantizeRel(const Array<Type>& types,
const
auto
*
quantize_attrs
=
attrs
.
as
<
QuantizeAttrs
>
();
const
Array
<
tvm
::
Expr
>
oshape
=
data
->
shape
;
const
DataType
out_dtype
=
quantize_attrs
->
out_dtype
;
CHECK
(
out_dtype
==
Int
(
8
)
||
out_dtype
==
UInt
(
8
))
<<
"Output type should be one of [int8, unit8
] but was "
<<
out_dtype
;
CHECK
(
out_dtype
==
Int
(
8
)
||
out_dtype
==
UInt
(
8
)
||
out_dtype
==
Int
(
32
)
)
<<
"Output type should be one of [int8, unit8
, int32
] but was "
<<
out_dtype
;
// assign output type
reporter
->
Assign
(
types
[
1
],
TensorTypeNode
::
make
(
oshape
,
out_dtype
));
return
true
;
...
...
@@ -72,12 +72,12 @@ Expr MakeQuantize(Expr data,
Expr
QuantizeLower
(
const
Expr
&
input_tensor
,
const
QuantizeAttrs
*
attrs
)
{
const
auto
out_dtype
=
attrs
->
out_dtype
;
const
auto
output_zero_point
=
MakeConstantScalar
(
In
t
(
32
),
attrs
->
output_zero_point
);
const
auto
output_zero_point
=
MakeConstantScalar
(
Floa
t
(
32
),
attrs
->
output_zero_point
);
const
auto
scale
=
MakeConstantScalar
(
Float
(
32
),
attrs
->
output_scale
);
const
int32_t
min_val
=
GetQmin
(
out_dtype
);
const
int32_t
max_val
=
GetQmax
(
out_dtype
);
auto
scale_data
=
Cast
(
Round
(
Divide
(
input_tensor
,
scale
)),
Int
(
32
)
);
auto
add_zero_point
=
Add
(
scale_data
,
output_zero_point
);
auto
scale_data
=
Divide
(
input_tensor
,
scale
);
auto
add_zero_point
=
Cast
(
Round
(
Add
(
scale_data
,
output_zero_point
)),
Int
(
32
)
);
auto
clamped_output
=
Clip
(
add_zero_point
,
min_val
,
max_val
);
auto
clamp_out_dtype
=
Cast
(
clamped_output
,
out_dtype
);
return
clamp_out_dtype
;
...
...
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