Skip to content

Commit

Permalink
[skip ci] enforce code format
Browse files Browse the repository at this point in the history
  • Loading branch information
taichi-gardener committed Jul 10, 2020
1 parent a42adb9 commit c5adefe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion python/taichi/lang/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def subscript(value, *indices):
if is_taichi_class(value):
return value.subscript(*indices)
else:
if isinstance(indices, tuple) and len(indices) == 1 and indices[0] is None:
if isinstance(indices,
tuple) and len(indices) == 1 and indices[0] is None:
indices = []
indices_expr_group = make_expr_group(*indices)
tensor_dim = int(value.ptr.get_attribute("dim"))
Expand Down
9 changes: 6 additions & 3 deletions taichi/transforms/type_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,12 @@ class TypeCheck : public IRVisitor {
}
for (int i = 0; i < stmt->indices.size(); i++) {
if (!is_integral(stmt->indices[i]->ret_type.data_type)) {
TI_WARN("[{}] Tensor accessed with non-integral indices (e.g., "
"i32/i64), casting into i32 by default...", stmt->name());
stmt->indices[i] = insert_type_cast_before(stmt, stmt->indices[i], DataType::i32);
TI_WARN(
"[{}] Tensor accessed with non-integral indices (e.g., "
"i32/i64), casting into i32 by default...",
stmt->name());
stmt->indices[i] =
insert_type_cast_before(stmt, stmt->indices[i], DataType::i32);
}
TI_ASSERT(stmt->indices[i]->ret_type.width == stmt->snodes.size());
}
Expand Down
3 changes: 1 addition & 2 deletions tests/python/test_indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def test_indices():
# the virtual first index exposed to the user comes second in memory layout.



@ti.host_arch_only
def test_float_as_index():
a = ti.var(ti.f32, (8, 5))
Expand All @@ -37,5 +36,5 @@ def func():

func()

assert a[6, 3] == 233
assert a[6, 3] == 233
assert a[3, 4] == 666

0 comments on commit c5adefe

Please sign in to comment.