"git@developer.sourcefind.cn:OpenDAS/ollama.git" did not exist on "d8def1ff9432ef60d1067e5e6dde0d700dd95021"
python_binding.cc 1.01 KB
Newer Older
Hongzhi (Steve), Chen's avatar
Hongzhi (Steve), Chen committed
1
/**
2
3
 *  Copyright (c) 2022 by Contributors
 * @file python_binding.cc
czkkkkkk's avatar
czkkkkkk committed
4
 * @brief DGL sparse library Python binding.
5
 */
czkkkkkk's avatar
czkkkkkk committed
6
7
8
9
// clang-format off
#include <sparse/dgl_headers.h>
// clang-format on

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <sparse/elementwise_op.h>
#include <sparse/sparse_matrix.h>
#include <torch/custom_class.h>
#include <torch/script.h>

namespace dgl {
namespace sparse {

TORCH_LIBRARY(dgl_sparse, m) {
  m.class_<SparseMatrix>("SparseMatrix")
      .def("val", &SparseMatrix::value)
      .def("nnz", &SparseMatrix::nnz)
      .def("device", &SparseMatrix::device)
      .def("shape", &SparseMatrix::shape)
      .def("coo", &SparseMatrix::COOTensors)
      .def("csr", &SparseMatrix::CSRTensors)
26
      .def("csc", &SparseMatrix::CSCTensors)
27
      .def("transpose", &SparseMatrix::Transpose);
28
29
30
  m.def("create_from_coo", &CreateFromCOO)
      .def("create_from_csr", &CreateFromCSR)
      .def("create_from_csc", &CreateFromCSC)
31
      .def("spsp_add", &SpSpAdd)
32
      .def("val_like", &CreateValLike);
33
34
35
36
}

}  // namespace sparse
}  // namespace dgl