Skip to content
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] Shorten traceback for _BoundedDifferentiableMethod #6475

Merged
merged 1 commit into from
Oct 31, 2022

Conversation

lin-hitonami
Copy link
Contributor

@lin-hitonami lin-hitonami commented 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'

@netlify
Copy link

netlify bot commented Oct 31, 2022

Deploy Preview for docsite-preview ready!

Name Link
🔨 Latest commit a96df4d
🔍 Latest deploy log https://app.netlify.com/sites/docsite-preview/deploys/635f4a58a7e9e7000999832b
😎 Deploy Preview https://deploy-preview-6475--docsite-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@ailzhang
Copy link
Contributor

/rebase

lin-hitonami added a commit that referenced this pull request Oct 31, 2022
…not supported (#6477)

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'
```
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>
Copy link
Contributor

@ailzhang ailzhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ailzhang ailzhang merged commit 618c0f1 into taichi-dev:master Oct 31, 2022
@lin-hitonami lin-hitonami deleted the shorten branch October 31, 2022 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants