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
51808ee1
Commit
51808ee1
authored
Aug 28, 2017
by
Scott Cyphers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dynamic_ptr_cast
parent
27ce1b0a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
16 deletions
+9
-16
type.hpp
src/ngraph/type.hpp
+0
-7
op.cpp
src/ops/op.cpp
+3
-3
build_graph.cpp
test/build_graph.cpp
+6
-6
No files found.
src/ngraph/type.hpp
View file @
51808ee1
...
...
@@ -39,13 +39,6 @@ namespace ngraph
using
ptr
=
std
::
shared_ptr
<
ValueType
>
;
virtual
~
ValueType
()
{}
/**
** Unmanaged cast to a supertype. dynamic_cast cannot be used
** directly on a shared_ptr. Can use dynamic_pointer_cast if
** a shared_ptr is needed.
**/
template
<
typename
T
>
T
as
()
{
return
dynamic_cast
<
T
>
(
this
);
}
};
/**
...
...
src/ops/op.cpp
View file @
51808ee1
...
...
@@ -49,7 +49,7 @@ void BroadcastOp::propagate_types()
{
throw
ngraph_error
(
"Argument to broadcast is missing type."
);
}
auto
arg_tensor_view_type
=
arg_type
->
as
<
TensorViewType
*>
(
);
auto
arg_tensor_view_type
=
dynamic_pointer_cast
<
TensorViewType
>
(
arg_type
);
if
(
nullptr
==
arg_tensor_view_type
)
{
throw
ngraph_error
(
"Argument to broadcast is not a tensor view"
);
...
...
@@ -91,8 +91,8 @@ Node::ptr ngraph::op::dot(const Node::ptr& arg0, const Node::ptr& arg1)
void
DotOp
::
propagate_types
()
{
auto
arg0_tensor_type
=
m_arguments
.
at
(
0
)
->
type
()
->
as
<
TensorViewType
*>
(
);
auto
arg1_tensor_type
=
m_arguments
.
at
(
1
)
->
type
()
->
as
<
TensorViewType
*>
(
);
auto
arg0_tensor_type
=
dynamic_pointer_cast
<
TensorViewType
>
(
m_arguments
.
at
(
0
)
->
type
()
);
auto
arg1_tensor_type
=
dynamic_pointer_cast
<
TensorViewType
>
(
m_arguments
.
at
(
1
)
->
type
()
);
if
(
nullptr
==
arg0_tensor_type
||
nullptr
==
arg1_tensor_type
)
{
throw
ngraph_error
(
"Arguments to dot must be tensor views"
);
...
...
test/build_graph.cpp
View file @
51808ee1
...
...
@@ -48,17 +48,17 @@ TEST(build_graph, as_type)
{
// Check upcasting a ValueType::ptr that is a TensorViewType to a TensorViewType and Tuple.
ValueType
::
ptr
tv_vt
=
make_shared
<
TensorViewType
>
(
element
::
float32_t
,
Shape
{
2
,
3
,
5
});
TensorViewType
*
tv_tv
=
tv_vt
->
as
<
TensorViewType
*>
(
);
ASSERT_EQ
(
tv_vt
.
get
()
,
tv_tv
);
TupleType
*
tv_tp
=
tv_vt
->
as
<
TupleType
*>
(
);
auto
tv_tv
=
dynamic_pointer_cast
<
TensorViewType
>
(
tv_vt
);
ASSERT_EQ
(
tv_vt
,
tv_tv
);
auto
tv_tp
=
dynamic_pointer_cast
<
TupleType
>
(
tv_vt
);
ASSERT_EQ
(
nullptr
,
tv_tp
);
// Check upcasting a ValueType::ptr that is a TupleType to a TensorViewType and Tuple.
ValueType
::
ptr
tp_vt
=
make_shared
<
TupleType
>
(
vector
<
ValueType
::
ptr
>
{
tv_vt
,
tv_vt
});
TensorViewType
*
tp_tv
=
tp_vt
->
as
<
TensorViewType
*>
(
);
auto
tp_tv
=
dynamic_pointer_cast
<
TensorViewType
>
(
tp_vt
);
ASSERT_EQ
(
nullptr
,
tp_tv
);
TupleType
*
tp_tp
=
tp_vt
->
as
<
TupleType
*>
(
);
ASSERT_EQ
(
tp_vt
.
get
()
,
tp_tp
);
auto
tp_tp
=
dynamic_pointer_cast
<
TupleType
>
(
tp_vt
);
ASSERT_EQ
(
tp_vt
,
tp_tp
);
}
// Check Call comparisons
...
...
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