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
b0e1e076
Commit
b0e1e076
authored
Aug 28, 2017
by
Scott Cyphers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Call -> Op, failing test for pattern match.
parent
db6e3052
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
19 deletions
+61
-19
node.hpp
src/ngraph/node.hpp
+11
-0
op.hpp
src/ngraph/op.hpp
+0
-0
op.cpp
src/ops/op.cpp
+19
-19
build_graph.cpp
test/build_graph.cpp
+31
-0
No files found.
src/ngraph/node.hpp
View file @
b0e1e076
...
...
@@ -18,6 +18,8 @@
#include <string>
#include <vector>
#include <iostream>
#include "ngraph/type.hpp"
namespace
ngraph
...
...
@@ -62,6 +64,15 @@ namespace ngraph
std
::
string
name
()
const
{
return
m_name
;
}
void
name
(
const
std
::
string
&
name
)
{
m_name
=
name
;
}
/**
** Return true if this has the same implementing class as call. This
** will be used by the pattern matcher when comparing a pattern
** graph against the graph.
** TODO: typeids are Node*, doc says they should be the actual classes.
**/
bool
has_same_op
(
const
Node
::
ptr
&
node
)
{
return
typeid
(
this
)
==
typeid
(
node
.
get
());
}
protected
:
std
::
vector
<
Node
::
ptr
>
m_arguments
;
std
::
multiset
<
Node
*>
m_users
;
...
...
src/ngraph/op.hpp
View file @
b0e1e076
This diff is collapsed.
Click to expand it.
src/ops/op.cpp
View file @
b0e1e076
...
...
@@ -21,12 +21,12 @@ using namespace std;
Node
::
ptr
ngraph
::
op
::
abs
(
const
Node
::
ptr
&
arg
)
{
return
make_shared
<
Abs
Call
>
(
arg
);
return
make_shared
<
Abs
Op
>
(
arg
);
}
Node
::
ptr
ngraph
::
op
::
add
(
const
Node
::
ptr
&
arg0
,
const
Node
::
ptr
&
arg1
)
{
return
make_shared
<
Add
Call
>
(
arg0
,
arg1
);
return
make_shared
<
Add
Op
>
(
arg0
,
arg1
);
}
/**
...
...
@@ -39,10 +39,10 @@ Node::ptr ngraph::op::broadcast(const Node::ptr& tensor,
const
Shape
&
shape
,
const
vector
<
size_t
>&
broadcast_axes
)
{
return
make_shared
<
Broadcast
Call
>
(
tensor
,
shape
,
broadcast_axes
);
return
make_shared
<
Broadcast
Op
>
(
tensor
,
shape
,
broadcast_axes
);
}
void
Broadcast
Call
::
propagate_types
()
void
Broadcast
Op
::
propagate_types
()
{
auto
arg_type
=
m_arguments
.
at
(
0
)
->
type
();
if
(
nullptr
==
arg_type
)
...
...
@@ -70,7 +70,7 @@ void BroadcastCall::propagate_types()
Node
::
ptr
ngraph
::
op
::
ceiling
(
const
Node
::
ptr
&
arg0
,
const
Node
::
ptr
&
arg1
)
{
return
make_shared
<
Ceiling
Call
>
(
arg0
,
arg1
);
return
make_shared
<
Ceiling
Op
>
(
arg0
,
arg1
);
}
// 'concatenate',
...
...
@@ -80,16 +80,16 @@ Node::ptr ngraph::op::ceiling(const Node::ptr& arg0, const Node::ptr& arg1)
Node
::
ptr
ngraph
::
op
::
divide
(
const
Node
::
ptr
&
arg0
,
const
Node
::
ptr
&
arg1
)
{
return
make_shared
<
Divide
Call
>
(
arg0
,
arg1
);
return
make_shared
<
Divide
Op
>
(
arg0
,
arg1
);
}
/// TODO: Semantics of arg0 and arg1 axes wrt reduction.
Node
::
ptr
ngraph
::
op
::
dot
(
const
Node
::
ptr
&
arg0
,
const
Node
::
ptr
&
arg1
)
{
return
make_shared
<
Dot
Call
>
(
arg0
,
arg1
);
return
make_shared
<
Dot
Op
>
(
arg0
,
arg1
);
}
void
Dot
Call
::
propagate_types
()
void
Dot
Op
::
propagate_types
()
{
auto
arg0_tensor_type
=
m_arguments
.
at
(
0
)
->
type
()
->
as
<
TensorViewType
*>
();
auto
arg1_tensor_type
=
m_arguments
.
at
(
1
)
->
type
()
->
as
<
TensorViewType
*>
();
...
...
@@ -129,37 +129,37 @@ void DotCall::propagate_types()
Node
::
ptr
ngraph
::
op
::
exponential
(
const
Node
::
ptr
&
arg0
)
{
return
make_shared
<
Exponential
Call
>
(
arg0
);
return
make_shared
<
Exponential
Op
>
(
arg0
);
}
Node
::
ptr
ngraph
::
op
::
floor
(
const
Node
::
ptr
&
arg0
,
const
Node
::
ptr
&
arg1
)
{
return
make_shared
<
Floor
Call
>
(
arg0
,
arg1
);
return
make_shared
<
Floor
Op
>
(
arg0
,
arg1
);
}
Node
::
ptr
ngraph
::
op
::
log
(
const
Node
::
ptr
&
arg0
)
{
return
make_shared
<
Log
Call
>
(
arg0
);
return
make_shared
<
Log
Op
>
(
arg0
);
}
Node
::
ptr
ngraph
::
op
::
maximum
(
const
Node
::
ptr
&
arg0
,
const
Node
::
ptr
&
arg1
)
{
return
make_shared
<
Maximum
Call
>
(
arg0
,
arg1
);
return
make_shared
<
Maximum
Op
>
(
arg0
,
arg1
);
}
Node
::
ptr
ngraph
::
op
::
minimum
(
const
Node
::
ptr
&
arg0
,
const
Node
::
ptr
&
arg1
)
{
return
make_shared
<
Minimum
Call
>
(
arg0
,
arg1
);
return
make_shared
<
Minimum
Op
>
(
arg0
,
arg1
);
}
Node
::
ptr
ngraph
::
op
::
multiply
(
const
Node
::
ptr
&
arg0
,
const
Node
::
ptr
&
arg1
)
{
return
make_shared
<
Multiply
Call
>
(
arg0
,
arg1
);
return
make_shared
<
Multiply
Op
>
(
arg0
,
arg1
);
}
Node
::
ptr
ngraph
::
op
::
negate
(
const
Node
::
ptr
&
arg0
)
{
return
make_shared
<
Negate
Call
>
(
arg0
);
return
make_shared
<
Negate
Op
>
(
arg0
);
}
// 'pad',
...
...
@@ -167,19 +167,19 @@ Node::ptr ngraph::op::negate(const Node::ptr& arg0)
Node
::
ptr
ngraph
::
op
::
power
(
const
Node
::
ptr
&
arg0
,
const
Node
::
ptr
&
arg1
)
{
return
make_shared
<
Power
Call
>
(
arg0
,
arg1
);
return
make_shared
<
Power
Op
>
(
arg0
,
arg1
);
}
//'reduce',
Node
::
ptr
ngraph
::
op
::
remainder
(
const
Node
::
ptr
&
arg0
,
const
Node
::
ptr
&
arg1
)
{
return
make_shared
<
Remainder
Call
>
(
arg0
,
arg1
);
return
make_shared
<
Remainder
Op
>
(
arg0
,
arg1
);
}
Node
::
ptr
ngraph
::
op
::
reshape
(
const
Node
::
ptr
&
arg0
,
const
Shape
&
shape
)
{
return
make_shared
<
Reshape
Call
>
(
arg0
,
shape
);
return
make_shared
<
Reshape
Op
>
(
arg0
,
shape
);
}
//'reverse',
...
...
@@ -189,7 +189,7 @@ Node::ptr ngraph::op::reshape(const Node::ptr& arg0, const Shape& shape)
Node
::
ptr
ngraph
::
op
::
subtract
(
const
Node
::
ptr
&
arg0
,
const
Node
::
ptr
&
arg1
)
{
return
make_shared
<
Subtract
Call
>
(
arg0
,
arg1
);
return
make_shared
<
Subtract
Op
>
(
arg0
,
arg1
);
}
// 'transpose',
...
...
test/build_graph.cpp
View file @
b0e1e076
...
...
@@ -60,3 +60,34 @@ TEST(build_graph, as_type)
TupleType
*
tp_tp
=
tp_vt
->
as
<
TupleType
*>
();
ASSERT_EQ
(
tp_vt
.
get
(),
tp_tp
);
}
// Check Call comparisons
TEST
(
DISABLED_build_graph
,
call_comparison
)
{
auto
fun
=
make_shared
<
Function
>
(
3
);
fun
->
parameter
(
0
)
->
type
(
element
::
float32_t
,
{
32
,
3
});
fun
->
parameter
(
1
)
->
type
(
element
::
float32_t
,
{
3
});
fun
->
parameter
(
2
)
->
type
(
element
::
float32_t
,
{
32
});
auto
arg0
=
fun
->
parameter
(
0
);
auto
arg1
=
fun
->
parameter
(
1
);
auto
arg2
=
fun
->
parameter
(
2
);
auto
dot
=
op
::
dot
(
arg0
,
arg1
);
auto
add
=
op
::
add
(
dot
,
arg2
);
auto
pattern
=
make_shared
<
Function
>
(
1
);
pattern
->
parameter
(
0
)
->
type
(
element
::
float32_t
,
{});
auto
parg
=
pattern
->
parameter
(
0
);
auto
pattern_dot
=
op
::
dot
(
parg
,
parg
);
ASSERT_TRUE
(
pattern_dot
->
has_same_op
(
dot
));
// TODO This passes because typeid is not behaving as documented.
// Need to figure out what's wrong.
ASSERT_FALSE
(
pattern_dot
->
has_same_op
(
add
));
}
// Check argument inverses
TEST
(
build_graph
,
arg_inverse
)
{
}
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