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
eb22cbb4
Commit
eb22cbb4
authored
Oct 03, 2017
by
Scott Cyphers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use weak_ptr for node in inputs/outputs, turn off alignment style.
parent
c95c8b68
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
18 deletions
+25
-18
.clang-format
.clang-format
+2
-2
input.cpp
src/ngraph/descriptor/input.cpp
+2
-2
input.hpp
src/ngraph/descriptor/input.hpp
+3
-3
output.cpp
src/ngraph/descriptor/output.cpp
+4
-2
output.hpp
src/ngraph/descriptor/output.hpp
+5
-3
node.cpp
src/ngraph/node.cpp
+9
-6
No files found.
.clang-format
View file @
eb22cbb4
...
...
@@ -6,8 +6,8 @@ Standard: Cpp11
AccessModifierOffset: -4
AlignConsecutiveDeclarations:
tru
e
AlignConsecutiveAssignments:
tru
e
AlignConsecutiveDeclarations:
fals
e
AlignConsecutiveAssignments:
fals
e
AlignTrailingComments: true
AllowShortBlocksOnASingleLine: true
...
...
src/ngraph/descriptor/input.cpp
View file @
eb22cbb4
...
...
@@ -19,7 +19,7 @@ using namespace ngraph;
using
namespace
descriptor
;
Input
::
Input
(
Node
*
node
,
size_t
index
,
size_t
argno
,
size_t
arg_index
,
Output
&
output
)
const
std
::
shared_ptr
<
Node
>&
node
,
size_t
index
,
size_t
argno
,
size_t
arg_index
,
Output
&
output
)
:
m_node
(
node
)
,
m_index
(
index
)
,
m_argno
(
argno
)
...
...
@@ -31,7 +31,7 @@ Input::Input(
std
::
shared_ptr
<
Node
>
Input
::
get_node
()
{
return
m_node
->
shared_from_this
();
return
m_node
.
lock
();
}
const
Tensor
&
Input
::
get_tensor
()
const
...
...
src/ngraph/descriptor/input.hpp
View file @
eb22cbb4
...
...
@@ -32,12 +32,12 @@ namespace ngraph
friend
class
Node
;
public
:
/// @param node The node that owns this input
; not shared to prevent owner loop
/// @param node The node that owns this input
/// @param index The position of this this tensor in all input tensors
/// @param argno The position of the argument with this tensor
/// @param arg_index The position of the tensor within the argument's tensors
/// @param output The output that supplies a value for this input
Input
(
Node
*
node
,
Input
(
const
std
::
shared_ptr
<
Node
>&
node
,
size_t
index
,
size_t
argno
,
size_t
arg_index
,
...
...
@@ -53,7 +53,7 @@ namespace ngraph
Tensor
&
get_tensor
();
protected
:
Node
*
m_node
;
// The node we are an input for
std
::
weak_ptr
<
Node
>
m_node
;
// The node we are an input for
size_t
m_index
;
// Index into all input tensors
size_t
m_argno
;
// Arg number for this input
size_t
m_arg_index
;
// Index into arg's tensors
...
...
src/ngraph/descriptor/output.cpp
View file @
eb22cbb4
...
...
@@ -18,7 +18,9 @@ using namespace std;
using
namespace
ngraph
;
using
namespace
descriptor
;
Output
::
Output
(
Node
*
node
,
size_t
index
,
const
std
::
shared_ptr
<
TensorView
>&
tensor_view
)
Output
::
Output
(
const
std
::
shared_ptr
<
Node
>&
node
,
size_t
index
,
const
std
::
shared_ptr
<
TensorView
>&
tensor_view
)
:
m_node
(
node
)
,
m_index
(
index
)
,
m_tensor_view
(
tensor_view
)
...
...
@@ -33,7 +35,7 @@ void Output::add_input(Input* input)
std
::
shared_ptr
<
Node
>
Output
::
get_node
()
const
{
return
m_node
->
shared_from_this
();
return
m_node
.
lock
();
}
const
Tensor
&
Output
::
get_tensor
()
const
...
...
src/ngraph/descriptor/output.hpp
View file @
eb22cbb4
...
...
@@ -32,10 +32,12 @@ namespace ngraph
// Output& operator=(const Output&) = delete;
public
:
/// @param node Node that owns this output.
Not shared to prevent owner loop.
/// @param node Node that owns this output.
/// @param index Position of the output tensor in all output tensors
/// @param tensor_view The view of this tensor; where the value will be written
Output
(
Node
*
node
,
size_t
index
,
const
std
::
shared_ptr
<
TensorView
>&
tensor_view
);
Output
(
const
std
::
shared_ptr
<
Node
>&
node
,
size_t
index
,
const
std
::
shared_ptr
<
TensorView
>&
tensor_view
);
std
::
shared_ptr
<
Node
>
get_node
()
const
;
size_t
get_index
()
const
{
return
m_index
;
}
...
...
@@ -46,7 +48,7 @@ namespace ngraph
Tensor
&
get_tensor
();
protected
:
Node
*
m_node
;
std
::
weak_ptr
<
Node
>
m_node
;
size_t
m_index
;
std
::
shared_ptr
<
TensorView
>
m_tensor_view
;
std
::
set
<
Input
*>
m_inputs
;
...
...
src/ngraph/node.cpp
View file @
eb22cbb4
...
...
@@ -32,9 +32,7 @@ Node::Node(const std::vector<shared_ptr<Node>>& arguments, shared_ptr<ValueType>
}
}
Node
::~
Node
()
{
}
Node
::~
Node
()
{}
void
Node
::
set_value_type_checked
(
const
shared_ptr
<
const
ValueType
>&
value_type
)
{
...
...
@@ -55,11 +53,16 @@ void Node::assign_tensors()
{
vector
<
std
::
shared_ptr
<
const
TensorViewType
>>
tensor_view_types
;
get_value_type
()
->
collect_tensor_views
(
tensor_view_types
);
std
::
shared_ptr
<
Node
>
shared_this
=
shared_from_this
();
size_t
i
=
0
;
for
(
auto
tvt
:
tensor_view_types
)
{
auto
tensor_view_descriptor
=
make_shared
<
descriptor
::
PrimaryTensorView
>
(
tvt
,
ngraph
::
descriptor
::
Tensor
::
make_tensor_name
(
this
,
i
),
is_output
(),
is_parameter
());
m_outputs
.
emplace_back
(
this
,
i
,
tensor_view_descriptor
);
auto
tensor_view_descriptor
=
make_shared
<
descriptor
::
PrimaryTensorView
>
(
tvt
,
ngraph
::
descriptor
::
Tensor
::
make_tensor_name
(
this
,
i
),
is_output
(),
is_parameter
());
m_outputs
.
emplace_back
(
shared_this
,
i
,
tensor_view_descriptor
);
i
++
;
}
...
...
@@ -70,7 +73,7 @@ void Node::assign_tensors()
size_t
arg_index
=
0
;
for
(
descriptor
::
Output
&
output
:
arg
->
get_outputs
())
{
m_inputs
.
emplace_back
(
this
,
i
,
argno
,
arg_index
++
,
output
);
m_inputs
.
emplace_back
(
shared_
this
,
i
,
argno
,
arg_index
++
,
output
);
i
++
;
}
argno
++
;
...
...
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