Skip to content

Commit

Permalink
fixes 'misaligned address' when using 'group' parameter in CNN layers…
Browse files Browse the repository at this point in the history
…. This fixes the error by aligning by the address to be multiple of m (32). Fixes also another bug of not correctly grouped if..else

see: BVLC#5729
  • Loading branch information
mentezar committed Oct 13, 2019
1 parent 9ac621b commit 5dde827
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/caffe/layers/cudnn_conv_layer.cpp
Expand Up @@ -186,6 +186,8 @@ void CuDNNConvolutionLayer<Dtype>::Reshape(
total_workspace_bwd_data);
max_workspace = std::max(max_workspace, total_workspace_bwd_filter);
// ensure all groups have enough workspace
size_t m=32;
max_workspace = (max_workspace + m-1) / m * m; //align address to be multiples of m
size_t total_max_workspace = max_workspace *
(this->group_ * CUDNN_STREAMS_PER_GROUP);

Expand Down Expand Up @@ -217,10 +219,11 @@ void CuDNNConvolutionLayer<Dtype>::Reshape(
workspaceData = NULL;
workspaceSizeInBytes = 0;
}

// if we succeed in the allocation, set pointer aliases for workspaces
for (int g = 0; g < (this->group_ * CUDNN_STREAMS_PER_GROUP); g++) {
workspace[g] = reinterpret_cast<char *>(workspaceData) + g*max_workspace;
else {
// if we succeed in the allocation, set pointer aliases for workspaces
for (int g = 0; g < (this->group_ * CUDNN_STREAMS_PER_GROUP); g++) {
workspace[g] = reinterpret_cast<char *>(workspaceData) + g*max_workspace;
}
}
}

Expand Down

0 comments on commit 5dde827

Please sign in to comment.