Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
N
ngraph
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ngraph
Commits
8bfc2848
Commit
8bfc2848
authored
Aug 17, 2019
by
Nagy Mostafa
Committed by
Scott Cyphers
Aug 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[MLIR] Use f64 APFloat (#3453)
* Use f64 APFloat * PR feedback
parent
2ff6995e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
28 deletions
+30
-28
lowerer.cpp
src/contrib/mlir/lowerer.cpp
+30
-28
No files found.
src/contrib/mlir/lowerer.cpp
View file @
8bfc2848
...
...
@@ -100,6 +100,8 @@ namespace
PatternRewriter
&
rewriter
,
DialectLoweringPass
&
pass
);
ValueHandle
createZeroConstant
(
mlir
::
Type
type
);
/// Conversion from types in the nGraph dialect to the Standard dialect.
class
NGraphTypeConverter
:
public
TypeConverter
{
...
...
@@ -509,20 +511,8 @@ namespace
LoopNestBuilder
(
pivs
,
lbs
,
ubs
,
steps
)([
&
]
{
ValueHandle
val
=
iLHS
(
ivs
);
if
(
auto
floatTy
=
elemTy
.
dyn_cast
<
FloatType
>
())
{
ValueHandle
zero
=
intrinsics
::
constant_float
(
llvm
::
APFloat
(
0.0
f
),
floatTy
);
iRes
(
ivs
)
=
intrinsics
::
select
(
val
>
zero
,
val
,
zero
);
}
else
if
(
auto
intTy
=
elemTy
.
dyn_cast
<
IntegerType
>
())
{
ValueHandle
zero
=
intrinsics
::
constant_int
(
0
,
intTy
.
getWidth
());
iRes
(
ivs
)
=
intrinsics
::
select
(
val
>
zero
,
val
,
zero
);
}
else
{
NGRAPH_CHECK
(
false
,
"Unsupported type for Relu"
);
}
ValueHandle
zero
=
createZeroConstant
(
elemTy
);
iRes
(
ivs
)
=
intrinsics
::
select
(
val
>
zero
,
val
,
zero
);
});
rewriter
.
replaceOp
(
op
,
{
result
});
...
...
@@ -840,20 +830,8 @@ namespace
ValueHandle
val
=
iLHS
(
ivs
);
if
(
isa
<
NGNegOp
>
(
op
))
{
if
(
auto
floatTy
=
elemTy
.
dyn_cast
<
FloatType
>
())
{
ValueHandle
zero
=
intrinsics
::
constant_float
(
llvm
::
APFloat
(
0.0
f
),
floatTy
);
iRes
(
ivs
)
=
zero
-
val
;
}
else
if
(
auto
intTy
=
elemTy
.
dyn_cast
<
IntegerType
>
())
{
ValueHandle
zero
=
intrinsics
::
constant_int
(
0
,
intTy
.
getWidth
());
iRes
(
ivs
)
=
zero
-
val
;
}
else
{
NGRAPH_CHECK
(
false
,
"Unsupported type for Negative"
);
}
ValueHandle
zero
=
createZeroConstant
(
elemTy
);
iRes
(
ivs
)
=
zero
-
val
;
}
else
{
...
...
@@ -1029,6 +1007,30 @@ namespace
rewriter
.
replaceOp
(
op
,
result
);
}
ValueHandle
createZeroConstant
(
mlir
::
Type
type
)
{
if
(
auto
floatTy
=
type
.
dyn_cast
<
FloatType
>
())
{
if
(
floatTy
.
isF32
())
{
return
intrinsics
::
constant_float
(
llvm
::
APFloat
(
0.0
f
),
floatTy
);
}
else
if
(
floatTy
.
isF64
())
{
return
intrinsics
::
constant_float
(
llvm
::
APFloat
(
0.0
),
floatTy
);
}
else
{
NGRAPH_UNREACHABLE
(
"Unsupported floating-point precision"
);
}
}
else
if
(
auto
intTy
=
type
.
dyn_cast
<
IntegerType
>
())
{
return
intrinsics
::
constant_int
(
0
,
intTy
.
getWidth
());
}
NGRAPH_UNREACHABLE
(
"Unsupported type"
);
}
}
namespace
mlir
...
...
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