Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lang] Move sparse matrix/solver into subfolder #3115

Merged
merged 5 commits into from
Oct 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions python/taichi/lang/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@
from taichi.lang.ops import *
from taichi.lang.quant_impl import quant
from taichi.lang.runtime_ops import async_flush, sync
from taichi.lang.sparse_matrix import SparseMatrix, SparseMatrixBuilder
from taichi.lang.sparse_solver import SparseSolver
from taichi.lang.struct import Struct
from taichi.lang.type_factory_impl import type_factory
from taichi.lang.util import (has_pytorch, is_taichi_class, python_scope,
taichi_scope, to_numpy_type, to_pytorch_type,
to_taichi_type)
from taichi.linalg import SparseMatrix, SparseMatrixBuilder, SparseSolver
from taichi.misc.util import deprecated
from taichi.profiler import KernelProfiler, get_default_kernel_profiler
from taichi.snode.fields_builder import FieldsBuilder
Expand Down
2 changes: 1 addition & 1 deletion python/taichi/lang/kernel_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from taichi.lang.any_array import AnyArray
from taichi.lang.enums import Layout
from taichi.lang.expr import Expr
from taichi.lang.sparse_matrix import SparseMatrixBuilder
from taichi.lang.util import cook_dtype
from taichi.linalg import SparseMatrixBuilder
from taichi.type.primitive_types import u64


Expand Down
2 changes: 2 additions & 0 deletions python/taichi/linalg/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from taichi.linalg.sparse_matrix import SparseMatrix, SparseMatrixBuilder
from taichi.linalg.sparse_solver import SparseSolver
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import numpy as np
from taichi.core.util import ti_core as _ti_core
from taichi.lang import Field
from taichi.lang.impl import get_runtime
from taichi.lang.sparse_matrix import SparseMatrix
from taichi.linalg import SparseMatrix


class SparseSolver:
def __init__(self, solver_type="LLT", ordering="AMD"):
from taichi.lang.impl import get_runtime
solver_type_list = ["LLT", "LDLT", "LU"]
solver_ordering = ['AMD', 'COLAMD']
if solver_type in solver_type_list and ordering in solver_ordering:
Expand Down Expand Up @@ -39,6 +38,7 @@ def factorize(self, sparse_matrix):
self.type_assert(sparse_matrix)

def solve(self, b):
from taichi.lang import Field
if isinstance(b, Field):
return self.solver.solve(b.to_numpy())
elif isinstance(b, np.ndarray):
Expand Down