 
 THC_API void THCTensor_(getri)(THCState *state, THCTensor *ra_, THCTensor *a)
 {
-#ifdef USE_MAGMA
   THArgCheck(a->nDimension == 2, 2, "A should be 2 dimensional");
   THArgCheck(a->size[0] == a->size[1], 2, "A should be square");
 
+#ifdef USE_MAGMA
   int info;
   int n = a->size[0];
   int lwork = n * magma_get_sgetri_nb(n);


  // Inverse
#if defined(THC_REAL_IS_FLOAT)
  THCudaBlas_Sgetri(state, n, d_matrices1_const, n, ipiv_gpu, d_matrices2, n, info_gpu, 1);
#else
  THCudaBlas_Dgetri(state, n, d_matrices1_const, n, ipiv_gpu, d_matrices2, n, info_gpu, 1);
#endif

  if (info > 0)
    THError("CUBLAS getri : U(%d,%d) is 0, U is singular", info, info);

  magma_free_pinned(ipiv);
  THCTensor_(freeCopyTo)(state, input, ra_);
#else
  int n = a->size[0];

  // input
  THCTensor *input = THCTensor_(newColumnMajor)(state, a, a);
  THCTensor_(resizeNd)(state, ra_, 2, input->size, input->stride);

  real *matrices1[1] = { THCTensor_(data)(state, input) };
  real *matrices2[1] = { THCTensor_(data)(state, ra_) };

  // Copy pointers to device.
  real **d_matrices1, **d_matrices2;
  THCudaCheck(THCudaMalloc(state, (void**)&d_matrices1, sizeof(real*)));
  THCudaCheck(THCudaMalloc(state, (void**)&d_matrices2, sizeof(real*)));

  THCudaCheck(cudaMemcpyAsync(d_matrices1, matrices1, sizeof(real*),
                              cudaMemcpyHostToDevice, THCState_getCurrentStream(state)));
  THCudaCheck(cudaMemcpyAsync(d_matrices2, matrices2, sizeof(real*),
                              cudaMemcpyHostToDevice, THCState_getCurrentStream(state)));
  int info;
  int *info_gpu;
