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
c302ab30
Commit
c302ab30
authored
Aug 24, 2017
by
Scott Cyphers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify op/call
parent
3a53de5e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
47 deletions
+53
-47
function.hpp
src/ngraph/function.hpp
+12
-1
node.hpp
src/ngraph/node.hpp
+0
-11
op.hpp
src/ngraph/op.hpp
+39
-24
op.cpp
src/ops/op.cpp
+2
-11
No files found.
src/ngraph/function.hpp
View file @
c302ab30
...
...
@@ -22,6 +22,10 @@ namespace ngraph
{
class
Function
;
/**
** One parameter of a function. Within the function's graph
** the parameter is a node that represents the argument in a call.
**/
class
Parameter
:
public
Node
{
public
:
...
...
@@ -34,6 +38,10 @@ namespace ngraph
size_t
m_index
;
};
/**
** The result of a function. The ndoe addociated with the result
** supplies the return value when the function is called.
**/
class
Result
:
public
TypedValueMixin
{
public
:
...
...
@@ -46,6 +54,9 @@ namespace ngraph
Node
::
ptr
m_value
;
};
/**
** A user-defined function.
**/
class
Function
:
public
Op
{
public
:
...
...
@@ -53,7 +64,7 @@ namespace ngraph
Result
*
result
()
{
return
&
m_result
;
}
std
::
shared_ptr
<
Parameter
>
parameter
(
size_t
i
)
{
return
m_parameters
[
i
];
}
Parameter
::
ptr
parameter
(
size_t
i
)
{
return
m_parameters
[
i
];
}
protected
:
std
::
vector
<
Parameter
::
ptr
>
m_parameters
;
...
...
src/ngraph/node.hpp
View file @
c302ab30
...
...
@@ -40,15 +40,4 @@ namespace ngraph
std
::
vector
<
Node
::
ptr
>
m_arguments
;
};
class
Call
:
public
Node
{
public
:
virtual
Op
&
op
()
const
=
0
;
protected
:
Call
(
const
std
::
vector
<
Node
::
ptr
>&
arguments
)
:
Node
(
arguments
,
0
)
{
}
};
}
src/ngraph/op.hpp
View file @
c302ab30
...
...
@@ -23,63 +23,78 @@ namespace ngraph
{
class
Op
{
public
:
using
ptr
=
std
::
shared_ptr
<
Op
>
;
using
ref
=
decltype
(
*
std
::
shared_ptr
<
Op
>
());
};
class
Call
:
public
Node
{
public
:
using
ptr
=
std
::
shared_ptr
<
Call
>
;
Op
::
ptr
op
()
const
{
return
m_op
;
}
Call
(
const
Op
::
ptr
&
op
,
const
std
::
vector
<
Node
::
ptr
>&
arguments
)
:
Node
(
arguments
,
0
)
,
m_op
(
op
)
{
}
protected
:
Op
::
ptr
m_op
;
};
class
Broadcast
:
public
Op
class
Broadcast
:
public
Op
,
public
std
::
enable_shared_from_this
<
Broadcast
>
{
public
:
using
ptr
=
std
::
shared_ptr
<
Broadcast
>
;
using
ref
=
decltype
(
*
std
::
shared_ptr
<
Broadcast
>
());
protected
:
class
BroadcastCall
:
public
Call
{
friend
class
Broadcast
;
public
:
BroadcastCall
(
const
Node
::
ptr
&
arg
,
size_t
axis
)
:
Call
({
arg
})
BroadcastCall
(
const
Op
::
ptr
&
op
,
const
Node
::
ptr
&
arg
,
size_t
axis
)
:
Call
(
op
,
{
arg
})
,
m_axis
(
axis
)
{
}
Op
&
op
()
const
override
;
protected
:
size_t
m_axis
;
};
public
:
std
::
shared_ptr
<
BroadcastCall
>
operator
()(
const
Node
::
ptr
&
tensor
,
size_t
axis
)
{
return
std
::
make_shared
<
BroadcastCall
>
(
tensor
,
axis
);
return
std
::
make_shared
<
BroadcastCall
>
(
shared_from_this
(),
tensor
,
axis
);
}
};
namespace
op
{
extern
Broadcast
broadcast
;
extern
Broadcast
::
ref
broadcast
;
}
class
Dot
:
public
Op
class
Dot
:
public
Op
,
public
std
::
enable_shared_from_this
<
Dot
>
{
class
DotCall
:
public
Call
{
friend
class
Dot
;
public
:
DotCall
(
const
std
::
shared_ptr
<
Node
>&
arg0
,
const
Node
::
ptr
&
arg1
)
:
Call
({
arg0
,
arg1
})
{
}
Op
&
op
()
const
override
;
};
public
:
std
::
shared_ptr
<
DotCall
>
operator
()(
const
Node
::
ptr
&
arg0
,
const
Node
::
ptr
&
arg1
)
using
ptr
=
std
::
shared_ptr
<
Dot
>
;
using
ref
=
decltype
(
*
std
::
shared_ptr
<
Dot
>
());
public
:
Call
::
ptr
operator
()(
const
Node
::
ptr
&
arg0
,
const
Node
::
ptr
&
arg1
)
{
return
std
::
make_shared
<
DotCall
>
(
arg0
,
arg1
);
return
Call
::
ptr
::
make_shared
(
shared_from_this
(),
std
::
vector
<
Node
::
ptr
>
{
arg0
,
arg1
}
);
}
};
namespace
op
{
extern
Dot
dot
;
extern
Dot
::
ref
dot
;
}
}
src/ops/op.cpp
View file @
c302ab30
...
...
@@ -16,16 +16,7 @@
using
namespace
ngraph
;
Broadcast
ngraph
::
op
::
broadcast
{}
;
Broadcast
::
ref
ngraph
::
op
::
broadcast
=
*
std
::
make_shared
<
Broadcast
>
()
;
Op
&
ngraph
::
Broadcast
::
BroadcastCall
::
op
()
const
{
return
op
::
broadcast
;
}
Dot
::
ref
ngraph
::
op
::
dot
=
*
std
::
make_shared
<
Dot
>
();
Dot
ngraph
::
op
::
dot
{};
Op
&
ngraph
::
Dot
::
DotCall
::
op
()
const
{
return
op
::
dot
;
}
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