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
7e5966a0
Commit
7e5966a0
authored
Jan 11, 2019
by
Sergei Grechanik
Committed by
Tianqi Chen
Jan 11, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[LLVM CodeGen] Partially disable unsafe fp math (#2422)
parent
394cf9f7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
2 deletions
+36
-2
src/codegen/llvm/llvm_common.cc
+2
-2
tests/python/unittest/test_codegen_llvm.py
+34
-0
No files found.
src/codegen/llvm/llvm_common.cc
View file @
7e5966a0
...
...
@@ -104,8 +104,8 @@ void ParseLLVMTargetOptions(const std::string& target_str,
opt
.
LessPreciseFPMADOption
=
true
;
#endif
opt
.
AllowFPOpFusion
=
llvm
::
FPOpFusion
::
Fast
;
opt
.
UnsafeFPMath
=
tru
e
;
opt
.
NoInfsFPMath
=
tru
e
;
opt
.
UnsafeFPMath
=
fals
e
;
opt
.
NoInfsFPMath
=
fals
e
;
opt
.
NoNaNsFPMath
=
true
;
if
(
soft_float_abi
)
{
opt
.
FloatABIType
=
llvm
::
FloatABI
::
Soft
;
...
...
tests/python/unittest/test_codegen_llvm.py
View file @
7e5966a0
...
...
@@ -422,6 +422,39 @@ def test_llvm_div():
check_llvm
(
123
,
133
,
d
,
'uint8'
)
check_llvm
(
0
,
256
,
d
,
'uint8'
)
def
test_llvm_fp_math
():
def
check_llvm_reciprocal
(
n
):
A
=
tvm
.
placeholder
((
n
,),
name
=
'A'
)
B
=
tvm
.
compute
((
n
,),
lambda
i
:
1.0
/
(
1e+37
*
A
[
i
]),
name
=
'B'
)
s
=
tvm
.
create_schedule
(
B
.
op
)
f
=
tvm
.
build
(
s
,
[
A
,
B
],
"llvm"
)
a
=
tvm
.
nd
.
array
(
np
.
full
((
n
,),
100
,
'float32'
))
b
=
tvm
.
nd
.
empty
((
n
,),
'float32'
)
f
(
a
,
b
)
tvm
.
testing
.
assert_allclose
(
b
.
asnumpy
(),
np
.
zeros
((
n
,),
'float32'
))
check_llvm_reciprocal
(
4
)
check_llvm_reciprocal
(
8
)
check_llvm_reciprocal
(
16
)
def
check_llvm_sigmoid
(
n
):
A
=
tvm
.
placeholder
((
n
,),
name
=
'A'
)
B
=
tvm
.
compute
((
n
,),
lambda
i
:
tvm
.
sigmoid
(
A
[
i
]),
name
=
'B'
)
s
=
tvm
.
create_schedule
(
B
.
op
)
f
=
tvm
.
build
(
s
,
[
A
,
B
],
"llvm"
)
a
=
tvm
.
nd
.
array
(
np
.
full
((
n
,),
-
1000
,
'float32'
))
b
=
tvm
.
nd
.
empty
((
n
,),
'float32'
)
f
(
a
,
b
)
tvm
.
testing
.
assert_allclose
(
b
.
asnumpy
(),
np
.
zeros
((
n
,),
'float32'
))
check_llvm_sigmoid
(
4
)
check_llvm_sigmoid
(
8
)
check_llvm_sigmoid
(
16
)
if
__name__
==
"__main__"
:
test_llvm_import
()
test_alignment
()
...
...
@@ -439,3 +472,4 @@ if __name__ == "__main__":
test_llvm_temp_space
()
test_llvm_lookup_intrin
()
test_llvm_div
()
test_llvm_fp_math
()
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