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

[OPENCL][BUG] fix gflops calculate bug in conv #412

Merged
merged 5 commits into from
Sep 18, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ Status OpenCLConvLayerAccImpl::ConvertWeights(float *weights_data_ptr) {
// create weights use clBuffer
DimsVector filter_buffershape;
filter_buffershape = {ROUND_UP(conv_params_.output_channel, 4), ROUND_UP(conv_params_.input_channel, 4),
conv_params_.kernel_y, conv_params_.kernel_x};
conv_params_.kernel_y, conv_params_.kernel_x};
ocl_weights_.reset(new OpenCLMemory(TNN_CL_BUFFER));
size_t type_size = sizeof(float);
if (opencl_runtime->GetFp16Enable())
Expand All @@ -182,7 +182,7 @@ Status OpenCLConvLayerAccImpl::ConvertWeights(float *weights_data_ptr) {
DimsVector filter_imageshape;
if (CT_CONV_DEPTHWISE == conv_type_) {
filter_imageshape = {conv_params_.kernel_x * conv_params_.kernel_y,
(int)(UP_DIV(conv_params_.output_channel, 4))}; // {w,h}
(int)(UP_DIV(conv_params_.output_channel, 4))}; // {w,h}
} else {
filter_imageshape = {conv_params_.input_channel, (int)(UP_DIV(conv_params_.output_channel, 4) *
conv_params_.kernel_x * conv_params_.kernel_y)};
Expand Down Expand Up @@ -216,7 +216,7 @@ Status OpenCLConvLayerAccImpl::ConvertWeights(float *weights_data_ptr) {

#if TNN_PROFILE
double OpenCLConvLayerAccImpl::GetFlops() {
return 2.0 * DimsVectorUtils::Count(output_dims_) * output_dims_[1] / conv_params_.group * conv_params_.kernel_x *
return 2.0 * DimsVectorUtils::Count(output_dims_) * input_dims_[1] / conv_params_.group * conv_params_.kernel_x *
conv_params_.kernel_y / 1000.0 / 1000.0;
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ void OpenCLDeconvLayerAccImpl::SetExtraKernelParameters(uint32_t idx, const std:

#if TNN_PROFILE
double OpenCLDeconvLayerAccImpl::GetFlops() {
return 2.0 * DimsVectorUtils::Count(input_dims_) * input_dims_[1] / deconv_params_.group * deconv_params_.kernel_x *
return 2.0 * DimsVectorUtils::Count(input_dims_) * output_dims_[1] / deconv_params_.group * deconv_params_.kernel_x *
deconv_params_.kernel_y / 1000.0 / 1000.0;
}
#endif
Expand Down