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
36f5ab7a
Commit
36f5ab7a
authored
Oct 08, 2019
by
Robert Kimball
Committed by
Scott Cyphers
Oct 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add bfloat16 to make_constant builder (#3741)
parent
b7d8c78b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
35 deletions
+43
-35
make_constant.hpp
src/ngraph/builder/make_constant.hpp
+43
-35
No files found.
src/ngraph/builder/make_constant.hpp
View file @
36f5ab7a
...
...
@@ -31,67 +31,75 @@ namespace ngraph
{
std
::
shared_ptr
<
Node
>
val
=
nullptr
;
if
(
type
==
element
::
f32
)
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch"
#pragma GCC diagnostic error "-Wswitch-enum"
#endif
switch
(
type
)
{
case
element
:
:
Type_t
::
f32
:
val
=
std
::
make_shared
<
ngraph
::
op
::
Constant
>
(
type
,
ngraph
::
Shape
{},
std
::
vector
<
float
>
{
static_cast
<
float
>
(
num
)});
}
else
if
(
type
==
element
::
f64
)
{
break
;
case
element
:
:
Type_t
::
f64
:
val
=
std
::
make_shared
<
ngraph
::
op
::
Constant
>
(
type
,
ngraph
::
Shape
{},
std
::
vector
<
double
>
{
static_cast
<
double
>
(
num
)});
}
else
if
(
type
==
element
::
f16
)
{
break
;
case
element
:
:
Type_t
::
f16
:
val
=
std
::
make_shared
<
ngraph
::
op
::
Constant
>
(
type
,
ngraph
::
Shape
{},
std
::
vector
<
ngraph
::
float16
>
{
ngraph
::
float16
(
static_cast
<
float
>
(
num
))});
}
else
if
(
type
==
element
::
i64
)
{
break
;
case
element
:
:
Type_t
::
bf16
:
val
=
std
::
make_shared
<
ngraph
::
op
::
Constant
>
(
type
,
ngraph
::
Shape
{},
std
::
vector
<
ngraph
::
bfloat16
>
{
ngraph
::
bfloat16
(
static_cast
<
float
>
(
num
))});
break
;
case
element
:
:
Type_t
::
i64
:
val
=
std
::
make_shared
<
ngraph
::
op
::
Constant
>
(
type
,
ngraph
::
Shape
{},
std
::
vector
<
int64_t
>
{
static_cast
<
int64_t
>
(
num
)});
}
else
if
(
type
==
element
::
i32
)
{
break
;
case
element
:
:
Type_t
::
i32
:
val
=
std
::
make_shared
<
ngraph
::
op
::
Constant
>
(
type
,
ngraph
::
Shape
{},
std
::
vector
<
int32_t
>
{
static_cast
<
int32_t
>
(
num
)});
}
else
if
(
type
==
element
::
i16
)
{
break
;
case
element
:
:
Type_t
::
i16
:
val
=
std
::
make_shared
<
ngraph
::
op
::
Constant
>
(
type
,
ngraph
::
Shape
{},
std
::
vector
<
int16_t
>
{
static_cast
<
int16_t
>
(
num
)});
}
else
if
(
type
==
element
::
i8
)
{
break
;
case
element
:
:
Type_t
::
i8
:
val
=
std
::
make_shared
<
ngraph
::
op
::
Constant
>
(
type
,
ngraph
::
Shape
{},
std
::
vector
<
int8_t
>
{
static_cast
<
int8_t
>
(
num
)});
}
else
if
(
type
==
element
::
u64
)
{
break
;
case
element
:
:
Type_t
::
u64
:
val
=
std
::
make_shared
<
ngraph
::
op
::
Constant
>
(
type
,
ngraph
::
Shape
{},
std
::
vector
<
uint64_t
>
{
static_cast
<
uint64_t
>
(
num
)});
}
else
if
(
type
==
element
::
u32
)
{
break
;
case
element
:
:
Type_t
::
u32
:
val
=
std
::
make_shared
<
ngraph
::
op
::
Constant
>
(
type
,
ngraph
::
Shape
{},
std
::
vector
<
uint32_t
>
{
static_cast
<
uint32_t
>
(
num
)});
}
else
if
(
type
==
element
::
u16
)
{
break
;
case
element
:
:
Type_t
::
u16
:
val
=
std
::
make_shared
<
ngraph
::
op
::
Constant
>
(
type
,
ngraph
::
Shape
{},
std
::
vector
<
uint16_t
>
{
static_cast
<
uint16_t
>
(
num
)});
}
else
if
(
type
==
element
::
u8
)
{
break
;
case
element
:
:
Type_t
::
u8
:
val
=
std
::
make_shared
<
ngraph
::
op
::
Constant
>
(
type
,
ngraph
::
Shape
{},
std
::
vector
<
uint8_t
>
{
static_cast
<
uint8_t
>
(
num
)});
break
;
case
element
:
:
Type_t
::
dynamic
:
throw
ngraph_error
(
"make_constant: Unsupported element type 'dynamic'"
);
case
element
:
:
Type_t
::
boolean
:
throw
ngraph_error
(
"make_constant: Unsupported element type 'boolean'"
);
case
element
:
:
Type_t
::
undefined
:
throw
ngraph_error
(
"make_constant: Unsupported element type 'undefined'"
);
}
else
{
throw
ngraph_error
(
"make_constant: Unsupported element type"
);
}
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic pop
#endif
if
(
shape
.
size
()
>
0
)
{
...
...
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