Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bug] Fix SparseMatrix's dtype; check for dtype in SparseSolver. (#8071)
Issue: #8045 ### Brief Summary `SparseMatrix`'s dtype should be determined by the dtype of the `SparseMatrixBuilder` from which it's built. However, it's fixed to `f32` in the current code base. This PR fix this by passing `self.dtype` instead of `dtype` to `SparseMatrix()` in the builder: ```python def build(self, dtype=f32, _format="CSR"): """Create a sparse matrix using the triplets""" taichi_arch = get_runtime().prog.config().arch if taichi_arch in [_ti_core.Arch.x64, _ti_core.Arch.arm64]: sm = self.ptr.build() return SparseMatrix(sm=sm, dtype=self.dtype) # Previously it was dtype, which is f32 in the current context. ``` Also, `SparseSolver` should raise an exception to better notify the user if the `dtype` of the `SparseMatrix` is not consistent with the solver's `dtype`. This is implemented in the `sparse_solver.py`. ### Additional comments - This PR should resolve the user's question posted on the forum: https://forum.taichi-lang.cn/t/topic/4316 - This PR might fix part of the CI test failures mentioned in issue #8045 , but #8045 still needs more thorough investigation even with this PR merged to ensure that there is no future issues. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information