Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CUDNN] Support gradient kernels #9986

Merged
merged 21 commits into from
Jan 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix dgrad test
  • Loading branch information
masahi committed Jan 22, 2022
commit 42bc825b2698dcc8ce4e6dba6a7c69a746586f0f
8 changes: 6 additions & 2 deletions python/tvm/contrib/cudnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,16 @@ def conv_dgrad_shape(
C = w_shape[1]
P, Q = dy_shape[2:]
R, S = w_shape[2:]
dy_shape = dy_shape[2:]
w_shape = w_shape[2:]
elif tensor_format == 1:
N = dy_shape[0]
K = w_shape[0]
C = w_shape[1]
C = w_shape[-1]
P, Q = dy_shape[2:]
R, S = w_shape[2:]
dy_shape = dy_shape[1:-1]
w_shape = w_shape[1:-1]
else:
raise ValueError("Unsupported CuDNN tensor format: '{}'".format(tensor_format))

Expand Down Expand Up @@ -746,7 +750,7 @@ def conv_backward_data(
)

return te.extern(
x_shape,
dx_shape,
[dy, w],
lambda ins, outs: tvm.tir.call_packed(
"tvm.contrib.cudnn.conv2d.backward_data",
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/contrib/cudnn/conv_backward.cc
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ TVM_REGISTER_GLOBAL("tvm.contrib.cudnn.conv2d.backward_filter")
std::string conv_dtype = args[12];
int groups = args[13];

ConvolutionBackwardFilter(mode, format, algo, 2, groups, pad_v, stride_v, dilation_v, dy, dx,
ConvolutionBackwardFilter(mode, format, algo, 2, groups, pad_v, stride_v, dilation_v, dy, x,
dw, conv_dtype);
});

Expand Down