We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
It looks like it is only possible to reshape a tensor immediately following it's definition.
The following works as expected, when inlining all statements one after another:
from tensor import Tensor, TensorShape def main(): var a = Tensor[DType.float64](2, 1.0) var a_expanded_shape = TensorShape(1, 2) var a_reshaped = a.reshape(a_expanded_shape)
If the reshape is, however, placed inside a different function than the code no longer compiles:
from tensor import Tensor, TensorShape fn my_reshape(a: Tensor[DType.float64]): var a_expanded_shape = TensorShape(1, 2) var a_reshaped = a.reshape(a_expanded_shape) def main(): var a = Tensor[DType.float64](2, 1.0) my_reshape(a)
Which gives the compilation error:
error: invalid call to 'reshape': invalid use of mutating method on rvalue of type 'Tensor[float64]' var a_reshaped = a.reshape(a_expanded_shape)
Am I missing something obvious?
Reading the Tensor.reshape docs, I am expecting a.reshape to return a copy. So no mutations on the function's argument a, right?
a.reshape
a
Thanks in advance,
Hylke
- Ubuntu 24.04 - `mojo --version`: mojo 2024.8.2805 (fd3bceba) - `modular -v`: modular 0.9.2 (b3079bd5)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Bug description
It looks like it is only possible to reshape a tensor immediately following it's definition.
Steps to reproduce
The following works as expected, when inlining all statements one after another:
If the reshape is, however, placed inside a different function than the code no longer compiles:
Which gives the compilation error:
Am I missing something obvious?
Reading the Tensor.reshape docs, I am expecting
a.reshape
to return a copy. So no mutations on the function's argumenta
, right?Thanks in advance,
Hylke
System information
The text was updated successfully, but these errors were encountered: