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
cb465e7e
Commit
cb465e7e
authored
Feb 03, 2018
by
PENGUINLIONG
Committed by
Tianqi Chen
Feb 02, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix boolean type (#862)
parent
79d503fd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
10 deletions
+20
-10
src/codegen/spirv/ir_builder.cc
+20
-10
No files found.
src/codegen/spirv/ir_builder.cc
View file @
cb465e7e
...
...
@@ -311,17 +311,27 @@ Value IRBuilder::GetConst_(const SType& dtype, const uint64_t* pvalue) {
}
CHECK_LE
(
dtype
.
type
.
bits
(),
64
);
Value
ret
=
NewValue
(
dtype
,
kConstant
);
ib_
.
Begin
(
spv
::
OpConstant
).
AddSeq
(
dtype
,
ret
);
uint64_t
mask
=
0xFFFFFFFFUL
;
ib_
.
Add
(
static_cast
<
uint32_t
>
(
pvalue
[
0
]
&
mask
));
if
(
dtype
.
type
.
bits
()
>
32
)
{
if
(
dtype
.
type
.
is_int
())
{
int64_t
sign_mask
=
0xFFFFFFFFL
;
const
int64_t
*
sign_ptr
=
reinterpret_cast
<
const
int64_t
*>
(
pvalue
);
ib_
.
Add
(
static_cast
<
uint32_t
>
((
sign_ptr
[
0
]
>>
32L
)
&
sign_mask
));
if
(
1
==
dtype
.
type
.
bits
()
&&
dtype
.
is_uint
())
{
// Boolean types.
if
(
*
pvalue
)
{
ib_
.
Begin
(
spv
::
OpConstantTrue
).
AddSeq
(
ret
);
}
else
{
ib_
.
Add
(
static_cast
<
uint32_t
>
((
pvalue
[
0
]
>>
32UL
)
&
mask
));
ib_
.
Begin
(
spv
::
OpConstantFalse
).
AddSeq
(
ret
);
}
}
else
{
// Integral/floating-point types.
ib_
.
Begin
(
spv
::
OpConstant
).
AddSeq
(
dtype
,
ret
);
uint64_t
mask
=
0xFFFFFFFFUL
;
ib_
.
Add
(
static_cast
<
uint32_t
>
(
pvalue
[
0
]
&
mask
));
if
(
dtype
.
type
.
bits
()
>
32
)
{
if
(
dtype
.
type
.
is_int
())
{
int64_t
sign_mask
=
0xFFFFFFFFL
;
const
int64_t
*
sign_ptr
=
reinterpret_cast
<
const
int64_t
*>
(
pvalue
);
ib_
.
Add
(
static_cast
<
uint32_t
>
((
sign_ptr
[
0
]
>>
32L
)
&
sign_mask
));
}
else
{
ib_
.
Add
(
static_cast
<
uint32_t
>
((
pvalue
[
0
]
>>
32UL
)
&
mask
));
}
}
}
ib_
.
Commit
(
&
global_
);
...
...
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