Skip to content

Commit c513682

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 8699512 commit c513682

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

python/taichi/lang/ast/ast_transformer.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
from taichi.lang.ast.symbol_resolver import ASTResolver
1515
from taichi.lang.exception import TaichiSyntaxError, TaichiTypeError
1616
from taichi.lang.field import Field
17-
from taichi.lang.matrix import (Matrix, MatrixType, _PyScopeMatrixImpl,
18-
_TiScopeMatrixImpl, Vector)
17+
from taichi.lang.matrix import (Matrix, MatrixType, Vector, _PyScopeMatrixImpl,
18+
_TiScopeMatrixImpl)
1919
from taichi.lang.snode import append
2020
from taichi.lang.util import in_taichi_scope, is_taichi_class, to_taichi_type
2121
from taichi.types import (annotations, ndarray_type, primitive_types,
@@ -488,7 +488,8 @@ def build_Call(ctx, node):
488488
node.ptr = impl.ti_format(*args, **keywords)
489489
return node.ptr
490490

491-
if isinstance(node.func, ast.Attribute) and func == Matrix or func == Vector:
491+
if isinstance(node.func,
492+
ast.Attribute) and func == Matrix or func == Vector:
492493
node.ptr = matrix.make_matrix(*args, **keywords)
493494
return node.ptr
494495

python/taichi/lang/matrix.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,14 @@ def make_matrix(arr, dt=None, suppress_warning=False, is_ref=False, **kwargs):
103103
cast = (lambda x: ops_mod.cast(x, dt)) if dt else (
104104
lambda x: x if isinstance(x, expr.Expr) else expr.Expr(x))
105105
if len(arr) == 0:
106-
return impl.expr_init(impl.expr_init_matrix([0], dt, []))
106+
return impl.expr_init(impl.expr_init_matrix([0], dt, []))
107107
if not isinstance(arr[0], Iterable):
108-
return impl.expr_init(impl.expr_init_matrix([len(arr)], dt,
109-
[cast(elt).ptr for elt in arr]))
110-
return impl.expr_init(impl.expr_init_matrix([len(arr), len(arr[0])], dt,
111-
[cast(elt).ptr for row in arr for elt in row]))
108+
return impl.expr_init(
109+
impl.expr_init_matrix([len(arr)], dt,
110+
[cast(elt).ptr for elt in arr]))
111+
return impl.expr_init(
112+
impl.expr_init_matrix([len(arr), len(arr[0])], dt,
113+
[cast(elt).ptr for row in arr for elt in row]))
112114

113115

114116
class _MatrixBaseImpl:

taichi/codegen/llvm/codegen_llvm.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -1484,8 +1484,7 @@ void TaskCodeGenLLVM::visit(GlobalStoreStmt *stmt) {
14841484
TI_NOT_IMPLEMENTED;
14851485
}
14861486
} else {
1487-
TI_TRACE("Store {} to {}", stmt->val->name(),
1488-
stmt->dest->name());
1487+
TI_TRACE("Store {} to {}", stmt->val->name(), stmt->dest->name());
14891488
llvm_val[stmt->val]->dump();
14901489
llvm_val[stmt->dest]->dump();
14911490
builder->CreateStore(llvm_val[stmt->val], llvm_val[stmt->dest]);

taichi/ir/statements.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,11 @@ class PtrOffsetStmt : public Stmt {
367367

368368
bool is_local_ptr() const {
369369
if (origin->is<AllocaStmt>() || origin->is<GlobalTemporaryStmt>()) {
370-
auto is_tensor_type = origin->ret_type->is<PointerType>() ?
371-
origin->ret_type->cast<PointerType>()->get_pointee_type()->is<TensorType>() :
372-
origin->ret_type->is<TensorType>();
370+
auto is_tensor_type = origin->ret_type->is<PointerType>()
371+
? origin->ret_type->cast<PointerType>()
372+
->get_pointee_type()
373+
->is<TensorType>()
374+
: origin->ret_type->is<TensorType>();
373375
TI_ASSERT_INFO(is_tensor_type,
374376
"PtrOffsetStmt can only be used for Alloca (TensorType).");
375377
}

0 commit comments

Comments
 (0)