-
Notifications
You must be signed in to change notification settings - Fork 242
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
Proper fix for backward passes bwd/wrw for CK group conv 3d #2619
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,14 +84,15 @@ struct CKArgs | |
Do = ProblemInterpreter::GetOutputDepthDo(problem); | ||
Z = ProblemInterpreter::GetFilterDepthZ(problem); | ||
|
||
// On a backward pass, out is in and in is out and this is silly | ||
output = {G, N, C, Di, Hi, Wi}; | ||
input = {G, N, K, Do, Ho, Wo}; | ||
input = {G, N, C, Di, Hi, Wi}; | ||
output = {G, N, K, Do, Ho, Wo}; | ||
weight = {G, K, C, Z, Y, X}; | ||
|
||
// miopen strides to CK strides | ||
auto miopen_in_strides = problem.GetIn().GetStrides(); | ||
auto miopen_out_strides = problem.GetOut().GetStrides(); | ||
// On a backward pass, problem.GetIn() means y(or out), | ||
// and problem.GetOut means x(or in) | ||
Comment on lines
+92
to
+93
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Notice] For backward pass, x (or dx) tensor contains output data (non-const buffer), y (dy) tensor contains input data (the buffer allowed to be const). |
||
auto miopen_in_strides = problem.GetOut().GetStrides(); | ||
auto miopen_out_strides = problem.GetIn().GetStrides(); | ||
auto miopen_wei_strides = problem.GetWeights().GetStrides(); | ||
miopen_in_strides.insert(miopen_in_strides.begin(), C); | ||
miopen_out_strides.insert(miopen_out_strides.begin(), K); | ||
|
@@ -120,6 +121,28 @@ struct CKArgs | |
template <typename ConvPtr> | ||
auto MakeArgPtr(const ConvPtr& conv_ptr, ConstData_t x, Data_t dw, ConstData_t dy) const | ||
{ | ||
#if 0 // Leaving for debugging needs | ||
std::cout << "y ptr = " << dy << std::endl; | ||
std::cout << "w ptr = " << dw << std::endl; | ||
std::cout << "x ptr = " << x << std::endl; | ||
|
||
auto print_vec = [](const char* name, const auto& vec) { | ||
std::cout << name << " = [ "; | ||
for(const auto& v : vec) | ||
{ | ||
std::cout << v << ", "; | ||
} | ||
std::cout << "]\n"; | ||
}; | ||
#define PRINT_VEC(x) print_vec(#x, x); | ||
|
||
PRINT_VEC(output); | ||
PRINT_VEC(out_strides); | ||
PRINT_VEC(input); | ||
PRINT_VEC(in_strides); | ||
PRINT_VEC(weight); | ||
PRINT_VEC(wei_strides); | ||
#endif | ||
Comment on lines
+124
to
+145
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [same as above] |
||
return conv_ptr->MakeArgumentPointer(x, | ||
dw, | ||
dy, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,8 +54,9 @@ void SolverBwd(const miopen::TensorDescriptor& inputDesc, | |
const auto tensors = | ||
miopen::ConvBwdTensors{outputDesc, output, wDesc, weight, inputDesc, input}; | ||
|
||
// order for bwd data pass is dy, w, dx | ||
const auto problem = miopen::conv::ProblemDescription{ | ||
inputDesc, wDesc, outputDesc, convDesc, miopen::conv::Direction::BackwardData}; | ||
outputDesc, wDesc, inputDesc, convDesc, miopen::conv::Direction::BackwardData}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Notice] The test (incorrectly) uses notions of "input" and "output", which is not good for convolutions. This is legacy that we should get rid of in the future, I guess. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets make that the "near future" |
||
auto ctx = miopen::ExecutionContext{}; | ||
|
||
ctx.SetStream(&handle); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far we have never had such code in MIOpen, if we intend on keeping this, we should move the macro to the proper header file. and add it as a higher log level.