Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tic
Overview
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenyuanbo
tic
Commits
6737739c
Commit
6737739c
authored
Jan 14, 2019
by
Ashutosh Parkhi
Committed by
Siva
Jan 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Tensorflow] Support for Crop (#2285)
fixes fixes
parent
a9bd5593
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
nnvm/python/nnvm/frontend/tensorflow.py
+16
-0
nnvm/tests/python/frontend/tensorflow/test_forward.py
+18
-0
No files found.
nnvm/python/nnvm/frontend/tensorflow.py
View file @
6737739c
...
...
@@ -388,6 +388,21 @@ def _pack():
return
_impl
def
_slice
():
def
_impl
(
inputs
,
attr
,
params
):
begin
=
params
.
pop
(
inputs
[
1
]
.
list_output_names
()[
0
])
.
asnumpy
()
.
tolist
()
size
=
params
.
pop
(
inputs
[
2
]
.
list_output_names
()[
0
])
.
asnumpy
()
.
tolist
()
data_shape
=
attr
[
'_input_shapes'
][
inputs
[
0
]]
data_dim
=
len
(
data_shape
)
end
=
size
for
i
in
range
(
data_dim
):
if
size
[
i
]
==
-
1
:
end
[
i
]
=
data_shape
[
i
]
-
begin
[
i
]
else
:
end
[
i
]
+=
begin
[
i
]
return
_sym
.
strided_slice
(
inputs
[
0
],
begin
=
begin
,
end
=
size
)
return
_impl
def
_reshape
():
def
_impl
(
inputs
,
attr
,
params
):
try
:
...
...
@@ -883,6 +898,7 @@ _convert_map = {
'Sum'
:
_sum
(),
'Square'
:
_square
(),
'Pack'
:
_pack
(),
'Slice'
:
_slice
(),
'LeakyRelu'
:
AttrCvt
(
'leaky_relu'
),
'Relu'
:
AttrCvt
(
'relu'
),
'Reshape'
:
_reshape
(),
...
...
nnvm/tests/python/frontend/tensorflow/test_forward.py
View file @
6737739c
...
...
@@ -656,6 +656,23 @@ def test_forward_resize_bilinear():
#######################################################################
# Crop to bounding box
# --------------------
def
_test_crop
(
in_shape
,
off_h
,
off_w
,
tar_h
,
tar_w
):
""" Crop to bounding box """
data
=
np
.
random
.
uniform
(
size
=
in_shape
)
.
astype
(
'float32'
)
with
tf
.
Graph
()
.
as_default
():
in_data
=
array_ops
.
placeholder
(
shape
=
data
.
shape
,
dtype
=
data
.
dtype
)
tf
.
image
.
crop_to_bounding_box
(
in_data
,
off_h
,
off_w
,
tar_h
,
tar_w
)
compare_tf_with_tvm
(
data
,
'Placeholder:0'
,
'crop_to_bounding_box/Slice:0'
)
def
test_forward_crop
():
""" Crop to bounding box """
_test_crop
((
1
,
224
,
224
,
3
),
20
,
20
,
120
,
120
)
#######################################################################
# LSTM
# ----
...
...
@@ -1139,6 +1156,7 @@ if __name__ == '__main__':
test_forward_squeeze
()
test_forward_pack
()
test_forward_resize_bilinear
()
test_forward_crop
()
test_forward_pad
()
test_forward_gather
()
test_forward_stridedslice
()
...
...
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