Skip to content

Commit

Permalink
finalize
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanke98 committed Sep 21, 2022
1 parent f632d06 commit 5ac0a52
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 34 deletions.
44 changes: 22 additions & 22 deletions misc/sparse_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,32 +45,32 @@ def fill(A: ti.types.sparse_matrix_builder(),
B = A + A
print(B)

# print(">>>> Summation: B += A")
# B += A
# print(B)
print(">>>> Summation: B += A")
B += A
print(B)

# print(">>>> Subtraction: C = B - A")
# C = B - A
# print(C)
print(">>>> Subtraction: C = B - A")
C = B - A
print(C)

# print(">>>> Subtraction: C -= A")
# C -= A
# print(C)
print(">>>> Subtraction: C -= A")
C -= A
print(C)

# print(">>>> Multiplication with a scalar on the right: D = A * 3.0")
# D = A * 3.0
# print(D)
print(">>>> Multiplication with a scalar on the right: D = A * 3.0")
D = A * 3.0
print(D)

# print(">>>> Multiplication with a scalar on the left: D = 3.0 * A")
# D = 3.0 * A
# print(D)
print(">>>> Multiplication with a scalar on the left: D = 3.0 * A")
D = 3.0 * A
print(D)

# print(">>>> Transpose: E = D.transpose()")
# E = D.transpose()
# print(E)
print(">>>> Transpose: E = D.transpose()")
E = D.transpose()
print(E)

# print(">>>> Matrix multiplication: F= E @ A")
# F = E @ A
# print(F)
print(">>>> Matrix multiplication: F= E @ A")
F = E @ A
print(F)

# print(f">>>> Element Access: F[0,0] = {F[0,0]}")
print(f">>>> Element Access: F[0,0] = {F[0,0]}")
2 changes: 1 addition & 1 deletion misc/test_gpu_sm_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
data_rvs=rvs).astype(np_dtype)
S2 = random(rows, cols, density=0.5, random_state=rng,
data_rvs=rvs).astype(np_dtype)
# S2 = S2.T

nnz_A = len(S1.data)
nnz_B = len(S2.data)

Expand Down
1 change: 0 additions & 1 deletion python/taichi/linalg/sparse_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ def print_triplets(self):
def build(self, dtype=f32, _format='CSR'):
"""Create a sparse matrix using the triplets"""
sm = self.ptr.build()
print(type(sm))
return SparseMatrix(sm=sm)


Expand Down
1 change: 0 additions & 1 deletion taichi/program/sparse_matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ void CuSparseMatrix::build_csr_from_coo(void *coo_row_ptr,
CUDADriver::get_instance().mem_free(d_values_sorted);
CUDADriver::get_instance().mem_free(d_permutation);
CUDADriver::get_instance().mem_free(dbuffer);

#endif
}

Expand Down
7 changes: 3 additions & 4 deletions taichi/program/sparse_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,8 @@ class EigenSparseMatrix : public SparseMatrix {
: SparseMatrix(em.rows(), em.cols()), matrix_(em) {
}

~EigenSparseMatrix() {
TI_INFO("Destroy eigen sparse matrix.");
};
~EigenSparseMatrix() override = default;

void build_triplets(void *triplets_adr) override;
const std::string to_string() const override;

Expand Down Expand Up @@ -225,6 +224,7 @@ class CuSparseMatrix : public SparseMatrix {

virtual ~CuSparseMatrix();

// TODO: Overload +=, -= and *=
friend std::unique_ptr<SparseMatrix> operator+(const CuSparseMatrix &lhs,
const CuSparseMatrix &rhs) {
auto m = lhs.addition(rhs, 1.0, 1.0);
Expand All @@ -236,7 +236,6 @@ class CuSparseMatrix : public SparseMatrix {
return lhs.addition(rhs, 1.0, -1.0);
};

// TODO: Overload *=
friend std::unique_ptr<SparseMatrix> operator*(const CuSparseMatrix &sm,
float scale) {
return sm.addition(sm, scale, 0.0);
Expand Down
5 changes: 0 additions & 5 deletions taichi/python/export_lang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1154,11 +1154,6 @@ void export_lang(py::module &m) {
.def("build", &BitStructTypeBuilder::build,
py::return_value_policy::reference);

m.def("decl_tensor_type",
[&](std::vector<int> shape, const DataType &element_type) {
return TypeFactory::create_tensor_type(shape, element_type);
});

py::class_<SNodeRegistry>(m, "SNodeRegistry")
.def(py::init<>())
.def("create_root", &SNodeRegistry::create_root,
Expand Down

0 comments on commit 5ac0a52

Please sign in to comment.