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
02ddb5a9
Commit
02ddb5a9
authored
Sep 06, 2019
by
雾雨魔理沙
Committed by
Jared Roesch
Sep 06, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save (#3901)
parent
19f8c123
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
4 deletions
+10
-4
python/tvm/relay/op/_tensor_grad.py
+6
-0
tests/python/relay/test_op_grad_level3.py
+2
-3
tests/python/relay/test_op_level3.py
+2
-1
No files found.
python/tvm/relay/op/_tensor_grad.py
View file @
02ddb5a9
...
...
@@ -290,6 +290,12 @@ def dense_grad(orig, grad):
collapse_sum_like
(
data
*
transpose
(
grad
),
weight
)]
@register_gradient
(
"reshape"
)
def
reshape_grad
(
orig
,
grad
):
"""Gradient of reshape"""
return
[
reshape_like
(
grad
,
orig
.
args
[
0
])]
@register_gradient
(
"nn.batch_flatten"
)
def
batch_flatten_grad
(
orig
,
grad
):
"""Returns grad reshaped to data dims"""
...
...
tests/python/relay/test_op_grad_level3.py
View file @
02ddb5a9
...
...
@@ -15,6 +15,7 @@
# specific language governing permissions and limitations
# under the License.
import
numpy
as
np
import
pytest
import
tvm
from
tvm
import
relay
...
...
@@ -58,6 +59,4 @@ def test_negative_grad():
if
__name__
==
"__main__"
:
test_clip
()
test_transpose_grad
()
test_negative_grad
()
pytest
.
main
()
tests/python/relay/test_op_level3.py
View file @
02ddb5a9
...
...
@@ -21,7 +21,7 @@ from nose.tools import raises
import
tvm
from
tvm
import
relay
from
tvm.relay
import
create_executor
,
transform
from
tvm.relay.testing
import
ctx_list
from
tvm.relay.testing
import
ctx_list
,
check_grad
def
run_infer_type
(
expr
):
mod
=
relay
.
Module
.
from_expr
(
expr
)
...
...
@@ -247,6 +247,7 @@ def test_reshape():
assert
zz
.
checked_type
==
relay
.
ty
.
TensorType
(
oshape
,
"float32"
)
func
=
relay
.
Function
([
x
],
z
)
check_grad
(
func
)
x_data
=
np
.
random
.
uniform
(
low
=-
1
,
high
=
1
,
size
=
shape
)
.
astype
(
"float32"
)
ref_res
=
np
.
reshape
(
x_data
,
oshape
)
for
target
,
ctx
in
ctx_list
():
...
...
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