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

Invalid broadcasting #12

Closed
alwc opened this issue Jul 21, 2020 · 1 comment
Closed

Invalid broadcasting #12

alwc opened this issue Jul 21, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@alwc
Copy link

alwc commented Jul 21, 2020

Hi @jjjkkkjjj

I'm trying to do the following broadcasting, but it is considered as error in Matft:

let a = Matft.arange(start: 1, to: 7, by: 1, shape: [3, 2])
let b = Matft.arange(start: 1, to: 5, by: 1, shape: [2, 1, 2])
print(a - b)

Error message:

Fatal error: could not broadcast from shape 3, [2, 1, 2] into shape 3, [1, 3, 2]: file /Users/alwc/Library/Developer/Xcode/DerivedData/testnpy-afxfserzcwmbfdfgfaszjulxzrwa/SourcePackages/checkouts/Matft/Sources/Matft/core/function/conversion.swift, line 290

2020-07-21 19:05:02.261713+0800 testnpy[21523:5245927] Fatal error: could not broadcast from shape 3, [2, 1, 2] into shape 3, [1, 3, 2]: file /Users/alwc/Library/Developer/Xcode/DerivedData/testnpy-afxfserzcwmbfdfgfaszjulxzrwa/SourcePackages/checkouts/Matft/Sources/Matft/core/function/conversion.swift, line 290

In Python this is legal. For example,

x = np.random.randint(10, size=(3, 2))
y = np.random.randint(10, size=(2, 1, 2))

# Returns a shape (2, 3, 2) nd-array
print(x - y)      
jjjkkkjjj pushed a commit that referenced this issue Jul 21, 2020
@jjjkkkjjj
Copy link
Owner

@alwc
Good catch!
I misunderstood broadcasting rule...
I'll modify this bug ASAP, please wait for a moment!

@jjjkkkjjj jjjkkkjjj added the bug Something isn't working label Jul 21, 2020
jjjkkkjjj pushed a commit that referenced this issue Jul 22, 2020
jjjkkkjjj pushed a commit that referenced this issue Jul 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants