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
155e955f
Commit
155e955f
authored
Oct 25, 2018
by
Wuwei Lin
Committed by
Tianqi Chen
Oct 24, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix int8x4 broadcast value codegen in cuda (#1959)
parent
3bfa5fc0
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
src/codegen/codegen_cuda.cc
+10
-0
tests/python/unittest/test_codegen_cuda.py
+23
-0
No files found.
src/codegen/codegen_cuda.cc
View file @
155e955f
...
...
@@ -273,6 +273,16 @@ void CodeGenCUDA::VisitExpr_(const Ramp* op, std::ostream& os) {
}
void
CodeGenCUDA
::
VisitExpr_
(
const
Broadcast
*
op
,
std
::
ostream
&
os
)
{
// NOLINT(*)
if
(
op
->
type
.
is_int
()
&&
op
->
type
.
bits
()
==
8
&&
op
->
lanes
==
4
)
{
// make_int8x4
const
int64_t
*
p
=
as_const_int
(
op
->
value
);
CHECK
(
p
);
int64_t
v
=
*
p
&
0xFF
;
v
=
(
v
<<
24
)
|
(
v
<<
16
)
|
(
v
<<
8
)
|
v
;
os
<<
"(int)"
<<
v
;
return
;
}
std
::
string
v
=
PrintExpr
(
op
->
value
);
os
<<
"make_"
;
PrintType
(
op
->
type
,
os
);
...
...
tests/python/unittest/test_codegen_cuda.py
View file @
155e955f
...
...
@@ -87,7 +87,30 @@ def test_cuda_vectorize_load():
check_cuda
(
"int8"
,
64
,
8
)
check_cuda
(
"int8"
,
64
,
16
)
def
test_cuda_make_int8x4
():
def
check_cuda
(
n
,
value
):
if
not
tvm
.
gpu
(
0
)
.
exist
or
not
tvm
.
module
.
enabled
(
"cuda"
):
print
(
"skip because cuda is not enabled.."
)
return
lanes
=
4
dtype
=
'int8'
ctx
=
tvm
.
gpu
(
0
)
A
=
tvm
.
compute
((
n
,
lanes
),
lambda
i
,
j
:
tvm
.
const
(
value
,
dtype
=
dtype
))
s
=
tvm
.
create_schedule
(
A
.
op
)
y
,
x
=
s
[
A
]
.
op
.
axis
s
[
A
]
.
vectorize
(
x
)
s
[
A
]
.
bind
(
y
,
tvm
.
thread_axis
(
"blockIdx.x"
))
fun
=
tvm
.
build
(
s
,
[
A
],
"cuda"
,
name
=
"make_int8x4"
)
np_a
=
np
.
full
((
n
,
lanes
),
value
,
dtype
=
dtype
)
a
=
tvm
.
nd
.
empty
(
np_a
.
shape
,
dtype
,
ctx
)
fun
(
a
)
np
.
testing
.
assert_equal
(
a
.
asnumpy
(),
np_a
)
check_cuda
(
64
,
0xAB
)
check_cuda
(
64
,
0
)
check_cuda
(
64
,
-
3
)
if
__name__
==
"__main__"
:
test_cuda_vectorize_add
()
test_cuda_multiply_add
()
test_cuda_vectorize_load
()
test_cuda_make_int8x4
()
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