-
Notifications
You must be signed in to change notification settings - Fork 18.7k
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
MKL/non-MKL merge #97
Closed
Closed
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d7e3acf
compile caffe without MKL (dependency replaced by boost::random, Eigen3)
rodrigob 98f16b1
Fixed uniform distribution upper bound to be inclusive
kloudkl a7296f9
Fixed FlattenLayer Backward_cpu/gpu have no return value
kloudkl 837ce33
Fix test stochastic pooling stepsize/threshold to be same as max pooling
kloudkl 1538687
Fix math funcs, add tests, change Eigen Map to unaligned for lrn_layer
kloudkl 1488f13
relax precision of MultinomialLogisticLossLayer test
shelhamer 34f675f
nextafter templates off one type
f15dc9e
mean_bound and sample_mean need referencing with this
2792f02
make uniform distribution usage compatible with boost 1.46
jeffdonahue ad40955
use boost variate_generator to pass tests w/ boost 1.46 (Gaussian filler
jeffdonahue 430475b
change all Rng's to use variate_generator for consistency
jeffdonahue b08a2d9
add bernoulli rng test to demonstrate bug (generates all 0s unless p ==
jeffdonahue 10d6822
fix bernoulli generator bug
jeffdonahue 33e7141
Replace atlas with multithreaded OpenBLAS to speed-up on multi-core CPU
kloudkl 7d34b6e
Merge branch 'boost-eigen' of github.com:rowlanddepp/caffe into boost…
9bba820
major refactoring allow coexistence of MKL and non-MKL cases
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// Copyright 2013 Rowland Depp | ||
|
||
#ifndef CAFFE_UTIL_MKL_ALTERNATE_H_ | ||
#define CAFFE_UTIL_MKL_ALTERNATE_H_ | ||
|
||
#ifdef USE_MKL | ||
|
||
#include <mkl.h> | ||
|
||
#else // If use MKL, simply include the MKL header | ||
|
||
#include <cblas.h> | ||
#include <math.h> | ||
|
||
// Functions that caffe uses but are not present if MKL is not linked. | ||
|
||
// A simple way to define the vsl unary functions. The operation should | ||
// be in the form e.g. y[i] = sqrt(a[i]) | ||
#define DEFINE_VSL_UNARY_FUNC(name, operation) \ | ||
template<typename Dtype> \ | ||
void v##name(const int n, const Dtype* a, Dtype* y) { \ | ||
CHECK_GT(n, 0); CHECK(a); CHECK(y); \ | ||
for (int i = 0; i < n; ++i) { operation; } \ | ||
} \ | ||
inline void vs##name( \ | ||
const int n, const float* a, float* y) { \ | ||
v##name<float>(n, a, y); \ | ||
} \ | ||
inline void vd##name( \ | ||
const int n, const double* a, double* y) { \ | ||
v##name<double>(n, a, y); \ | ||
} | ||
|
||
DEFINE_VSL_UNARY_FUNC(Sqr, y[i] = a[i] * a[i]); | ||
DEFINE_VSL_UNARY_FUNC(Exp, y[i] = exp(a[i])); | ||
|
||
// A simple way to define the vsl unary functions with singular parameter b. | ||
// The operation should be in the form e.g. y[i] = pow(a[i], b) | ||
#define DEFINE_VSL_UNARY_FUNC_WITH_PARAM(name, operation) \ | ||
template<typename Dtype> \ | ||
void v##name(const int n, const Dtype* a, const Dtype b, Dtype* y) { \ | ||
CHECK_GT(n, 0); CHECK(a); CHECK(y); \ | ||
for (int i = 0; i < n; ++i) { operation; } \ | ||
} \ | ||
inline void vs##name( \ | ||
const int n, const float* a, const float b, float* y) { \ | ||
v##name<float>(n, a, b, y); \ | ||
} \ | ||
inline void vd##name( \ | ||
const int n, const double* a, const float b, double* y) { \ | ||
v##name<double>(n, a, b, y); \ | ||
} | ||
|
||
DEFINE_VSL_UNARY_FUNC_WITH_PARAM(Powx, y[i] = pow(a[i], b)); | ||
|
||
// A simple way to define the vsl binary functions. The operation should | ||
// be in the form e.g. y[i] = a[i] + b[i] | ||
#define DEFINE_VSL_BINARY_FUNC(name, operation) \ | ||
template<typename Dtype> \ | ||
void v##name(const int n, const Dtype* a, const Dtype* b, Dtype* y) { \ | ||
CHECK_GT(n, 0); CHECK(a); CHECK(b); CHECK(y); \ | ||
for (int i = 0; i < n; ++i) { operation; } \ | ||
} \ | ||
inline void vs##name( \ | ||
const int n, const float* a, const float* b, float* y) { \ | ||
v##name<float>(n, a, b, y); \ | ||
} \ | ||
inline void vd##name( \ | ||
const int n, const double* a, const double* b, double* y) { \ | ||
v##name<double>(n, a, b, y); \ | ||
} | ||
|
||
DEFINE_VSL_BINARY_FUNC(Add, y[i] = a[i] + b[i]); | ||
DEFINE_VSL_BINARY_FUNC(Sub, y[i] = a[i] - b[i]); | ||
DEFINE_VSL_BINARY_FUNC(Mul, y[i] = a[i] * b[i]); | ||
DEFINE_VSL_BINARY_FUNC(Div, y[i] = a[i] / b[i]); | ||
|
||
// In addition, MKL comes with an additional function axpby that is not present | ||
// in standard blas. We will simply use a two-step (inefficient, of course) way | ||
// to mimic that. | ||
inline void cblas_saxpby(const int N, const float alpha, const float* X, | ||
const int incX, const float beta, float* Y, | ||
const int incY) { | ||
cblas_sscal(N, beta, Y, incY); | ||
cblas_saxpy(N, alpha, X, incX, Y, incY); | ||
} | ||
inline void cblas_daxpby(const int N, const double alpha, const double* X, | ||
const int incX, const double beta, double* Y, | ||
const int incY) { | ||
cblas_dscal(N, beta, Y, incY); | ||
cblas_daxpy(N, alpha, X, incX, Y, incY); | ||
} | ||
|
||
#endif // USE_MKL | ||
#endif // CAFFE_UTIL_MKL_ALTERNATE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
// Copyright 2013 Yangqing Jia | ||
|
||
|
||
#include <mkl.h> | ||
//#include <mkl.h> | ||
#include <cublas_v2.h> | ||
|
||
#include <vector> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could you check if the
ifdef USE_MKL
in Makefile will be false if USE_MKL=0 (I suspect not)? There might be a
hidden bug here by making the if statement ambiguous. Essentially
we should be checking the value of USE_MKL instead of checking whether it
is defined.
I am sure you are more familiar with Makefile jargons so please kindly fix
it :)
Yangqing
On Fri, Feb 14, 2014 at 1:19 PM, Evan Shelhamer notifications@github.comwrote:
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.
I shouldn't work on Caffe before I have my coffee :) I'll make sure it's right when I merge.