Skip to content

Commit

Permalink
Getting rid of OpenBLAS compilation warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
TadasBaltrusaitis committed Jun 28, 2018
1 parent 120330c commit fcf6fbe
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 9 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ MESSAGE(" Boost_LIBRARY_DIRS: ${Boost_LIBRARY_DIRS}")
find_package( TBB CONFIG )

# If not found, use FindTBB.cmake
#if ("${TBB_LIBRARIES}" STREQUAL "" OR NOT ${TBB_LIBRARIES})
if ("${TBB_LIBRARIES}" STREQUAL "")
MESSAGE("TBB not found in CONFIG, searching with FindTBB.cmake.")
find_package( TBB REQUIRED )
if ("${TBB_LIBRARIES}" STREQUAL "")
MESSAGE(FATAL_ERROR "TBB not found")
endif()
else()
MESSAGE("TBB found in CONFIG: ${TBB_LIBRARIES}")
endif()
Expand Down
5 changes: 3 additions & 2 deletions lib/local/LandmarkDetector/src/CCNF_patch_expert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,8 @@ void CCNF_patch_expert::ResponseOpenBlas(const cv::Mat_<float> &area_of_interest
// Perform matrix multiplication in OpenBLAS (fortran call)
float alpha1 = 1.0;
float beta1 = 0.0;
sgemm_("N", "N", &normalized_input.cols, &weight_matrix.rows, &weight_matrix.cols, &alpha1, (float*)normalized_input.data, &normalized_input.cols, (float*)weight_matrix.data, &weight_matrix.cols, &beta1, (float*)neuron_resp_full.data, &normalized_input.cols);
char* N = "N";
sgemm_(N, N, &normalized_input.cols, &weight_matrix.rows, &weight_matrix.cols, &alpha1, (float*)normalized_input.data, &normalized_input.cols, (float*)weight_matrix.data, &weight_matrix.cols, &beta1, (float*)neuron_resp_full.data, &normalized_input.cols);

// Above is a faster version of this
//cv::Mat_<float> neuron_resp_full = this->weight_matrix * normalized_input;
Expand Down Expand Up @@ -494,7 +495,7 @@ void CCNF_patch_expert::ResponseOpenBlas(const cv::Mat_<float> &area_of_interest
// Perform matrix multiplication in OpenBLAS (fortran call)
alpha1 = 1.0;
beta1 = 0.0;
sgemm_("N", "N", &resp_vec_f.cols, &Sigmas[s_to_use].rows, &Sigmas[s_to_use].cols, &alpha1, (float*)resp_vec_f.data, &resp_vec_f.cols, (float*)Sigmas[s_to_use].data, &Sigmas[s_to_use].cols, &beta1, (float*)out.data, &resp_vec_f.cols);
sgemm_(N, N, &resp_vec_f.cols, &Sigmas[s_to_use].rows, &Sigmas[s_to_use].cols, &alpha1, (float*)resp_vec_f.data, &resp_vec_f.cols, (float*)Sigmas[s_to_use].data, &Sigmas[s_to_use].cols, &beta1, (float*)out.data, &resp_vec_f.cols);

// Above is a faster version of this
//cv::Mat out = Sigmas[s_to_use] * resp_vec_f;
Expand Down
6 changes: 4 additions & 2 deletions lib/local/LandmarkDetector/src/CEN_patch_expert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ void CEN_patch_expert::Response(const cv::Mat_<float> &area_of_interest, cv::Mat
// Perform matrix multiplication in OpenBLAS (fortran call)
float alpha1 = 1.0;
float beta1 = 0.0;
sgemm_("N", "N", &resp.cols, &weight.rows, &weight.cols, &alpha1, m1, &resp.cols, m2, &weight.cols, &beta1, m3, &resp.cols);
char* N = "N";
sgemm_(N, N, &resp.cols, &weight.rows, &weight.cols, &alpha1, m1, &resp.cols, m2, &weight.cols, &beta1, m3, &resp.cols);

// The above is a faster version of this, by calling the fortran version directly
//cblas_sgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, resp.cols, weight.rows, weight.cols, 1, m1, resp.cols, m2, weight.cols, 0.0, m3, resp.cols);
Expand Down Expand Up @@ -489,7 +490,8 @@ void CEN_patch_expert::ResponseInternal(cv::Mat_<float>& response)
// Perform matrix multiplication in OpenBLAS (fortran call)
float alpha1 = 1.0;
float beta1 = 0.0;
sgemm_("N", "N", &resp.cols, &weights[layer].rows, &weights[layer].cols, &alpha1, m1, &resp.cols, m2, &weights[layer].cols, &beta1, m3, &resp.cols);
char* N = "N";
sgemm_(N, N, &resp.cols, &weights[layer].rows, &weights[layer].cols, &alpha1, m1, &resp.cols, m2, &weights[layer].cols, &beta1, m3, &resp.cols);

// The above is a faster version of this, by calling the fortran version directly
//cblas_sgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, resp.cols, weight.rows, weight.cols, 1, m1, resp.cols, m2, weight.cols, 0.0, m3, resp.cols);
Expand Down
3 changes: 2 additions & 1 deletion lib/local/LandmarkDetector/src/CNN_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,8 @@ namespace LandmarkDetector
float alpha = 1.0f;
float beta = 0.0f;
// Call fortran directly (faster)
sgemm_("N", "N", &m2_cols, &num_rows, &pre_alloc_im2col.cols, &alpha, m2, &m2_cols, m1, &pre_alloc_im2col.cols, &beta, m3, &m2_cols);
char* N = "N";
sgemm_(N, N, &m2_cols, &num_rows, &pre_alloc_im2col.cols, &alpha, m2, &m2_cols, m1, &pre_alloc_im2col.cols, &beta, m3, &m2_cols);

// Above is equivalent to out = pre_alloc_im2col * weight_matrix;

Expand Down
3 changes: 2 additions & 1 deletion lib/local/LandmarkDetector/src/LandmarkDetectorModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,8 @@ float CLNF::NU_RLMS(cv::Vec6f& final_global, cv::Mat_<float>& final_local, const
// Perform matrix multiplication in OpenBLAS (fortran call)
float alpha1 = 1.0;
float beta1 = 1.0;
sgemm_("N", "N", &J.cols, &J_w_t.rows, &J_w_t.cols, &alpha1, (float*)J.data, &J.cols, (float*)J_w_t.data, &J_w_t.cols, &beta1, (float*)Hessian.data, &J.cols);
char* N = "N";
sgemm_(N, N, &J.cols, &J_w_t.rows, &J_w_t.cols, &alpha1, (float*)J.data, &J.cols, (float*)J_w_t.data, &J_w_t.cols, &beta1, (float*)Hessian.data, &J.cols);

// Above is a fast (but ugly) version of
// cv::Mat_<float> Hessian = J_w_t * J + regTerm;
Expand Down
6 changes: 4 additions & 2 deletions lib/local/LandmarkDetector/src/PDM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ void PDM::CalcShape3D(cv::Mat_<float>& out_shape, const cv::Mat_<float>& p_local
int p_local_cols = p_local.cols;
int princ_comp_rows = princ_comp.rows;
int princ_comp_cols = princ_comp.cols;
sgemm_("N", "N", &p_local_cols, &princ_comp_rows, &princ_comp_cols, &alpha1, (float*)p_local.data, &p_local_cols, (float*)princ_comp.data, &princ_comp_cols, &beta1, (float*)out_shape.data, &p_local_cols);
char* N = "N";
sgemm_(N, N, &p_local_cols, &princ_comp_rows, &princ_comp_cols, &alpha1, (float*)p_local.data, &p_local_cols, (float*)princ_comp.data, &princ_comp_cols, &beta1, (float*)out_shape.data, &p_local_cols);

// Above is a fast (but ugly) version of
// out_shape = mean_shape + princ_comp * p_local;
Expand Down Expand Up @@ -645,7 +646,8 @@ void PDM::CalcParams(cv::Vec6f& out_params_global, cv::Mat_<float>& out_params_l
// Perform matrix multiplication in OpenBLAS (fortran call)
float alpha1 = 1.0;
float beta1 = 1.0;
sgemm_("N", "N", &J.cols, &J_w_t.rows, &J_w_t.cols, &alpha1, (float*)J.data, &J.cols, (float*)J_w_t.data, &J_w_t.cols, &beta1, (float*)Hessian.data, &J.cols);
char* N = "N";
sgemm_(N, N, &J.cols, &J_w_t.rows, &J_w_t.cols, &alpha1, (float*)J.data, &J.cols, (float*)J_w_t.data, &J_w_t.cols, &beta1, (float*)Hessian.data, &J.cols);

// Above is a fast (but ugly) version of
// cv::Mat_<float> Hessian2 = J_w_t * J + regularisations;
Expand Down

0 comments on commit fcf6fbe

Please sign in to comment.