crystal-data / num.cr

Scientific computing in pure Crystal
MIT License
151 stars 12 forks source link

Tensor#matmul Error: undefined method 'buffer' for Tensor(Float32) #31

Closed jtanderson closed 4 years ago

jtanderson commented 4 years ago

This code, taken partially from the readme:

a = [[1, 2], [3, 4]].to_tensor.astype(Float32)
b = [[3, 4], [5, 6]].to_tensor.astype(Float32)

puts a.matmul(b)

Throws Error: undefined method 'buffer' for Tensor(Float32) after expanding the blas macro.

Edit: From some quick testing, it looks like a swap of .storage instead of .buffer in tensor/linalg#matmul will fix this. Putting together a PR but let me know if this isn't the right way to fix

christopherzimmerman commented 4 years ago

@jtanderson I think to_unsafe should be used intstead of buffer in all cases now. Looks like I stopped 90% of the way through the file unfortunately.

christopherzimmerman commented 4 years ago

This is fixed on master. You will probably need to clear your shard.lock. I am working on a stable 0.4.0 release right now, and after that I'll start versioning/tagging appropriately.

jtanderson commented 4 years ago

Great!