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
4e2715b5
Commit
4e2715b5
authored
May 10, 2018
by
Michał Karzyński
Committed by
Robert Kimball
May 10, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Py] Use get_friendly_name for object names (#968)
* [Py] Use get_friendly_name for object names
parent
8508410f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
13 deletions
+14
-13
basic.py
python/examples/basic.py
+8
-9
broadcasting.py
python/ngraph/utils/broadcasting.py
+3
-2
node.cpp
python/pyngraph/node.cpp
+1
-1
parameter.cpp
python/pyngraph/ops/parameter.cpp
+2
-1
No files found.
python/examples/basic.py
View file @
4e2715b5
...
...
@@ -18,24 +18,23 @@
import
numpy
as
np
import
ngraph
as
ng
shape
=
[
2
,
2
]
A
=
ng
.
parameter
(
shape
,
name
=
'A'
)
B
=
ng
.
parameter
(
shape
,
name
=
'B'
)
C
=
ng
.
parameter
(
shape
,
name
=
'C'
)
A
=
ng
.
parameter
(
shape
=
[
2
,
2
],
name
=
'A'
,
dtype
=
np
.
float32
)
B
=
ng
.
parameter
(
shape
=
[
2
,
2
],
name
=
'B'
)
C
=
ng
.
parameter
(
shape
=
[
2
,
2
],
name
=
'C'
)
# >>> print(A)
# <Parameter: 'A' (
2, 2
, float)>
# <Parameter: 'A' (
[2, 2]
, float)>
model
=
(
A
+
B
)
*
C
# >>> print(model)
# <
Node: 'Multiply_6'
>
# <
Multiply: 'Multiply_14' ([2, 2])
>
runtime
=
ng
.
runtime
(
backend_name
=
'
INTERPRETER
'
)
runtime
=
ng
.
runtime
(
backend_name
=
'
CPU
'
)
# >>> print(runtime)
# <Runtime:
Manager='INTERPRETER
'>
# <Runtime:
Backend='CPU
'>
computation
=
runtime
.
computation
(
model
,
A
,
B
,
C
)
# >>> print(computation)
# <Computation: Multiply_
6
(A, B, C)>
# <Computation: Multiply_
14
(A, B, C)>
value_a
=
np
.
array
([[
1
,
2
],
[
3
,
4
]],
dtype
=
np
.
float32
)
value_b
=
np
.
array
([[
5
,
6
],
[
7
,
8
]],
dtype
=
np
.
float32
)
...
...
python/ngraph/utils/broadcasting.py
View file @
4e2715b5
...
...
@@ -63,8 +63,9 @@ def as_elementwise_compatible_nodes(*input_values): # type: (*NodeInput) -> Lis
if
len
(
shapes
)
>
1
:
log
.
warning
(
'More than one different shape in input nodes
%
s.'
,
input_nodes
)
types
=
{
node
.
get_element_type
()
for
node
in
input_nodes
}
if
len
(
types
)
>
1
:
types
=
[
node
.
get_element_type
()
for
node
in
input_nodes
]
unique_types
=
{
repr
(
type
)
for
type
in
types
}
if
len
(
unique_types
)
>
1
:
log
.
warning
(
'More than one different data type in input nodes
%
s.'
,
input_nodes
)
sorted_shapes
=
sorted
(
shapes
,
key
=
len
)
...
...
python/pyngraph/node.cpp
View file @
4e2715b5
...
...
@@ -69,6 +69,6 @@ void regclass_pyngraph_Node(py::module m)
node
.
def
(
"get_shape"
,
&
ngraph
::
Node
::
get_shape
);
node
.
def
(
"get_argument"
,
&
ngraph
::
Node
::
get_argument
);
node
.
def_property
(
"name"
,
&
ngraph
::
Node
::
get_name
,
&
ngraph
::
Node
::
set_name
);
node
.
def_property
(
"name"
,
&
ngraph
::
Node
::
get_
friendly_
name
,
&
ngraph
::
Node
::
set_name
);
node
.
def_property_readonly
(
"shape"
,
&
ngraph
::
Node
::
get_shape
);
}
python/pyngraph/ops/parameter.cpp
View file @
4e2715b5
...
...
@@ -33,7 +33,8 @@ void regclass_pyngraph_op_Parameter(py::module m)
std
::
string
class_name
=
py
::
cast
(
self
).
get_type
().
attr
(
"__name__"
).
cast
<
std
::
string
>
();
std
::
string
shape
=
py
::
cast
(
self
.
get_shape
()).
attr
(
"__str__"
)().
cast
<
std
::
string
>
();
std
::
string
type
=
self
.
get_element_type
().
c_type_string
();
return
"<"
+
class_name
+
": '"
+
self
.
get_name
()
+
"' ("
+
shape
+
", "
+
type
+
")>"
;
return
"<"
+
class_name
+
": '"
+
self
.
get_friendly_name
()
+
"' ("
+
shape
+
", "
+
type
+
")>"
;
});
parameter
.
def
(
py
::
init
<
const
ngraph
::
element
::
Type
&
,
const
ngraph
::
Shape
&>
());
...
...
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