From 5f1081d83d2d699ad8519d55174cf9e2f1861a3c Mon Sep 17 00:00:00 2001 From: qijun Date: Thu, 10 Aug 2017 08:54:05 +0000 Subject: [PATCH] fix bug in dynload --- paddle/operators/math/CMakeLists.txt | 2 +- paddle/operators/math/math_function_test.cc | 11 +++++++---- paddle/platform/dynload/cublas.h | 12 ++++++------ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/paddle/operators/math/CMakeLists.txt b/paddle/operators/math/CMakeLists.txt index bae11905b78..b1d0bc8f875 100644 --- a/paddle/operators/math/CMakeLists.txt +++ b/paddle/operators/math/CMakeLists.txt @@ -13,4 +13,4 @@ else() endif() -nv_test(math_function_test SRCS math_function_test.cc DEPS math_function) +nv_test(math_function_test SRCS math_function_test.cc DEPS math_function tensor) diff --git a/paddle/operators/math/math_function_test.cc b/paddle/operators/math/math_function_test.cc index f7b453a20c0..d0f0acab917 100644 --- a/paddle/operators/math/math_function_test.cc +++ b/paddle/operators/math/math_function_test.cc @@ -12,16 +12,19 @@ TEST(math_function, GPU) { auto* cpu_place = new paddle::platform::CPUPlace(); float* input1_ptr = input1.mutable_data({2, 2}, *cpu_place); float arr[4] = {0, 1, 2, 3}; + memcpy(input1_ptr, arr, 4 * sizeof(int)); auto* gpu_place = new paddle::platform::GPUPlace(0); - paddle::platform::DeviceContext* context = new CUDADeviceContext(gpu_place); + paddle::platform::DeviceContext* context = + new paddle::platform::CUDADeviceContext(*gpu_place); input1_gpu.CopyFrom(input1, *gpu_place); input2_gpu.CopyFrom(input1, *gpu_place); out_gpu.CopyFrom(input1, *gpu_place); - matmul(input1_gpu, false, input2_gpu, - false, 1, &out_gpu, 0, context); + paddle::operators::math::matmul( + input1_gpu, false, input2_gpu, + false, 1, &out_gpu, 0, context); out.CopyFrom(out_gpu, *cpu_place); @@ -31,4 +34,4 @@ TEST(math_function, GPU) { EXPECT_EQ(out_ptr[2], 6); EXPECT_EQ(out_ptr[3], 11); } -#endif \ No newline at end of file +#endif diff --git a/paddle/platform/dynload/cublas.h b/paddle/platform/dynload/cublas.h index c44b7240a88..617866d17c0 100644 --- a/paddle/platform/dynload/cublas.h +++ b/paddle/platform/dynload/cublas.h @@ -62,12 +62,12 @@ extern void *cublas_dso_handle; DECLARE_DYNAMIC_LOAD_CUBLAS_WRAP(__name) #define CUBLAS_BLAS_ROUTINE_EACH(__macro) \ - __macro(cublasSgemv); \ - __macro(cublasDgemv); \ - __macro(cublasSgemm); \ - __macro(cublasDgemm); \ - __macro(cublasSgeam); \ - __macro(cublasDgeam); \ + __macro(cublasSgemv_v2); \ + __macro(cublasDgemv_v2); \ + __macro(cublasSgemm_v2); \ + __macro(cublasDgemm_v2); \ + __macro(cublasSgeam_v2); \ + __macro(cublasDgeam_v2); \ __macro(cublasCreate_v2); \ __macro(cublasDestroy_v2); \ __macro(cublasSetStream_v2); \ -- GitLab