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

Clos Conv FDA error #161

Open
NeuralCoder3 opened this issue Dec 9, 2022 · 0 comments
Open

Clos Conv FDA error #161

NeuralCoder3 opened this issue Dec 9, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@NeuralCoder3
Copy link
Collaborator

NeuralCoder3 commented Dec 9, 2022

The FreeDefAna in ClosConv throws an error.
In Node::add_fvs, the def is tested to be no memory.
However, this is tested in a situation that shallowly seems correct:

.con f a::[m:%mem.M, ...] = {
  ... // defined g
  g (a#0, ...)
  //  ^ error occurs here
}
Reproduction

Branch: https://github.com/NeuralCoder3/thorin2/tree/ad_ptr_merge
Commit: 8a56cf0
File: lit/autodiff/imperativ/arr.thorin
Example call: ./build/bin/thorin -o - -VVVV -d autodiff -d direct -d affine lit/autodiff/imperativ/arr.thorin

Code before error:

.import affine;
.import autodiff;
.import clos;
.import compile;
.import core;
.import direct;
.import mem;
.import opt;
.import refly;
.con printInteger [%mem.M, .Idx 4294967296, .Cn %mem.M] @(<nullptr>) = {
     <unset>
};
.con .extern main __2788883::[%mem.M, .Idx 4294967296, %mem.Ptr (%mem.Ptr (.Idx 256, 0), 0), return_2788887: .Cn [%mem.M, .Idx 4294967296]] @(1:(.Idx 2)) = {
    .con print_integer_callback2_reshape_2788874 _2788913: %mem.M @(1:(.Idx 2)) = {
        .let _2788915: %mem.M = %mem.free («100; .Idx 4294967296», 0) (_2788913,:%mem.Ptr («100; .Idx 4294967296», 0));
        return_2788887 (_2788915, 0:(.Idx 4294967296))
    };
    .con print_integer_callback_reshape_2788818 _2788819: %mem.M @(1:(.Idx 2)) = {
        .let _2788798: %mem.Ptr (.Idx 4294967296, 0) = %mem.lea (100,100; .Idx 4294967296, 0) (:%mem.Ptr («100; .Idx 4294967296», 0), 0:(.Idx 100));
        .let _2788806: [%mem.M, .Idx 4294967296] = %mem.load (.Idx 4294967296, 0) (:%mem.M, _2788798);
        .let _2788855: %mem.Ptr (.Idx 4294967296, 0) = %mem.lea (100,100; .Idx 4294967296, 0) (:%mem.Ptr («100; .Idx 4294967296», 0), 1:(.Idx 100));
        .let _2788863: [%mem.M, .Idx 4294967296] = %mem.load (.Idx 4294967296, 0) (_2788806#0:(.Idx 2), _2788855);
        printInteger (_2788819, _2788863#1:(.Idx 2), %clos.attr.ret .Cn %mem.M print_integer_callback2_reshape_2788874)
    };
    .con init_callback_reshape_2788341 _2788374: %mem.M @(1:(.Idx 2)) = {
        printInteger (_2788374, _2788806#1:(.Idx 2), %clos.attr.ret .Cn %mem.M print_integer_callback_reshape_2788818)
    };
    .con for_reshape_2788328 _2788998::[_2789065: %mem.M, _2789000: .Idx 4294967296] @(1:(.Idx 2)) = {
        .con for_body_reshape_2788938 _2788954: %mem.M @(1:(.Idx 2)) = {
            .let _2788985: [%mem.M, %mem.Ptr («100; .Idx 4294967296», 0)] = %mem.alloc («100; .Idx 4294967296», 0) _2788863#0:(.Idx 2);
            .let _2789001: .Idx 100 = %core.bitcast (.Idx 100, .Idx 4294967296) _2789000;
            .let _2789009: %mem.Ptr (.Idx 4294967296, 0) = %mem.lea (100,100; .Idx 4294967296, 0) (_2788985#1:(.Idx 2), _2789001);
            .let _2789016: %mem.M = %mem.store (.Idx 4294967296, 0) (_2788954, _2789009, _2789000);
            .let _2789044: .Idx 4294967296 = %core.wrap.add 4294967296 0 (1:(.Idx 4294967296), _2789000);
            for_reshape_2788328 (_2789016, _2789044)
        };
        .let _2789062: .Idx 2 = %core.icmp.XygLe 4294967296 (_2789000, 100:(.Idx 4294967296));
        (init_callback_reshape_2788341, for_body_reshape_2788938)#_2789062 _2789065
    };
    for_reshape_2788328 (_2788985#0:(.Idx 2), 0:(.Idx 4294967296))
};

Error mesage:

E:dialects/clos/phase/clos_conv.h:49: memory def in free def analysis: _2788985#0:(.Idx 2) : %mem.M
E:dialects/clos/phase/clos_conv.h:50:   in nom main
thorin: dialects/clos/phase/clos_conv.h:52: auto thorin::clos::FreeDefAna::Node::add_fvs(const thorin::Def*): Assertion `!match<mem::M>(def->type())' failed.

Edit: There seem to be other problems (⊥:%mem.Ptr, ⊤:%mem.M) that were obscured by the printing.

@NeuralCoder3 NeuralCoder3 added the bug Something isn't working label Dec 9, 2022
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

1 participant