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
9a075c46
Commit
9a075c46
authored
Jan 29, 2019
by
Adam Rogowiec
Committed by
Michał Karzyński
Jan 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ONNX] Add lacking data types to ONNX Tensor (#2366)
parent
af85d85d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
102 additions
and
0 deletions
+102
-0
tensor.hpp
src/ngraph/frontend/onnx_import/core/tensor.hpp
+70
-0
constant.cpp
src/ngraph/frontend/onnx_import/op/constant.cpp
+32
-0
No files found.
src/ngraph/frontend/onnx_import/core/tensor.hpp
View file @
9a075c46
...
...
@@ -181,6 +181,34 @@ namespace ngraph
throw
error
::
tensor
::
invalid_data_type
{
tensor
.
data_type
()};
}
template
<>
inline
std
::
vector
<
int8_t
>
get_data
(
const
onnx
::
TensorProto
&
tensor
)
{
if
(
tensor
.
has_raw_data
())
{
return
detail
::
__get_raw_data
<
int8_t
>
(
tensor
.
raw_data
());
}
if
(
tensor
.
data_type
()
==
onnx
::
TensorProto_DataType_INT8
)
{
return
detail
::
__get_data
<
int8_t
>
(
tensor
.
int32_data
());
}
throw
error
::
tensor
::
invalid_data_type
{
tensor
.
data_type
()};
}
template
<>
inline
std
::
vector
<
int16_t
>
get_data
(
const
onnx
::
TensorProto
&
tensor
)
{
if
(
tensor
.
has_raw_data
())
{
return
detail
::
__get_raw_data
<
int16_t
>
(
tensor
.
raw_data
());
}
if
(
tensor
.
data_type
()
==
onnx
::
TensorProto_DataType_INT16
)
{
return
detail
::
__get_data
<
int16_t
>
(
tensor
.
int32_data
());
}
throw
error
::
tensor
::
invalid_data_type
{
tensor
.
data_type
()};
}
template
<>
inline
std
::
vector
<
int32_t
>
get_data
(
const
onnx
::
TensorProto
&
tensor
)
{
...
...
@@ -209,6 +237,48 @@ namespace ngraph
return
detail
::
__get_data
<
int64_t
>
(
tensor
.
int64_data
());
}
template
<>
inline
std
::
vector
<
uint8_t
>
get_data
(
const
onnx
::
TensorProto
&
tensor
)
{
if
(
tensor
.
has_raw_data
())
{
return
detail
::
__get_raw_data
<
uint8_t
>
(
tensor
.
raw_data
());
}
if
(
tensor
.
data_type
()
==
onnx
::
TensorProto_DataType_UINT8
)
{
return
detail
::
__get_data
<
uint8_t
>
(
tensor
.
int32_data
());
}
throw
error
::
tensor
::
invalid_data_type
{
tensor
.
data_type
()};
}
template
<>
inline
std
::
vector
<
uint16_t
>
get_data
(
const
onnx
::
TensorProto
&
tensor
)
{
if
(
tensor
.
has_raw_data
())
{
return
detail
::
__get_raw_data
<
uint16_t
>
(
tensor
.
raw_data
());
}
if
(
tensor
.
data_type
()
==
onnx
::
TensorProto_DataType_UINT16
)
{
return
detail
::
__get_data
<
uint16_t
>
(
tensor
.
int32_data
());
}
throw
error
::
tensor
::
invalid_data_type
{
tensor
.
data_type
()};
}
template
<>
inline
std
::
vector
<
uint32_t
>
get_data
(
const
onnx
::
TensorProto
&
tensor
)
{
if
(
tensor
.
has_raw_data
())
{
return
detail
::
__get_raw_data
<
uint32_t
>
(
tensor
.
raw_data
());
}
if
(
tensor
.
data_type
()
==
onnx
::
TensorProto_DataType_UINT32
)
{
return
detail
::
__get_data
<
uint32_t
>
(
tensor
.
uint64_data
());
}
throw
error
::
tensor
::
invalid_data_type
{
tensor
.
data_type
()};
}
template
<>
inline
std
::
vector
<
uint64_t
>
get_data
(
const
onnx
::
TensorProto
&
tensor
)
{
...
...
src/ngraph/frontend/onnx_import/op/constant.cpp
View file @
9a075c46
...
...
@@ -65,6 +65,20 @@ namespace ngraph
return
__make_ng_constant
<
double
>
(
element
::
f64
,
tensor
);
}
template
<>
inline
std
::
shared_ptr
<
ngraph
::
op
::
Constant
>
make_ng_constant
<
Tensor
::
Type
::
int8
>
(
const
Tensor
&
tensor
)
{
return
__make_ng_constant
<
int8_t
>
(
element
::
i8
,
tensor
);
}
template
<>
inline
std
::
shared_ptr
<
ngraph
::
op
::
Constant
>
make_ng_constant
<
Tensor
::
Type
::
int16
>
(
const
Tensor
&
tensor
)
{
return
__make_ng_constant
<
int16_t
>
(
element
::
i16
,
tensor
);
}
template
<>
inline
std
::
shared_ptr
<
ngraph
::
op
::
Constant
>
make_ng_constant
<
Tensor
::
Type
::
int32
>
(
const
Tensor
&
tensor
)
...
...
@@ -79,6 +93,20 @@ namespace ngraph
return
__make_ng_constant
<
int64_t
>
(
element
::
i64
,
tensor
);
}
template
<>
inline
std
::
shared_ptr
<
ngraph
::
op
::
Constant
>
make_ng_constant
<
Tensor
::
Type
::
uint8
>
(
const
Tensor
&
tensor
)
{
return
__make_ng_constant
<
uint8_t
>
(
element
::
u8
,
tensor
);
}
template
<>
inline
std
::
shared_ptr
<
ngraph
::
op
::
Constant
>
make_ng_constant
<
Tensor
::
Type
::
uint16
>
(
const
Tensor
&
tensor
)
{
return
__make_ng_constant
<
uint16_t
>
(
element
::
u16
,
tensor
);
}
template
<>
inline
std
::
shared_ptr
<
ngraph
::
op
::
Constant
>
make_ng_constant
<
Tensor
::
Type
::
uint32
>
(
const
Tensor
&
tensor
)
...
...
@@ -103,8 +131,12 @@ namespace ngraph
MAKE_NG_CONSTANT
(
Tensor
::
Type
::
float16
);
MAKE_NG_CONSTANT
(
Tensor
::
Type
::
float32
);
MAKE_NG_CONSTANT
(
Tensor
::
Type
::
float64
);
MAKE_NG_CONSTANT
(
Tensor
::
Type
::
int8
);
MAKE_NG_CONSTANT
(
Tensor
::
Type
::
int16
);
MAKE_NG_CONSTANT
(
Tensor
::
Type
::
int32
);
MAKE_NG_CONSTANT
(
Tensor
::
Type
::
int64
);
MAKE_NG_CONSTANT
(
Tensor
::
Type
::
uint8
);
MAKE_NG_CONSTANT
(
Tensor
::
Type
::
uint16
);
MAKE_NG_CONSTANT
(
Tensor
::
Type
::
uint32
);
MAKE_NG_CONSTANT
(
Tensor
::
Type
::
uint64
);
default
:
throw
error
::
tensor
::
invalid_data_type
{
tensor
};
...
...
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