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

[BUG] Tensor metadata not updated when calling astype() #2592

Closed
fnands opened this issue May 8, 2024 · 1 comment
Closed

[BUG] Tensor metadata not updated when calling astype() #2592

fnands opened this issue May 8, 2024 · 1 comment
Labels
bug Something isn't working mojo-repo Tag all issues with this label

Comments

@fnands
Copy link

fnands commented May 8, 2024

Bug description

Hey, I have run into something odd with Tensors.

The tensor astype() method: https://docs.modular.com/mojo/stdlib/tensor/tensor/Tensor#astype

Says:

Copy the Tensor with elements cast to the new type.

However when I do this the metadata of the tensor seems to still be that of the old tensor type.

The values in the tensor themselves are fine, but when looking at the bytecount and tensorspec are called the new tensor seems to think it is still the old tensor.

Steps to reproduce

Minimal example:

from tensor import Tensor, rand

var tensor_uint8 = rand[DType.uint8](3, 3)
print("8 bit tensor byte count: ", tensor_uint8.bytecount())
var tensor_float32 = tensor_uint8.astype[DType.float32]()
print("32 bit tensor byte count: ", tensor_float32.bytecount())

print("")
print("8 bit tensor spec: ", tensor_uint8.spec())
print("32 bit tensor spec: ", tensor_float32.spec())

Yeilds:

8 bit tensor byte count:  9
32 bit tensor byte count:  9

8 bit tensor spec:  3x3xuint8
32 bit tensor spec:  3x3xuint8

System information

  • What OS did you do install Mojo on ?
    Ubuntu 22.04.4 LTS
  • Provide version information for Mojo by pasting the output of mojo -v
    mojo 24.3.0 (9882e19d)
  • Provide Modular CLI version by pasting the output of modular -v
    modular 0.7.2 (d0adc668)
@fnands fnands added bug Something isn't working mojo-repo Tag all issues with this label labels May 8, 2024
Copy link
Collaborator

This is fixed in a recent nightly ~1 week ago

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mojo-repo Tag all issues with this label
Projects
None yet
Development

No branches or pull requests

2 participants