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
6a777636
Commit
6a777636
authored
Feb 04, 2019
by
Robert Kimball
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revert unnecessary changes
parent
4e437868
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
63 deletions
+33
-63
test_ops.py
python/test/test_ops.py
+31
-61
CMakeLists.txt
src/ngraph/CMakeLists.txt
+2
-2
No files found.
python/test/test_ops.py
View file @
6a777636
...
...
@@ -22,7 +22,7 @@ import numpy as np
from
ngraph.impl
import
util
from
ngraph.impl
import
Shape
,
Strides
,
CoordinateDiff
,
AxisSet
,
AxisVector
,
Coordinate
from
ngraph.impl
import
Type
,
Function
,
NodeVector
from
ngraph.impl.runtime
import
Backend
,
Executable
from
ngraph.impl.runtime
import
Backend
from
ngraph.impl.op
import
Acos
,
Asin
,
Atan
,
Cos
,
Sin
,
Tan
from
ngraph.impl.op
import
Cosh
,
Sinh
,
Tanh
,
Sqrt
,
Sign
from
ngraph.impl.op
import
Power
,
Negative
,
Ceiling
,
Floor
...
...
@@ -127,8 +127,7 @@ def binary_op_exec(op_str):
result_arr
=
np
.
array
([[
0
,
0
],
[
0
,
0
]],
dtype
=
np
.
float32
)
result
.
write
(
util
.
numpy_to_c
(
result_arr
),
0
,
16
)
handle
=
backend
.
compile
(
function
)
handle
.
call
([
result
],
[
a
,
b
])
backend
.
call
(
backend
.
compile
(
function
),
[
result
],
[
a
,
b
])
result
.
read
(
util
.
numpy_to_c
(
result_arr
),
0
,
16
)
a_arr
=
np
.
array
([[
1
,
6
],
[
7
,
4
]],
dtype
=
np
.
float32
)
...
...
@@ -157,8 +156,7 @@ def binary_op_comparison(op_str):
result_arr
=
np
.
array
([[
False
,
False
],
[
False
,
False
]],
dtype
=
np
.
bool
)
result
.
write
(
util
.
numpy_to_c
(
result_arr
),
0
,
4
)
handle
=
backend
.
compile
(
function
)
handle
.
call
([
result
],
[
a
,
b
])
backend
.
call
(
backend
.
compile
(
function
),
[
result
],
[
a
,
b
])
result
.
read
(
util
.
numpy_to_c
(
result_arr
),
0
,
4
)
a_arr
=
np
.
array
([[
1
,
5
],
[
3
,
2
]],
dtype
=
np
.
float32
)
...
...
@@ -258,8 +256,7 @@ def test_add_with_mul():
result_arr
=
np
.
array
([
0
,
0
,
0
,
0
],
dtype
=
np
.
float32
)
result
.
write
(
util
.
numpy_to_c
(
result_arr
),
0
,
16
)
handle
=
backend
.
compile
(
function
)
handle
.
call
([
result
],
[
a
,
b
,
c
])
backend
.
call
(
backend
.
compile
(
function
),
[
result
],
[
a
,
b
,
c
])
result
.
read
(
util
.
numpy_to_c
(
result_arr
),
0
,
16
)
a_arr
=
np
.
array
([
1
,
2
,
3
,
4
],
dtype
=
np
.
float32
)
...
...
@@ -367,8 +364,7 @@ def unary_op_exec(op_str, input_list):
result_arr
=
np
.
zeros
(
shape_np
,
dtype
=
np
.
float32
)
result
.
write
(
util
.
numpy_to_c
(
result_arr
),
0
,
16
)
handle
=
backend
.
compile
(
function
)
handle
.
call
([
result
],
[
a
])
backend
.
call
(
backend
.
compile
(
function
),
[
result
],
[
a
])
result
.
read
(
util
.
numpy_to_c
(
result_arr
),
0
,
16
)
a_arr
=
np
.
array
(
input_list
,
dtype
=
np
.
float32
)
...
...
@@ -501,8 +497,7 @@ def test_not():
result_arr
=
np
.
array
([
False
,
False
],
dtype
=
np
.
bool
)
result
.
write
(
util
.
numpy_to_c
(
result_arr
),
0
,
2
)
handle
=
backend
.
compile
(
function
)
handle
.
call
([
result
],
[
a
])
backend
.
call
(
backend
.
compile
(
function
),
[
result
],
[
a
])
result
.
read
(
util
.
numpy_to_c
(
result_arr
),
0
,
2
)
a_arr
=
np
.
array
([
True
,
False
],
dtype
=
np
.
bool
)
...
...
@@ -527,8 +522,7 @@ def test_sum():
result_arr
=
np
.
array
([
0
],
dtype
=
np
.
float32
)
result
.
write
(
util
.
numpy_to_c
(
result_arr
),
0
,
4
)
handle
=
backend
.
compile
(
function
)
handle
.
call
([
result
],
[
a
])
backend
.
call
(
backend
.
compile
(
function
),
[
result
],
[
a
])
result
.
read
(
util
.
numpy_to_c
(
result_arr
),
0
,
4
)
a_arr
=
np
.
array
([
1
,
2
,
3
,
4
],
dtype
=
np
.
float32
)
...
...
@@ -553,8 +547,7 @@ def test_reshape():
result_arr
=
np
.
array
([[
0
,
0
],
[
0
,
0
],
[
0
,
0
]],
dtype
=
np
.
float32
)
result
.
write
(
util
.
numpy_to_c
(
result_arr
),
0
,
24
)
handle
=
backend
.
compile
(
function
)
handle
.
call
([
result
],
[
a
])
backend
.
call
(
backend
.
compile
(
function
),
[
result
],
[
a
])
result
.
read
(
util
.
numpy_to_c
(
result_arr
),
0
,
24
)
a_arr
=
np
.
array
([[
1
,
2
,
3
],
[
4
,
5
,
6
]],
dtype
=
np
.
float32
)
...
...
@@ -580,8 +573,7 @@ def test_convert():
result_arr
=
np
.
array
([
False
,
False
,
False
],
dtype
=
np
.
bool
)
result
.
write
(
util
.
numpy_to_c
(
result_arr
),
0
,
3
)
handle
=
backend
.
compile
(
function
)
handle
.
call
([
result
],
[
a
])
backend
.
call
(
backend
.
compile
(
function
),
[
result
],
[
a
])
result
.
read
(
util
.
numpy_to_c
(
result_arr
),
0
,
3
)
a_arr
=
np
.
array
([
1
,
5
,
3
],
dtype
=
np
.
float32
)
...
...
@@ -598,8 +590,7 @@ def test_convert():
result_arr
=
np
.
array
([
0
,
0
,
0
],
dtype
=
np
.
int32
)
result
.
write
(
util
.
numpy_to_c
(
result_arr
),
0
,
12
)
handle
=
backend
.
compile
(
function
)
handle
.
call
([
result
],
[
a
])
backend
.
call
(
backend
.
compile
(
function
),
[
result
],
[
a
])
result
.
read
(
util
.
numpy_to_c
(
result_arr
),
0
,
12
)
a_arr
=
np
.
array
([
1.4
,
5.4
,
3.9
],
dtype
=
np
.
float32
)
...
...
@@ -623,8 +614,7 @@ def test_broadcast():
result_arr
=
np
.
zeros
((
3
,
3
),
dtype
=
np
.
float32
)
result
.
write
(
util
.
numpy_to_c
(
result_arr
),
0
,
36
)
handle
=
backend
.
compile
(
function
)
handle
.
call
([
result
],
[
a
])
backend
.
call
(
backend
.
compile
(
function
),
[
result
],
[
a
])
result
.
read
(
util
.
numpy_to_c
(
result_arr
),
0
,
36
)
a_arr
=
np
.
array
([[
0
],
[
0
],
[
0
]],
dtype
=
np
.
float32
)
...
...
@@ -646,8 +636,7 @@ def test_constant():
result_arr
=
np
.
zeros
((
3
,
3
),
dtype
=
np
.
float32
)
result
.
write
(
util
.
numpy_to_c
(
result_arr
),
0
,
36
)
handle
=
backend
.
compile
(
function
)
handle
.
call
([
result
],
[])
backend
.
call
(
backend
.
compile
(
function
),
[
result
],
[])
result
.
read
(
util
.
numpy_to_c
(
result_arr
),
0
,
36
)
result_arr_ref
=
np
.
arange
(
9
)
.
reshape
(
3
,
3
)
...
...
@@ -670,8 +659,7 @@ def test_onehot():
result_arr
=
np
.
zeros
((
3
,
3
),
dtype
=
np
.
float32
)
result
.
write
(
util
.
numpy_to_c
(
result_arr
),
0
,
36
)
handle
=
backend
.
compile
(
function
)
handle
.
call
([
result
],
[
a
])
backend
.
call
(
backend
.
compile
(
function
),
[
result
],
[
a
])
result
.
read
(
util
.
numpy_to_c
(
result_arr
),
0
,
36
)
a_arr
=
np
.
array
([
1
,
0
,
2
])
...
...
@@ -703,8 +691,7 @@ def test_concat():
result_arr
=
np
.
zeros
(
6
,
dtype
=
np
.
float32
)
.
reshape
(
3
,
2
)
result
.
write
(
util
.
numpy_to_c
(
result_arr
),
0
,
24
)
handle
=
backend
.
compile
(
function
)
handle
.
call
([
result
],
[
a
,
b
,
c
])
backend
.
call
(
backend
.
compile
(
function
),
[
result
],
[
a
,
b
,
c
])
result
.
read
(
util
.
numpy_to_c
(
result_arr
),
0
,
24
)
a_arr
=
np
.
array
([[
1
,
2
]],
dtype
=
np
.
float32
)
...
...
@@ -755,8 +742,7 @@ def test_select():
result_arr
=
np
.
array
([[
0
,
0
]],
dtype
=
np
.
float32
)
result
.
write
(
util
.
numpy_to_c
(
result_arr
),
0
,
8
)
handle
=
backend
.
compile
(
function
)
handle
.
call
([
result
],
[
a
,
b
,
c
])
backend
.
call
(
backend
.
compile
(
function
),
[
result
],
[
a
,
b
,
c
])
result
.
read
(
util
.
numpy_to_c
(
result_arr
),
0
,
8
)
result_arr_ref
=
np
.
array
([[
5
,
8
]])
...
...
@@ -787,8 +773,7 @@ def test_slice():
result_arr
=
np
.
zeros
(
16
,
dtype
=
np
.
float32
)
.
reshape
(
4
,
4
)
result
.
write
(
util
.
numpy_to_c
(
result_arr
),
0
,
16
*
4
)
handle
=
backend
.
compile
(
function
)
handle
.
call
([
result
],
[
a
])
backend
.
call
(
backend
.
compile
(
function
),
[
result
],
[
a
])
result
.
read
(
util
.
numpy_to_c
(
result_arr
),
0
,
64
)
result_arr_ref
=
input_arr
[
lower_bounds
[
0
]:
upper_bounds
[
0
],
lower_bounds
[
1
]:
upper_bounds
[
1
]]
...
...
@@ -807,8 +792,7 @@ def test_slice():
result_arr
=
np
.
zeros
(
8
,
dtype
=
np
.
float32
)
.
reshape
(
4
,
2
)
result
.
write
(
util
.
numpy_to_c
(
result_arr
),
0
,
8
*
4
)
handle
=
backend
.
compile
(
function
)
handle
.
call
([
result
],
[
a
])
backend
.
call
(
backend
.
compile
(
function
),
[
result
],
[
a
])
result
.
read
(
util
.
numpy_to_c
(
result_arr
),
0
,
32
)
result_arr_ref
=
result_arr_ref
[::
strides
[
0
],
::
strides
[
1
]]
...
...
@@ -842,8 +826,7 @@ def test_replace_slice():
result_arr
=
np
.
zeros
(
24
,
dtype
=
np
.
float32
)
.
reshape
(
6
,
4
)
result
.
write
(
util
.
numpy_to_c
(
result_arr
),
0
,
24
*
4
)
handle
=
backend
.
compile
(
function
)
handle
.
call
([
result
],
[
a
,
b
])
backend
.
call
(
backend
.
compile
(
function
),
[
result
],
[
a
,
b
])
result
.
read
(
util
.
numpy_to_c
(
result_arr
),
0
,
24
*
4
)
result_arr_ref
=
np
.
copy
(
input_arr_a
)
...
...
@@ -861,8 +844,7 @@ def test_replace_slice():
parameter_list
,
'test'
)
backend
=
Backend
.
create
(
pytest
.
config
.
getoption
(
'backend'
))
handle
=
backend
.
compile
(
function
)
handle
.
call
([
result
],
[
a
,
b
])
backend
.
call
(
backend
.
compile
(
function
),
[
result
],
[
a
,
b
])
result
.
read
(
util
.
numpy_to_c
(
result_arr
),
0
,
24
*
4
)
result_arr_ref
=
np
.
copy
(
input_arr_a
)
...
...
@@ -893,8 +875,7 @@ def test_max_pool():
result_arr
=
np
.
zeros
(
8
,
dtype
=
np
.
float32
)
.
reshape
(
1
,
1
,
8
)
result
.
write
(
util
.
numpy_to_c
(
result_arr
),
0
,
8
*
4
)
handle
=
backend
.
compile
(
function
)
handle
.
call
([
result
],
[
a
])
backend
.
call
(
backend
.
compile
(
function
),
[
result
],
[
a
])
result
.
read
(
util
.
numpy_to_c
(
result_arr
),
0
,
32
)
result_arr_ref
=
(
np
.
arange
(
8
)
+
2
)
.
reshape
(
1
,
1
,
8
)
...
...
@@ -911,8 +892,7 @@ def test_max_pool():
result_arr
=
np
.
zeros
(
size
,
dtype
=
np
.
float32
)
.
reshape
(
1
,
1
,
size
)
result
.
write
(
util
.
numpy_to_c
(
result_arr
),
0
,
size
*
4
)
handle
=
backend
.
compile
(
function
)
handle
.
call
([
result
],
[
a
])
backend
.
call
(
backend
.
compile
(
function
),
[
result
],
[
a
])
result
.
read
(
util
.
numpy_to_c
(
result_arr
),
0
,
size
*
4
)
result_arr_ref
=
((
np
.
arange
(
size
)
+
1
)
*
2
)
.
reshape
(
1
,
1
,
size
)
...
...
@@ -937,8 +917,7 @@ def test_max_pool():
result_arr
=
np
.
zeros
(
64
,
dtype
=
np
.
float32
)
.
reshape
(
1
,
1
,
8
,
8
)
result
.
write
(
util
.
numpy_to_c
(
result_arr
),
0
,
8
*
8
*
4
)
handle
=
backend
.
compile
(
function
)
handle
.
call
([
result
],
[
a
])
backend
.
call
(
backend
.
compile
(
function
),
[
result
],
[
a
])
result
.
read
(
util
.
numpy_to_c
(
result_arr
),
0
,
8
*
8
*
4
)
result_arr_ref
=
((
np
.
arange
(
100
)
.
reshape
(
10
,
10
))[
2
:,
2
:])
.
reshape
(
1
,
1
,
8
,
8
)
...
...
@@ -955,8 +934,7 @@ def test_max_pool():
result_arr
=
np
.
zeros
(
size
*
size
,
dtype
=
np
.
float32
)
.
reshape
(
1
,
1
,
size
,
size
)
result
.
write
(
util
.
numpy_to_c
(
result_arr
),
0
,
size
*
size
*
4
)
handle
=
backend
.
compile
(
function
)
handle
.
call
([
result
],
[
a
])
backend
.
call
(
backend
.
compile
(
function
),
[
result
],
[
a
])
result
.
read
(
util
.
numpy_to_c
(
result_arr
),
0
,
size
*
size
*
4
)
result_arr_ref
=
((
np
.
arange
(
100
)
.
reshape
(
10
,
10
))[
2
::
2
,
2
::
2
])
.
reshape
(
1
,
1
,
size
,
size
)
...
...
@@ -1036,8 +1014,7 @@ def test_convolution():
result
=
backend
.
create_tensor
(
element_type
,
Shape
([
1
,
1
,
14
,
14
]))
result
.
write
(
util
.
numpy_to_c
(
result_arr
),
0
,
14
*
14
*
4
)
handle
=
backend
.
compile
(
function
)
handle
.
call
([
result
],
[
a
,
b
])
backend
.
call
(
backend
.
compile
(
function
),
[
result
],
[
a
,
b
])
result
.
read
(
util
.
numpy_to_c
(
result_arr
),
0
,
14
*
14
*
4
)
result_arr_ref
=
convolution2d
(
image_arr
[
0
][
0
],
filter_arr
[
0
][
0
])
.
reshape
(
1
,
1
,
14
,
14
)
...
...
@@ -1071,8 +1048,7 @@ def test_convolution_with_strides():
result_arr
=
np
.
zeros
(
16
,
dtype
=
np
.
float32
)
.
reshape
(
1
,
1
,
4
,
4
)
result
=
backend
.
create_tensor
(
element_type
,
Shape
([
1
,
1
,
4
,
4
]))
result
.
write
(
util
.
numpy_to_c
(
result_arr
),
0
,
4
*
4
*
4
)
handle
=
backend
.
compile
(
function
)
handle
.
call
([
result
],
[
a
,
b
])
backend
.
call
(
backend
.
compile
(
function
),
[
result
],
[
a
,
b
])
result
.
read
(
util
.
numpy_to_c
(
result_arr
),
0
,
4
*
4
*
4
)
result_arr_ref
=
convolution2d
(
image_arr
[
0
][
0
],
filter_arr
[
0
][
0
],
strides
)
.
reshape
(
1
,
1
,
4
,
4
)
...
...
@@ -1106,8 +1082,7 @@ def test_convolution_with_filter_dilation():
result_arr
=
np
.
zeros
(
36
,
dtype
=
np
.
float32
)
.
reshape
(
1
,
1
,
6
,
6
)
result
=
backend
.
create_tensor
(
element_type
,
Shape
([
1
,
1
,
6
,
6
]))
result
.
write
(
util
.
numpy_to_c
(
result_arr
),
0
,
6
*
6
*
4
)
handle
=
backend
.
compile
(
function
)
handle
.
call
([
result
],
[
a
,
b
])
backend
.
call
(
backend
.
compile
(
function
),
[
result
],
[
a
,
b
])
result
.
read
(
util
.
numpy_to_c
(
result_arr
),
0
,
6
*
6
*
4
)
result_arr_ref
=
convolution2d
(
image_arr
[
0
][
0
],
filter_arr
[
0
][
0
],
strides
,
...
...
@@ -1147,8 +1122,7 @@ def test_convolution_with_padding():
result_arr
=
np
.
zeros
(
36
,
dtype
=
np
.
float32
)
.
reshape
(
1
,
1
,
6
,
6
)
result
=
backend
.
create_tensor
(
element_type
,
Shape
([
1
,
1
,
6
,
6
]))
result
.
write
(
util
.
numpy_to_c
(
result_arr
),
0
,
6
*
6
*
4
)
handle
=
backend
.
compile
(
function
)
handle
.
call
([
result
],
[
a
,
b
])
backend
.
call
(
backend
.
compile
(
function
),
[
result
],
[
a
,
b
])
result
.
read
(
util
.
numpy_to_c
(
result_arr
),
0
,
6
*
6
*
4
)
result_arr_ref
=
convolution2d
(
image_arr
[
0
][
0
],
filter_arr
[
0
][
0
],
strides
,
...
...
@@ -1186,8 +1160,7 @@ def test_convolution_with_padding():
result_arr
=
np
.
zeros
(
81
,
dtype
=
np
.
float32
)
.
reshape
(
1
,
1
,
9
,
9
)
result
=
backend
.
create_tensor
(
element_type
,
Shape
([
1
,
1
,
9
,
9
]))
result
.
write
(
util
.
numpy_to_c
(
result_arr
),
0
,
9
*
9
*
4
)
handle
=
backend
.
compile
(
function
)
handle
.
call
([
result
],
[
a
,
b
])
backend
.
call
(
backend
.
compile
(
function
),
[
result
],
[
a
,
b
])
result
.
read
(
util
.
numpy_to_c
(
result_arr
),
0
,
9
*
9
*
4
)
result_arr_ref
=
convolution2d
(
image_arr
[
0
][
0
],
filter_arr
[
0
][
0
],
strides
,
...
...
@@ -1228,8 +1201,7 @@ def test_convolution_with_data_dilation():
result_arr
=
np
.
zeros
(
17
*
17
,
dtype
=
np
.
float32
)
.
reshape
(
1
,
1
,
17
,
17
)
result
=
backend
.
create_tensor
(
element_type
,
Shape
([
1
,
1
,
17
,
17
]))
result
.
write
(
util
.
numpy_to_c
(
result_arr
),
0
,
17
*
17
*
4
)
handle
=
backend
.
compile
(
function
)
handle
.
call
([
result
],
[
a
,
b
])
backend
.
call
(
backend
.
compile
(
function
),
[
result
],
[
a
,
b
])
result
.
read
(
util
.
numpy_to_c
(
result_arr
),
0
,
17
*
17
*
4
)
result_arr_ref
=
convolution2d
(
image_arr
[
0
][
0
],
filter_arr
[
0
][
0
],
strides
,
...
...
@@ -1276,8 +1248,7 @@ def test_convolutionBackpropData():
result_arr
=
np
.
zeros
(
10
*
10
,
dtype
=
np
.
float32
)
.
reshape
(
1
,
1
,
10
,
10
)
result
=
backend
.
create_tensor
(
element_type
,
Shape
([
1
,
1
,
10
,
10
]))
result
.
write
(
util
.
numpy_to_c
(
result_arr
),
0
,
10
*
10
*
4
)
handle
=
backend
.
compile
(
function
)
handle
.
call
([
result
],
[
a
,
b
])
backend
.
call
(
backend
.
compile
(
function
),
[
result
],
[
a
,
b
])
result
.
read
(
util
.
numpy_to_c
(
result_arr
),
0
,
10
*
10
*
4
)
result_arr_ref
=
np
.
array
(
...
...
@@ -1332,8 +1303,7 @@ def test_convolutionBackpropFilters():
result_arr
=
np
.
zeros
(
3
*
3
,
dtype
=
np
.
float32
)
.
reshape
(
1
,
1
,
3
,
3
)
result
=
backend
.
create_tensor
(
element_type
,
Shape
([
1
,
1
,
3
,
3
]))
result
.
write
(
util
.
numpy_to_c
(
result_arr
),
0
,
3
*
3
*
4
)
handle
=
backend
.
compile
(
function
)
handle
.
call
([
result
],
[
a
,
b
])
backend
.
call
(
backend
.
compile
(
function
),
[
result
],
[
a
,
b
])
result
.
read
(
util
.
numpy_to_c
(
result_arr
),
0
,
3
*
3
*
4
)
result_arr_ref
=
np
.
array
(
...
...
src/ngraph/CMakeLists.txt
View file @
6a777636
...
...
@@ -139,8 +139,8 @@ set (SRC
pass/memory_visualize.cpp
pass/nop_elimination.cpp
pass/pass.cpp
pass/pass_config.cpp
pass/prefix_reshape_elimination.cpp
pass/pass_config.cpp
pass/prefix_reshape_elimination.cpp
pass/propagate_cacheability.cpp
pass/reshape_elimination.cpp
pass/reshape_sinking.cpp
...
...
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