|
|
@ -60,16 +60,6 @@ void matmul<platform::CPUPlace, float>(const framework::Tensor& in1, bool in1_T,
|
|
|
|
in1_dim.size() == 2 && in2_dim.size() == 2 && out_dim.size() == 2,
|
|
|
|
in1_dim.size() == 2 && in2_dim.size() == 2 && out_dim.size() == 2,
|
|
|
|
"The input and output of matmul be matrix");
|
|
|
|
"The input and output of matmul be matrix");
|
|
|
|
|
|
|
|
|
|
|
|
if (!in1_T && !in2_T) {
|
|
|
|
|
|
|
|
PADDLE_ENFORCE(in1_dim[1] == in2_dim[0]);
|
|
|
|
|
|
|
|
} else if (in1_T && !in2_T) {
|
|
|
|
|
|
|
|
PADDLE_ENFORCE(in1_dim[0] == in2_dim[0]);
|
|
|
|
|
|
|
|
} else if (!in1_T && in2_T) {
|
|
|
|
|
|
|
|
PADDLE_ENFORCE(in1_dim[1] == in2_dim[0]);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
PADDLE_ENFORCE(in1_dim[0] == in2_dim[1]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PADDLE_ENFORCE(platform::is_cpu_place(in1.place()) &&
|
|
|
|
PADDLE_ENFORCE(platform::is_cpu_place(in1.place()) &&
|
|
|
|
platform::is_cpu_place(in2.place()) &&
|
|
|
|
platform::is_cpu_place(in2.place()) &&
|
|
|
|
platform::is_cpu_place(out->place()),
|
|
|
|
platform::is_cpu_place(out->place()),
|
|
|
@ -77,7 +67,7 @@ void matmul<platform::CPUPlace, float>(const framework::Tensor& in1, bool in1_T,
|
|
|
|
|
|
|
|
|
|
|
|
int M = out_dim[0];
|
|
|
|
int M = out_dim[0];
|
|
|
|
int N = out_dim[1];
|
|
|
|
int N = out_dim[1];
|
|
|
|
int K = in1_dim[1];
|
|
|
|
int K = (in1_T == false) ? in1_dim[1] : in1_dim[0];
|
|
|
|
|
|
|
|
|
|
|
|
CBLAS_TRANSPOSE in1_Trans = (in1_T == false) ? CblasNoTrans : CblasTrans;
|
|
|
|
CBLAS_TRANSPOSE in1_Trans = (in1_T == false) ? CblasNoTrans : CblasTrans;
|
|
|
|
CBLAS_TRANSPOSE in2_Trans = (in2_T == false) ? CblasNoTrans : CblasTrans;
|
|
|
|
CBLAS_TRANSPOSE in2_Trans = (in2_T == false) ? CblasNoTrans : CblasTrans;
|
|
|
@ -100,16 +90,6 @@ void matmul<platform::CPUPlace, double>(const framework::Tensor& in1,
|
|
|
|
PADDLE_ENFORCE(
|
|
|
|
PADDLE_ENFORCE(
|
|
|
|
in1_dim.size() == 2 && in2_dim.size() == 2 && out_dim.size() == 2,
|
|
|
|
in1_dim.size() == 2 && in2_dim.size() == 2 && out_dim.size() == 2,
|
|
|
|
"The input and output of matmul be matrix");
|
|
|
|
"The input and output of matmul be matrix");
|
|
|
|
if (!in1_T && !in2_T) {
|
|
|
|
|
|
|
|
PADDLE_ENFORCE(in1_dim[1] == in2_dim[0]);
|
|
|
|
|
|
|
|
} else if (in1_T && !in2_T) {
|
|
|
|
|
|
|
|
PADDLE_ENFORCE(in1_dim[0] == in2_dim[0]);
|
|
|
|
|
|
|
|
} else if (!in1_T && in2_T) {
|
|
|
|
|
|
|
|
PADDLE_ENFORCE(in1_dim[1] == in2_dim[0]);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
PADDLE_ENFORCE(in1_dim[0] == in2_dim[1]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PADDLE_ENFORCE(platform::is_cpu_place(in1.place()) &&
|
|
|
|
PADDLE_ENFORCE(platform::is_cpu_place(in1.place()) &&
|
|
|
|
platform::is_cpu_place(in2.place()) &&
|
|
|
|
platform::is_cpu_place(in2.place()) &&
|
|
|
|
platform::is_cpu_place(out->place()),
|
|
|
|
platform::is_cpu_place(out->place()),
|
|
|
@ -117,7 +97,7 @@ void matmul<platform::CPUPlace, double>(const framework::Tensor& in1,
|
|
|
|
|
|
|
|
|
|
|
|
int M = out_dim[0];
|
|
|
|
int M = out_dim[0];
|
|
|
|
int N = out_dim[1];
|
|
|
|
int N = out_dim[1];
|
|
|
|
int K = in1_dim[1];
|
|
|
|
int K = (in1_T == false) ? in1_dim[1] : in1_dim[0];
|
|
|
|
CBLAS_TRANSPOSE in1_Trans = (in1_T == false) ? CblasNoTrans : CblasTrans;
|
|
|
|
CBLAS_TRANSPOSE in1_Trans = (in1_T == false) ? CblasNoTrans : CblasTrans;
|
|
|
|
CBLAS_TRANSPOSE in2_Trans = (in2_T == false) ? CblasNoTrans : CblasTrans;
|
|
|
|
CBLAS_TRANSPOSE in2_Trans = (in2_T == false) ? CblasNoTrans : CblasTrans;
|
|
|
|
|
|
|
|
|
|
|
|