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

[NCHW][SWDEV-312112] fix local buffer alignment bug on transpose+nhwc kernel's solver #1324

Merged
merged 8 commits into from
Dec 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 4 additions & 2 deletions src/conv/invokers/impl_gemm_dynamic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,8 @@ InvokerFactory MakeImplGemmDynamicForwardXdlopsNHWCInvokerFactory(
trans_output_idx = idx++;
}

const size_t cast_offset = is_nchw ? (trans_output_offset + trans_output_size) : 0;
// 4 bytes alignment to do atomic add
const size_t cast_offset = is_nchw ? (((trans_output_offset + trans_output_size + 3) >> 2) << 2) : 0;
atamazov marked this conversation as resolved.
Show resolved Hide resolved
const size_t cast_size = need_cast ? miopen::GetTypeSize(miopenFloat) * n * k * ho * wo : 0;

const int kID_trans_start = isGfx90aFp16altSupport ? 2 : 1;
Expand Down Expand Up @@ -886,7 +887,8 @@ InvokerFactory MakeImplGemmDynamicBackwardDataXdlopsNHWCInvokerFactory(
trans_output_idx = idx++;
}

const size_t cast_offset = is_nchw ? (trans_output_offset + trans_output_size) : 0;
// 4 bytes alignment to do atomic add
const size_t cast_offset = is_nchw ? (((trans_output_offset + trans_output_size + 3) >> 2) << 2) : 0;
const size_t cast_size = need_cast ? miopen::GetTypeSize(miopenFloat) * n * c * hi * wi : 0;

const int kID_trans_start = isGfx90aFp16altSupport ? 2 : 1;
Expand Down
3 changes: 3 additions & 0 deletions src/solver/conv_asm_implicit_gemm_gtc_bwd_nhwc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,9 @@ ConvAsmImplicitGemmGTCDynamicBwdXdlopsNHWC::GetWorkspaceSize(const ConvolutionCo
workspace_size += trans_weight.GetSize();
if(!trans_output.IsSkippable())
workspace_size += trans_output.GetSize();

// 4 bytes alignment to do atomic add
workspace_size = ((workspace_size + 3) >> 2) << 2;
}

if(!ctx.IsFp32())
Expand Down
3 changes: 3 additions & 0 deletions src/solver/conv_asm_implicit_gemm_gtc_fwd_nhwc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,9 @@ ConvAsmImplicitGemmGTCDynamicFwdXdlopsNHWC::GetWorkspaceSize(const ConvolutionCo
workspace_size += trans_weight.GetSize();
if(!trans_output.IsSkippable())
workspace_size += trans_output.GetSize();

// 4 bytes alignment to do atomic add
workspace_size = ((workspace_size + 3) >> 2) << 2;
}

if(!ctx.IsFp32())
Expand Down
6 changes: 5 additions & 1 deletion src/solver/conv_asm_implicit_gemm_gtc_wrw_nhwc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,9 @@ ConvAsmImplicitGemmGTCDynamicWrwXdlopsNHWC::GetWorkspaceSize(const ConvolutionCo
workspace_size += trans_weight.GetSize();
if(!trans_output.IsSkippable())
workspace_size += trans_output.GetSize();

// 4 bytes alignment to do atomic add
workspace_size = ((workspace_size + 3) >> 2) << 2;
}

if(!ctx.IsFp32())
Expand Down Expand Up @@ -1071,7 +1074,8 @@ ConvSolution ConvAsmImplicitGemmGTCDynamicWrwXdlopsNHWC::GetSolution(

MIOPEN_LOG_I2(SolverDbId(*this) << ": " << config.ToString() << msg.str());

const size_t cast_offset = is_nchw ? (trans_output_offset + trans_output_size) : 0;
// 4 bytes alignment to do atomic add
const size_t cast_offset = is_nchw ? (((trans_output_offset + trans_output_size + 3) >> 2) << 2) : 0;
const size_t cast_size = need_cast ?
miopen::GetTypeSize(miopenFloat) * k * (c / group) * y * x : 0;

Expand Down