Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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

Crash on call to DType.sizeof() when also creating a TensorShape [BUG] #2194

Closed
JakeEBrooks opened this issue Apr 4, 2024 · 1 comment
Closed
Labels
bug Something isn't working mojo-repo Tag all issues with this label

Comments

@JakeEBrooks
Copy link

Bug description

Please forgive my ignorance... it's my first time submitting an issue on GitHub :)

Earlier today I found a weird crash that happens when TensorShape is called within a function that returns an object containing a DType. If I call sizeof on the DType field I get a compiler crash (see below).

Steps to reproduce

For me, running the following works fine:

struct SomeStruct:
    var datatype: DType

    fn __init__(inout self, datatype: DType):
        self.datatype = datatype

fn create_struct() -> SomeStruct:
    #var ax = TensorShape(0)
    var datatype = DType.uint32
    return SomeStruct(datatype)

fn main():
    var astruct = create_struct()
    print(astruct.datatype.sizeof())

But if I uncomment the TensorShape bit in create_struct, I get:

/__w/modular/modular/Kernels/mojo/stdlib/builtin/dtype.mojo:430:44: error: failed to legalize operation 'pop.dtype.sizeof' that was explicitly marked illegal
/__w/modular/modular/Kernels/mojo/stdlib/builtin/dtype.mojo:430:44: note: see current operation: %61 = "pop.dtype.sizeof"(%60) : (!kgen.dtype) -> index
mojo: error: Failed to materialize symbols: { (exec, { KGEN_EE_JIT_GlobalConstructor, KGEN_EE_JIT_GlobalDestructor, main }) } (from the layer: failed to lower module to LLVM IR for archive compilation)

Interestingly, I noticed if you just provide an empty TensorShape it works. For example, the following works fine for me:

struct SomeStruct:
    var datatype: DType

    fn __init__(inout self, datatype: DType):
        self.datatype = datatype

fn create_struct() -> SomeStruct:
    var ax = TensorShape()
    var datatype = DType.uint32
    return SomeStruct(datatype)

fn main():
    var astruct = create_struct()
    print(astruct.datatype.sizeof())

Hope I'm not missing anything, and that this is helpful!

System information

- What OS did you do install Mojo on ?
Ubuntu 23.10
- Provide version information for Mojo by pasting the output of `mojo -v`
mojo 24.2.0 (c2427bc5)
- Provide Modular CLI version by pasting the output of `modular -v`
modular 0.6.0 (04c05243)
@JakeEBrooks JakeEBrooks added bug Something isn't working mojo Issues that are related to mojo labels Apr 4, 2024
@ematejska ematejska added the mojo-lang Tag for all issues related to language. label Apr 4, 2024
@linear linear bot removed mojo-lang Tag for all issues related to language. mojo Issues that are related to mojo labels Apr 29, 2024
@ematejska ematejska added the mojo-repo Tag all issues with this label label Apr 29, 2024
@JakeEBrooks
Copy link
Author

Reported fixed in #2983.

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