You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue: taichi-dev#5819
### Brief Summary
We no longer need the switch after taichi-dev#6801.
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
# with real_matrix=True, "data" is expected to be an Expr here
659
-
# Therefore we simply call "impl.expr_init_func(data)" to perform:
660
-
#
661
-
# TensorType* t = alloca()
662
-
# assign(t, data)
663
-
#
664
-
# We created local variable "t" - a copy of the passed-in argument "data"
665
-
ifnotisinstance(
666
-
data,
667
-
expr.Expr) ornotdata.ptr.is_tensor():
668
-
raiseTaichiSyntaxError(
669
-
f"Argument {arg.arg} of type {ctx.func.arguments[i].annotation} is expected to be a Matrix, but got {type(data)}."
670
-
)
671
-
672
-
element_shape=data.ptr.get_ret_type().shape()
673
-
iflen(element_shape
674
-
) !=ctx.func.arguments[i].annotation.ndim:
675
-
raiseTaichiSyntaxError(
676
-
f"Argument {arg.arg} of type {ctx.func.arguments[i].annotation} is expected to be a Matrix with ndim {ctx.func.arguments[i].annotation.ndim}, but got {len(element_shape)}."
677
-
)
678
-
679
-
assertctx.func.arguments[i].annotation.ndim>0
680
-
ifelement_shape[0] !=ctx.func.arguments[
681
-
i].annotation.n:
682
-
raiseTaichiSyntaxError(
683
-
f"Argument {arg.arg} of type {ctx.func.arguments[i].annotation} is expected to be a Matrix with n {ctx.func.arguments[i].annotation.n}, but got {element_shape[0]}."
684
-
)
685
-
686
-
ifctx.func.arguments[
687
-
i].annotation.ndim==2andelement_shape[
688
-
1] !=ctx.func.arguments[
689
-
i].annotation.m:
690
-
raiseTaichiSyntaxError(
691
-
f"Argument {arg.arg} of type {ctx.func.arguments[i].annotation} is expected to be a Matrix with m {ctx.func.arguments[i].annotation.m}, but got {element_shape[0]}."
692
-
)
693
-
else:
694
-
ifnotisinstance(data, Matrix):
695
-
raiseTaichiSyntaxError(
696
-
f"Argument {arg.arg} of type {ctx.func.arguments[i].annotation} is expected to be a Matrix, but got {type(data)}."
697
-
)
698
-
699
-
ifdata.m!=ctx.func.arguments[i].annotation.m:
700
-
raiseTaichiSyntaxError(
701
-
f"Argument {arg.arg} of type {ctx.func.arguments[i].annotation} is expected to be a Matrix with m {ctx.func.arguments[i].annotation.m}, but got {data.m}."
702
-
)
703
-
704
-
ifdata.n!=ctx.func.arguments[i].annotation.n:
705
-
raiseTaichiSyntaxError(
706
-
f"Argument {arg.arg} of type {ctx.func.arguments[i].annotation} is expected to be a Matrix with n {ctx.func.arguments[i].annotation.n}, but got {data.n}."
707
-
)
653
+
# "data" is expected to be an Expr here,
654
+
# so we simply call "impl.expr_init_func(data)" to perform:
655
+
#
656
+
# TensorType* t = alloca()
657
+
# assign(t, data)
658
+
#
659
+
# We created local variable "t" - a copy of the passed-in argument "data"
660
+
ifnotisinstance(
661
+
data, expr.Expr) ornotdata.ptr.is_tensor():
662
+
raiseTaichiSyntaxError(
663
+
f"Argument {arg.arg} of type {ctx.func.arguments[i].annotation} is expected to be a Matrix, but got {type(data)}."
664
+
)
665
+
666
+
element_shape=data.ptr.get_ret_type().shape()
667
+
iflen(element_shape
668
+
) !=ctx.func.arguments[i].annotation.ndim:
669
+
raiseTaichiSyntaxError(
670
+
f"Argument {arg.arg} of type {ctx.func.arguments[i].annotation} is expected to be a Matrix with ndim {ctx.func.arguments[i].annotation.ndim}, but got {len(element_shape)}."
671
+
)
672
+
673
+
assertctx.func.arguments[i].annotation.ndim>0
674
+
ifelement_shape[0] !=ctx.func.arguments[
675
+
i].annotation.n:
676
+
raiseTaichiSyntaxError(
677
+
f"Argument {arg.arg} of type {ctx.func.arguments[i].annotation} is expected to be a Matrix with n {ctx.func.arguments[i].annotation.n}, but got {element_shape[0]}."
678
+
)
679
+
680
+
ifctx.func.arguments[
681
+
i].annotation.ndim==2andelement_shape[
682
+
1] !=ctx.func.arguments[i].annotation.m:
683
+
raiseTaichiSyntaxError(
684
+
f"Argument {arg.arg} of type {ctx.func.arguments[i].annotation} is expected to be a Matrix with m {ctx.func.arguments[i].annotation.m}, but got {element_shape[0]}."
0 commit comments