|
| 1 | +//***************************************************************************** |
| 2 | +// Copyright (c) 2023, Intel Corporation |
| 3 | +// All rights reserved. |
| 4 | +// |
| 5 | +// Redistribution and use in source and binary forms, with or without |
| 6 | +// modification, are permitted provided that the following conditions are met: |
| 7 | +// - Redistributions of source code must retain the above copyright notice, |
| 8 | +// this list of conditions and the following disclaimer. |
| 9 | +// - Redistributions in binary form must reproduce the above copyright notice, |
| 10 | +// this list of conditions and the following disclaimer in the documentation |
| 11 | +// and/or other materials provided with the distribution. |
| 12 | +// |
| 13 | +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 14 | +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 | +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 16 | +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 17 | +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 18 | +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 19 | +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 20 | +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 21 | +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 22 | +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 23 | +// THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | +//***************************************************************************** |
| 25 | +// |
| 26 | +// This file defines functions of dpnp.backend._lapack_impl extensions |
| 27 | +// |
| 28 | +//***************************************************************************** |
| 29 | + |
| 30 | +#include <pybind11/pybind11.h> |
| 31 | +#include <pybind11/stl.h> |
| 32 | + |
| 33 | +#include "gemm.hpp" |
| 34 | + |
| 35 | +namespace blas_ext = dpnp::backend::ext::blas; |
| 36 | +namespace py = pybind11; |
| 37 | + |
| 38 | +// populate dispatch tables |
| 39 | +void init_dispatch_tables(void) |
| 40 | +{ |
| 41 | + blas_ext::init_gemm_batch_dispatch_table(); |
| 42 | + blas_ext::init_gemm_dispatch_table(); |
| 43 | +} |
| 44 | + |
| 45 | +PYBIND11_MODULE(_blas_impl, m) |
| 46 | +{ |
| 47 | + init_dispatch_tables(); |
| 48 | + |
| 49 | + { |
| 50 | + m.def("_gemm", &blas_ext::gemm, |
| 51 | + "Call `gemm` from OneMKL LAPACK library to return " |
| 52 | + "the matrix-matrix product with 2-D matrices.", |
| 53 | + py::arg("sycl_queue"), py::arg("matrixA"), py::arg("matrixB"), |
| 54 | + py::arg("result"), py::arg("depends") = py::list()); |
| 55 | + } |
| 56 | + |
| 57 | + { |
| 58 | + m.def("_gemm_batch", &blas_ext::gemm_batch, |
| 59 | + "Call `gemm_batch` from OneMKL LAPACK library to return " |
| 60 | + "the matrix-matrix product with general matrices.", |
| 61 | + py::arg("sycl_queue"), py::arg("matrixA"), py::arg("matrixB"), |
| 62 | + py::arg("result"), py::arg("m"), py::arg("n"), py::arg("k"), |
| 63 | + py::arg("batch_size"), py::arg("ld_array_1"), |
| 64 | + py::arg("ld_array_2"), py::arg("ld_result"), py::arg("stridea"), |
| 65 | + py::arg("strideb"), py::arg("stridec"), py::arg("transA_int"), |
| 66 | + py::arg("transB_int"), py::arg("depends") = py::list()); |
| 67 | + } |
| 68 | +} |
0 commit comments