-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[Error] Return TaichiTypeError in ASTTransformer when a binary op is not supported #6477
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
✅ Deploy Preview for docsite-preview ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
This was referenced Oct 31, 2022
ailzhang
approved these changes
Oct 31, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! nit: please add a test ;)
/rebase |
taichi-gardener
force-pushed
the
typeerror
branch
from
October 31, 2022 04:45
4faec0c
to
e07baa8
Compare
I'll add a test after one of #6474 and this PR is merged. |
lin-hitonami
added a commit
that referenced
this pull request
Oct 31, 2022
…atrix/Struct (#6474) Issue: #6472 ### Brief Summary Traceback of #6472 before #6474, #6475 and #6477: ``` Traceback (most recent call last): File "/home/lin/test/ant.py", line 21, in <module> myclass.do_something() File "/home/lin/taichi/python/taichi/lang/kernel_impl.py", line 1022, in __call__ return self._primal(self._kernel_owner, *args, **kwargs) File "/home/lin/taichi/python/taichi/lang/kernel_impl.py", line 888, in __call__ key = self.ensure_compiled(*args) File "/home/lin/taichi/python/taichi/lang/kernel_impl.py", line 855, in ensure_compiled self.materialize(key=key, args=args, arg_features=arg_features) File "/home/lin/taichi/python/taichi/lang/kernel_impl.py", line 566, in materialize taichi_kernel = impl.get_runtime().prog.create_kernel( File "/home/lin/taichi/python/taichi/lang/kernel_impl.py", line 556, in taichi_ast_generator transform_tree(tree, ctx) File "/home/lin/taichi/python/taichi/lang/ast/transform.py", line 6, in transform_tree ASTTransformer()(ctx, tree) File "/home/lin/taichi/python/taichi/lang/ast/ast_transformer_utils.py", line 28, in __call__ raise e.with_traceback(None) taichi.lang.exception.TaichiCompilationError: File "/home/lin/test/ant.py", line 16, in do_something: NEE_contrib = brdf * self.light_weight * self.light_color[None] ^^^^^^^^^^^^^^^^^^^^^^^^ Traceback (most recent call last): File "/home/lin/taichi/python/taichi/lang/ast/ast_transformer_utils.py", line 25, in __call__ return method(ctx, node) File "/home/lin/taichi/python/taichi/lang/ast/ast_transformer.py", line 800, in build_BinOp node.ptr = op(node.left.ptr, node.right.ptr) File "/home/lin/taichi/python/taichi/lang/ast/ast_transformer.py", line 788, in <lambda> ast.Mult: lambda l, r: l * r, File "/home/lin/taichi/python/taichi/lang/common_ops.py", line 47, in __mul__ return ops.mul(self, other) File "/home/lin/taichi/python/taichi/lang/ops.py", line 55, in wrapped return a._element_wise_binary(imp_foo, b) File "/home/lin/taichi/python/taichi/lang/matrix.py", line 491, in _element_wise_binary other = self._broadcast_copy(other) File "/home/lin/taichi/python/taichi/lang/matrix.py", line 507, in _broadcast_copy other = Vector([other for _ in range(self.n)]) File "/home/lin/taichi/python/taichi/lang/matrix.py", line 1465, in __init__ super().__init__(arr, dt=dt, **kwargs) File "/home/lin/taichi/python/taichi/lang/matrix.py", line 433, in __init__ flattened += row File "/home/lin/taichi/python/taichi/lang/field.py", line 264, in __iter__ raise NotImplementedError( NotImplementedError: Struct for is only available in Taichi scope. ``` Traceback after #6474: ``` Traceback (most recent call last): File "/home/lin/test/ant.py", line 21, in <module> myclass.do_something() File "/home/lin/taichi/python/taichi/lang/kernel_impl.py", line 1022, in __call__ return self._primal(self._kernel_owner, *args, **kwargs) File "/home/lin/taichi/python/taichi/lang/kernel_impl.py", line 888, in __call__ key = self.ensure_compiled(*args) File "/home/lin/taichi/python/taichi/lang/kernel_impl.py", line 855, in ensure_compiled self.materialize(key=key, args=args, arg_features=arg_features) File "/home/lin/taichi/python/taichi/lang/kernel_impl.py", line 566, in materialize taichi_kernel = impl.get_runtime().prog.create_kernel( File "/home/lin/taichi/python/taichi/lang/kernel_impl.py", line 556, in taichi_ast_generator transform_tree(tree, ctx) File "/home/lin/taichi/python/taichi/lang/ast/transform.py", line 6, in transform_tree ASTTransformer()(ctx, tree) File "/home/lin/taichi/python/taichi/lang/ast/ast_transformer_utils.py", line 28, in __call__ raise e.with_traceback(None) taichi.lang.exception.TaichiCompilationError: File "/home/lin/test/ant.py", line 16, in do_something: NEE_contrib = brdf * self.light_weight * self.light_color[None] ^^^^^^^^^^^^^^^^^^^^^^^^ Traceback (most recent call last): File "/home/lin/taichi/python/taichi/lang/ast/ast_transformer_utils.py", line 25, in __call__ return method(ctx, node) File "/home/lin/taichi/python/taichi/lang/ast/ast_transformer.py", line 800, in build_BinOp node.ptr = op(node.left.ptr, node.right.ptr) File "/home/lin/taichi/python/taichi/lang/ast/ast_transformer.py", line 788, in <lambda> ast.Mult: lambda l, r: l * r, TypeError: unsupported operand type(s) for *: 'Vector' and 'ScalarField' ``` Traceback after #6474 and #6475: ``` Traceback (most recent call last): File "/home/lin/test/ant.py", line 21, in <module> myclass.do_something() File "/home/lin/taichi/python/taichi/lang/kernel_impl.py", line 1025, in __call__ raise type(e)('\n' + str(e)) from None taichi.lang.exception.TaichiCompilationError: File "/home/lin/test/ant.py", line 16, in do_something: NEE_contrib = brdf * self.light_weight * self.light_color[None] ^^^^^^^^^^^^^^^^^^^^^^^^ Traceback (most recent call last): File "/home/lin/taichi/python/taichi/lang/ast/ast_transformer_utils.py", line 25, in __call__ return method(ctx, node) File "/home/lin/taichi/python/taichi/lang/ast/ast_transformer.py", line 800, in build_BinOp node.ptr = op(node.left.ptr, node.right.ptr) File "/home/lin/taichi/python/taichi/lang/ast/ast_transformer.py", line 788, in <lambda> ast.Mult: lambda l, r: l * r, TypeError: unsupported operand type(s) for *: 'Vector' and 'ScalarField' ``` Traceback after #6474, #6475 and #6477: ``` Traceback (most recent call last): File "/home/lin/test/ant.py", line 21, in <module> myclass.do_something() File "/home/lin/taichi/python/taichi/lang/kernel_impl.py", line 1025, in __call__ raise type(e)('\n' + str(e)) from None taichi.lang.exception.TaichiTypeError: File "/home/lin/test/ant.py", line 16, in do_something: NEE_contrib = brdf * self.light_weight * self.light_color[None] ^^^^^^^^^^^^^^^^^^^^^^^^ unsupported operand type(s) for *: 'Vector' and 'ScalarField' ``` Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
ailzhang
pushed a commit
that referenced
this pull request
Oct 31, 2022
Issue: #6472 ### Brief Summary Traceback of #6472 before #6474, #6475 and #6477: ``` Traceback (most recent call last): File "/home/lin/test/ant.py", line 21, in <module> myclass.do_something() File "/home/lin/taichi/python/taichi/lang/kernel_impl.py", line 1022, in __call__ return self._primal(self._kernel_owner, *args, **kwargs) File "/home/lin/taichi/python/taichi/lang/kernel_impl.py", line 888, in __call__ key = self.ensure_compiled(*args) File "/home/lin/taichi/python/taichi/lang/kernel_impl.py", line 855, in ensure_compiled self.materialize(key=key, args=args, arg_features=arg_features) File "/home/lin/taichi/python/taichi/lang/kernel_impl.py", line 566, in materialize taichi_kernel = impl.get_runtime().prog.create_kernel( File "/home/lin/taichi/python/taichi/lang/kernel_impl.py", line 556, in taichi_ast_generator transform_tree(tree, ctx) File "/home/lin/taichi/python/taichi/lang/ast/transform.py", line 6, in transform_tree ASTTransformer()(ctx, tree) File "/home/lin/taichi/python/taichi/lang/ast/ast_transformer_utils.py", line 28, in __call__ raise e.with_traceback(None) taichi.lang.exception.TaichiCompilationError: File "/home/lin/test/ant.py", line 16, in do_something: NEE_contrib = brdf * self.light_weight * self.light_color[None] ^^^^^^^^^^^^^^^^^^^^^^^^ Traceback (most recent call last): File "/home/lin/taichi/python/taichi/lang/ast/ast_transformer_utils.py", line 25, in __call__ return method(ctx, node) File "/home/lin/taichi/python/taichi/lang/ast/ast_transformer.py", line 800, in build_BinOp node.ptr = op(node.left.ptr, node.right.ptr) File "/home/lin/taichi/python/taichi/lang/ast/ast_transformer.py", line 788, in <lambda> ast.Mult: lambda l, r: l * r, File "/home/lin/taichi/python/taichi/lang/common_ops.py", line 47, in __mul__ return ops.mul(self, other) File "/home/lin/taichi/python/taichi/lang/ops.py", line 55, in wrapped return a._element_wise_binary(imp_foo, b) File "/home/lin/taichi/python/taichi/lang/matrix.py", line 491, in _element_wise_binary other = self._broadcast_copy(other) File "/home/lin/taichi/python/taichi/lang/matrix.py", line 507, in _broadcast_copy other = Vector([other for _ in range(self.n)]) File "/home/lin/taichi/python/taichi/lang/matrix.py", line 1465, in __init__ super().__init__(arr, dt=dt, **kwargs) File "/home/lin/taichi/python/taichi/lang/matrix.py", line 433, in __init__ flattened += row File "/home/lin/taichi/python/taichi/lang/field.py", line 264, in __iter__ raise NotImplementedError( NotImplementedError: Struct for is only available in Taichi scope. ``` Traceback after #6474: ``` Traceback (most recent call last): File "/home/lin/test/ant.py", line 21, in <module> myclass.do_something() File "/home/lin/taichi/python/taichi/lang/kernel_impl.py", line 1022, in __call__ return self._primal(self._kernel_owner, *args, **kwargs) File "/home/lin/taichi/python/taichi/lang/kernel_impl.py", line 888, in __call__ key = self.ensure_compiled(*args) File "/home/lin/taichi/python/taichi/lang/kernel_impl.py", line 855, in ensure_compiled self.materialize(key=key, args=args, arg_features=arg_features) File "/home/lin/taichi/python/taichi/lang/kernel_impl.py", line 566, in materialize taichi_kernel = impl.get_runtime().prog.create_kernel( File "/home/lin/taichi/python/taichi/lang/kernel_impl.py", line 556, in taichi_ast_generator transform_tree(tree, ctx) File "/home/lin/taichi/python/taichi/lang/ast/transform.py", line 6, in transform_tree ASTTransformer()(ctx, tree) File "/home/lin/taichi/python/taichi/lang/ast/ast_transformer_utils.py", line 28, in __call__ raise e.with_traceback(None) taichi.lang.exception.TaichiCompilationError: File "/home/lin/test/ant.py", line 16, in do_something: NEE_contrib = brdf * self.light_weight * self.light_color[None] ^^^^^^^^^^^^^^^^^^^^^^^^ Traceback (most recent call last): File "/home/lin/taichi/python/taichi/lang/ast/ast_transformer_utils.py", line 25, in __call__ return method(ctx, node) File "/home/lin/taichi/python/taichi/lang/ast/ast_transformer.py", line 800, in build_BinOp node.ptr = op(node.left.ptr, node.right.ptr) File "/home/lin/taichi/python/taichi/lang/ast/ast_transformer.py", line 788, in <lambda> ast.Mult: lambda l, r: l * r, TypeError: unsupported operand type(s) for *: 'Vector' and 'ScalarField' ``` Traceback after #6474 and #6475: ``` Traceback (most recent call last): File "/home/lin/test/ant.py", line 21, in <module> myclass.do_something() File "/home/lin/taichi/python/taichi/lang/kernel_impl.py", line 1025, in __call__ raise type(e)('\n' + str(e)) from None taichi.lang.exception.TaichiCompilationError: File "/home/lin/test/ant.py", line 16, in do_something: NEE_contrib = brdf * self.light_weight * self.light_color[None] ^^^^^^^^^^^^^^^^^^^^^^^^ Traceback (most recent call last): File "/home/lin/taichi/python/taichi/lang/ast/ast_transformer_utils.py", line 25, in __call__ return method(ctx, node) File "/home/lin/taichi/python/taichi/lang/ast/ast_transformer.py", line 800, in build_BinOp node.ptr = op(node.left.ptr, node.right.ptr) File "/home/lin/taichi/python/taichi/lang/ast/ast_transformer.py", line 788, in <lambda> ast.Mult: lambda l, r: l * r, TypeError: unsupported operand type(s) for *: 'Vector' and 'ScalarField' ``` Traceback after #6474, #6475 and #6477: ``` Traceback (most recent call last): File "/home/lin/test/ant.py", line 21, in <module> myclass.do_something() File "/home/lin/taichi/python/taichi/lang/kernel_impl.py", line 1025, in __call__ raise type(e)('\n' + str(e)) from None taichi.lang.exception.TaichiTypeError: File "/home/lin/test/ant.py", line 16, in do_something: NEE_contrib = brdf * self.light_weight * self.light_color[None] ^^^^^^^^^^^^^^^^^^^^^^^^ unsupported operand type(s) for *: 'Vector' and 'ScalarField' ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue: #6472
Brief Summary
Traceback of #6472 before #6474, #6475 and #6477:
Traceback after #6474:
Traceback after #6474 and #6475:
Traceback after #6474, #6475 and #6477: