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

Outer product between vectors not work #6067

Closed
BillXu2000 opened this issue Sep 15, 2022 · 2 comments · Fixed by #6076
Closed

Outer product between vectors not work #6067

BillXu2000 opened this issue Sep 15, 2022 · 2 comments · Fixed by #6076
Labels
potential bug Something that looks like a bug but not yet confirmed

Comments

@BillXu2000
Copy link
Collaborator

Describe the bug
Matrix multiplication between n1 and 1n vector will cause compilation error.

To Reproduce

import taichi as ti
ti.init()

@ti.kernel
def fun():
    a = ti.Vector([0.0, 0.0])
    print(a @ a.transpose())

fun()

Log/Screenshots

{15:04}~/playground:dev ✗ ➭ p test_ra.py
[Taichi] version 1.1.3, llvm 10.0.0, commit 9a35e049, linux, python 3.8.5
[Taichi] Starting on arch=x64
Traceback (most recent call last):
  File "test_ra.py", line 9, in <module>
    fun()
  File "/home/bx2k/git/taichi/python/taichi/lang/kernel_impl.py", line 917, in wrapped
    raise type(e)('\n' + str(e)) from None
taichi.lang.exception.TaichiCompilationError: 
File "test_ra.py", line 7, in fun:
    print(a @ a.transpose())
          ^^^^^^^^^^^^^^^^^
Traceback (most recent call last):
  File "/home/bx2k/git/taichi/python/taichi/lang/ast/ast_transformer_utils.py", line 25, in __call__
    return method(ctx, node)
  File "/home/bx2k/git/taichi/python/taichi/lang/ast/ast_transformer.py", line 738, in build_BinOp
    node.ptr = op(node.left.ptr, node.right.ptr)
  File "/home/bx2k/git/taichi/python/taichi/lang/ast/ast_transformer.py", line 736, in <lambda>
    ast.MatMult: lambda l, r: l @ r,
  File "/home/bx2k/git/taichi/python/taichi/lang/matrix.py", line 564, in __matmul__
    return other.transpose() @ self
  File "/home/bx2k/git/taichi/python/taichi/lang/matrix.py", line 566, in __matmul__
    assert self.m == other.n, f"Dimension mismatch between shapes ({self.n}, {self.m}), ({other.n}, {other.m})"
AssertionError: Dimension mismatch between shapes (2, 1), (2, 1)

Additional comments
This bug seems to be related to PR #6014 .

@BillXu2000 BillXu2000 added the potential bug Something that looks like a bug but not yet confirmed label Sep 15, 2022
@taichi-gardener taichi-gardener moved this to Untriaged in Taichi Lang Sep 15, 2022
@strongoier
Copy link
Contributor

cc: @AD1024

@AD1024
Copy link
Contributor

AD1024 commented Sep 15, 2022

Thanks! Just working on a PR

Repository owner moved this from Untriaged to Done in Taichi Lang Sep 16, 2022
strongoier pushed a commit that referenced this issue Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
potential bug Something that looks like a bug but not yet confirmed
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants