@@ -786,95 +786,95 @@ py_quadblas_get_version(PyObject *self, PyObject *args)
786
786
return PyUnicode_FromString (QuadBLAS::VERSION);
787
787
}
788
788
789
- void matmul_op (Sleef_quad * inp1, Sleef_quad *inp2, Sleef_quad *out)
790
- {
791
- Sleef_quad *data_a, *data_b;
792
- QuadBackendType backend_a, backend_b;
793
- QuadBLAS::Layout layout_a, layout_b;
794
-
795
- if (!extract_quad_array_info (a, &data_a, &backend_a, &layout_a) ||
796
- !extract_quad_array_info (b, &data_b, &backend_b, &layout_b)) {
797
- return nullptr ;
798
- }
799
-
800
- Sleef_quad *temp_a = nullptr , *temp_b = nullptr ;
801
- Sleef_quad *sleef_a = ensure_sleef_backend (a, backend_a, &temp_a);
802
- Sleef_quad *sleef_b = ensure_sleef_backend (b, backend_b, &temp_b);
803
-
804
- if (!sleef_a || !sleef_b) {
805
- QuadBLAS::aligned_free (temp_a);
806
- QuadBLAS::aligned_free (temp_b);
807
- return nullptr ;
808
- }
809
-
810
- QuadBackendType result_backend = BACKEND_SLEEF;
811
- if (backend_a == BACKEND_LONGDOUBLE && backend_b == BACKEND_LONGDOUBLE) {
812
- result_backend = BACKEND_LONGDOUBLE;
813
- }
814
-
815
- npy_intp result_dims[2 ] = {m, n};
816
- QuadPrecDTypeObject *result_dtype = new_quaddtype_instance (result_backend);
817
- if (!result_dtype) {
818
- QuadBLAS::aligned_free (temp_a);
819
- QuadBLAS::aligned_free (temp_b);
820
- return nullptr ;
821
- }
822
-
823
- PyArrayObject *result =
824
- (PyArrayObject *)PyArray_Empty (2 , result_dims, (PyArray_Descr *)result_dtype, 0 );
825
- if (!result) {
826
- QuadBLAS::aligned_free (temp_a);
827
- QuadBLAS::aligned_free (temp_b);
828
- Py_DECREF (result_dtype);
829
- return nullptr ;
830
- }
831
-
832
- Sleef_quad *result_data = (Sleef_quad *)PyArray_DATA (result);
833
- for (npy_intp i = 0 ; i < m * n; i++) {
834
- result_data[i] = Sleef_cast_from_doubleq1 (0.0 );
835
- }
836
-
837
- npy_intp lda, ldb, ldc;
838
-
839
- if (layout_a == QuadBLAS::Layout::RowMajor) {
840
- lda = k;
841
- }
842
- else {
843
- lda = m;
844
- }
845
-
846
- if (layout_b == QuadBLAS::Layout::RowMajor) {
847
- ldb = n;
848
- }
849
- else {
850
- ldb = k;
851
- }
852
-
853
- QuadBLAS::Layout result_layout = layout_a;
854
- if (result_layout == QuadBLAS::Layout::RowMajor) {
855
- ldc = n;
856
- }
857
- else {
858
- ldc = m;
859
- }
860
-
861
- Sleef_quad alpha = Sleef_cast_from_doubleq1 (1.0 );
862
- Sleef_quad beta = Sleef_cast_from_doubleq1 (0.0 );
863
-
864
- QuadBLAS::gemm (result_layout, m, n, k, alpha, sleef_a, lda, sleef_b, ldb, beta, result_data,
865
- ldc);
866
-
867
- if (result_backend == BACKEND_LONGDOUBLE) {
868
- long double *ld_result = (long double *)PyArray_DATA (result);
869
- for (npy_intp i = 0 ; i < m * n; i++) {
870
- ld_result[i] = (long double )Sleef_cast_to_doubleq1 (result_data[i]);
871
- }
872
- }
873
-
874
- QuadBLAS::aligned_free (temp_a);
875
- QuadBLAS::aligned_free (temp_b);
876
-
877
- return (PyObject *)result;
878
- }
789
+ // void matmul_op(Sleef_quad * inp1, Sleef_quad *inp2, Sleef_quad *out)
790
+ // {
791
+ // Sleef_quad *data_a, *data_b;
792
+ // QuadBackendType backend_a, backend_b;
793
+ // QuadBLAS::Layout layout_a, layout_b;
794
+
795
+ // if (!extract_quad_array_info(a, &data_a, &backend_a, &layout_a) ||
796
+ // !extract_quad_array_info(b, &data_b, &backend_b, &layout_b)) {
797
+ // return nullptr;
798
+ // }
799
+
800
+ // Sleef_quad *temp_a = nullptr, *temp_b = nullptr;
801
+ // Sleef_quad *sleef_a = ensure_sleef_backend(a, backend_a, &temp_a);
802
+ // Sleef_quad *sleef_b = ensure_sleef_backend(b, backend_b, &temp_b);
803
+
804
+ // if (!sleef_a || !sleef_b) {
805
+ // QuadBLAS::aligned_free(temp_a);
806
+ // QuadBLAS::aligned_free(temp_b);
807
+ // return nullptr;
808
+ // }
809
+
810
+ // QuadBackendType result_backend = BACKEND_SLEEF;
811
+ // if (backend_a == BACKEND_LONGDOUBLE && backend_b == BACKEND_LONGDOUBLE) {
812
+ // result_backend = BACKEND_LONGDOUBLE;
813
+ // }
814
+
815
+ // npy_intp result_dims[2] = {m, n};
816
+ // QuadPrecDTypeObject *result_dtype = new_quaddtype_instance(result_backend);
817
+ // if (!result_dtype) {
818
+ // QuadBLAS::aligned_free(temp_a);
819
+ // QuadBLAS::aligned_free(temp_b);
820
+ // return nullptr;
821
+ // }
822
+
823
+ // PyArrayObject *result =
824
+ // (PyArrayObject *)PyArray_Empty(2, result_dims, (PyArray_Descr *)result_dtype, 0);
825
+ // if (!result) {
826
+ // QuadBLAS::aligned_free(temp_a);
827
+ // QuadBLAS::aligned_free(temp_b);
828
+ // Py_DECREF(result_dtype);
829
+ // return nullptr;
830
+ // }
831
+
832
+ // Sleef_quad *result_data = (Sleef_quad *)PyArray_DATA(result);
833
+ // for (npy_intp i = 0; i < m * n; i++) {
834
+ // result_data[i] = Sleef_cast_from_doubleq1(0.0);
835
+ // }
836
+
837
+ // npy_intp lda, ldb, ldc;
838
+
839
+ // if (layout_a == QuadBLAS::Layout::RowMajor) {
840
+ // lda = k;
841
+ // }
842
+ // else {
843
+ // lda = m;
844
+ // }
845
+
846
+ // if (layout_b == QuadBLAS::Layout::RowMajor) {
847
+ // ldb = n;
848
+ // }
849
+ // else {
850
+ // ldb = k;
851
+ // }
852
+
853
+ // QuadBLAS::Layout result_layout = layout_a;
854
+ // if (result_layout == QuadBLAS::Layout::RowMajor) {
855
+ // ldc = n;
856
+ // }
857
+ // else {
858
+ // ldc = m;
859
+ // }
860
+
861
+ // Sleef_quad alpha = Sleef_cast_from_doubleq1(1.0);
862
+ // Sleef_quad beta = Sleef_cast_from_doubleq1(0.0);
863
+
864
+ // QuadBLAS::gemm(result_layout, m, n, k, alpha, sleef_a, lda, sleef_b, ldb, beta, result_data,
865
+ // ldc);
866
+
867
+ // if (result_backend == BACKEND_LONGDOUBLE) {
868
+ // long double *ld_result = (long double *)PyArray_DATA(result);
869
+ // for (npy_intp i = 0; i < m * n; i++) {
870
+ // ld_result[i] = (long double)Sleef_cast_to_doubleq1(result_data[i]);
871
+ // }
872
+ // }
873
+
874
+ // QuadBLAS::aligned_free(temp_a);
875
+ // QuadBLAS::aligned_free(temp_b);
876
+
877
+ // return (PyObject *)result;
878
+ // }
879
879
880
880
#endif // DISABLE_QUADBLAS
0 commit comments