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
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
38 deletions
+45
-38
.clang-format
.clang-format
+2
-2
input.cpp
src/ngraph/descriptor/input.cpp
+2
-2
input.hpp
src/ngraph/descriptor/input.hpp
+16
-16
output.cpp
src/ngraph/descriptor/output.cpp
+4
-2
output.hpp
src/ngraph/descriptor/output.hpp
+11
-9
node.cpp
src/ngraph/node.cpp
+10
-7
No files found.
.clang-format
View file @
eb22cbb4
...
@@ -6,8 +6,8 @@ Standard: Cpp11
...
@@ -6,8 +6,8 @@ Standard: Cpp11
AccessModifierOffset: -4
AccessModifierOffset: -4
AlignConsecutiveDeclarations:
tru
e
AlignConsecutiveDeclarations:
fals
e
AlignConsecutiveAssignments:
tru
e
AlignConsecutiveAssignments:
fals
e
AlignTrailingComments: true
AlignTrailingComments: true
AllowShortBlocksOnASingleLine: true
AllowShortBlocksOnASingleLine: true
...
...
src/ngraph/descriptor/input.cpp
View file @
eb22cbb4
...
@@ -19,7 +19,7 @@ using namespace ngraph;
...
@@ -19,7 +19,7 @@ using namespace ngraph;
using
namespace
descriptor
;
using
namespace
descriptor
;
Input
::
Input
(
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_node
(
node
)
,
m_index
(
index
)
,
m_index
(
index
)
,
m_argno
(
argno
)
,
m_argno
(
argno
)
...
@@ -31,7 +31,7 @@ Input::Input(
...
@@ -31,7 +31,7 @@ Input::Input(
std
::
shared_ptr
<
Node
>
Input
::
get_node
()
std
::
shared_ptr
<
Node
>
Input
::
get_node
()
{
{
return
m_node
->
shared_from_this
();
return
m_node
.
lock
();
}
}
const
Tensor
&
Input
::
get_tensor
()
const
const
Tensor
&
Input
::
get_tensor
()
const
...
...
src/ngraph/descriptor/input.hpp
View file @
eb22cbb4
...
@@ -32,31 +32,31 @@ namespace ngraph
...
@@ -32,31 +32,31 @@ namespace ngraph
friend
class
Node
;
friend
class
Node
;
public
:
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 index The position of this this tensor in all input tensors
/// @param argno The position of the argument with this tensor
/// @param argno The position of the argument with this tensor
/// @param arg_index The position of the tensor within the argument's tensors
/// @param arg_index The position of the tensor within the argument's tensors
/// @param output The output that supplies a value for this input
/// @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
index
,
size_t
argno
,
size_t
argno
,
size_t
arg_index
,
size_t
arg_index
,
Output
&
output
);
Output
&
output
);
std
::
shared_ptr
<
Node
>
get_node
();
std
::
shared_ptr
<
Node
>
get_node
();
size_t
get_argno
()
const
{
return
m_argno
;
}
size_t
get_argno
()
const
{
return
m_argno
;
}
size_t
get_arg_index
()
const
{
return
m_arg_index
;
}
size_t
get_arg_index
()
const
{
return
m_arg_index
;
}
size_t
get_index
()
const
{
return
m_index
;
}
size_t
get_index
()
const
{
return
m_index
;
}
const
Output
&
get_output
()
const
{
return
m_output
;
}
const
Output
&
get_output
()
const
{
return
m_output
;
}
Output
&
get_output
()
{
return
m_output
;
}
Output
&
get_output
()
{
return
m_output
;
}
const
Tensor
&
get_tensor
()
const
;
const
Tensor
&
get_tensor
()
const
;
Tensor
&
get_tensor
();
Tensor
&
get_tensor
();
protected
:
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_index
;
// Index into all input tensors
size_t
m_argno
;
// Arg number for this input
size_t
m_argno
;
// Arg number for this input
size_t
m_arg_index
;
// Index into arg's tensors
size_t
m_arg_index
;
// Index into arg's tensors
Output
&
m_output
;
Output
&
m_output
;
private
:
private
:
...
...
src/ngraph/descriptor/output.cpp
View file @
eb22cbb4
...
@@ -18,7 +18,9 @@ using namespace std;
...
@@ -18,7 +18,9 @@ using namespace std;
using
namespace
ngraph
;
using
namespace
ngraph
;
using
namespace
descriptor
;
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_node
(
node
)
,
m_index
(
index
)
,
m_index
(
index
)
,
m_tensor_view
(
tensor_view
)
,
m_tensor_view
(
tensor_view
)
...
@@ -33,7 +35,7 @@ void Output::add_input(Input* input)
...
@@ -33,7 +35,7 @@ void Output::add_input(Input* input)
std
::
shared_ptr
<
Node
>
Output
::
get_node
()
const
std
::
shared_ptr
<
Node
>
Output
::
get_node
()
const
{
{
return
m_node
->
shared_from_this
();
return
m_node
.
lock
();
}
}
const
Tensor
&
Output
::
get_tensor
()
const
const
Tensor
&
Output
::
get_tensor
()
const
...
...
src/ngraph/descriptor/output.hpp
View file @
eb22cbb4
...
@@ -32,24 +32,26 @@ namespace ngraph
...
@@ -32,24 +32,26 @@ namespace ngraph
// Output& operator=(const Output&) = delete;
// Output& operator=(const Output&) = delete;
public
:
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 index Position of the output tensor in all output tensors
/// @param tensor_view The view of this tensor; where the value will be written
/// @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
;
std
::
shared_ptr
<
Node
>
get_node
()
const
;
size_t
get_index
()
const
{
return
m_index
;
}
size_t
get_index
()
const
{
return
m_index
;
}
std
::
shared_ptr
<
TensorView
>
get_tensor_view
()
const
{
return
m_tensor_view
;
}
std
::
shared_ptr
<
TensorView
>
get_tensor_view
()
const
{
return
m_tensor_view
;
}
void
add_input
(
Input
*
input
);
void
add_input
(
Input
*
input
);
const
std
::
set
<
Input
*>&
get_inputs
()
const
{
return
m_inputs
;
}
const
std
::
set
<
Input
*>&
get_inputs
()
const
{
return
m_inputs
;
}
const
Tensor
&
get_tensor
()
const
;
const
Tensor
&
get_tensor
()
const
;
Tensor
&
get_tensor
();
Tensor
&
get_tensor
();
protected
:
protected
:
Node
*
m_node
;
std
::
weak_ptr
<
Node
>
m_node
;
size_t
m_index
;
size_t
m_index
;
std
::
shared_ptr
<
TensorView
>
m_tensor_view
;
std
::
shared_ptr
<
TensorView
>
m_tensor_view
;
std
::
set
<
Input
*>
m_inputs
;
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>
...
@@ -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
)
void
Node
::
set_value_type_checked
(
const
shared_ptr
<
const
ValueType
>&
value_type
)
{
{
...
@@ -55,22 +53,27 @@ void Node::assign_tensors()
...
@@ -55,22 +53,27 @@ void Node::assign_tensors()
{
{
vector
<
std
::
shared_ptr
<
const
TensorViewType
>>
tensor_view_types
;
vector
<
std
::
shared_ptr
<
const
TensorViewType
>>
tensor_view_types
;
get_value_type
()
->
collect_tensor_views
(
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
;
size_t
i
=
0
;
for
(
auto
tvt
:
tensor_view_types
)
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
());
auto
tensor_view_descriptor
=
make_shared
<
descriptor
::
PrimaryTensorView
>
(
m_outputs
.
emplace_back
(
this
,
i
,
tensor_view_descriptor
);
tvt
,
ngraph
::
descriptor
::
Tensor
::
make_tensor_name
(
this
,
i
),
is_output
(),
is_parameter
());
m_outputs
.
emplace_back
(
shared_this
,
i
,
tensor_view_descriptor
);
i
++
;
i
++
;
}
}
i
=
0
;
i
=
0
;
size_t
argno
=
0
;
size_t
argno
=
0
;
for
(
auto
arg
:
get_arguments
())
for
(
auto
arg
:
get_arguments
())
{
{
size_t
arg_index
=
0
;
size_t
arg_index
=
0
;
for
(
descriptor
::
Output
&
output
:
arg
->
get_outputs
())
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
++
;
i
++
;
}
}
argno
++
;
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