biometrics / likely

A compiler intermediate representation for image recognition and heterogeneous computing.
http://www.liblikely.org
Other
78 stars 11 forks source link

Array Allocation issue #56

Closed JordanCheney closed 9 years ago

JordanCheney commented 9 years ago

@jklontz I'm on my way to a minimum reproducing example of the array allocation issue and I'm running into a different issue-

array := ($ 0.f32XY 2)
(array 0) :<- (f32XY 1 2 2 1)
(array 1) :<- (f32XY 1 2 1 1)
array

This is throwing an error-

Assertion failed: (!(x.type & ~likely_element) && !(type & ~likely_element)), function cast, file /code/likely/src/backend.cpp, line 993.

Abort trap: 6

I'm sure this is related to a syntax error but I'm not sure what it is. Any insights?

jklontz commented 9 years ago

I think the issue is that you're trying to modify a global variable. Try it in a local scope:

{
  array := ($ 0.f32XY 2)
  (array 0) :<- (f32XY 1 2 2 1)
  (array 1) :<- (f32XY 1 2 1 1)
  array
}
JordanCheney commented 9 years ago

Ok here is an example that has a few issues-

init :=
    (mat-1 mat-2) :->
    {
        mat-1.(set 0.01)
        ; mat-2.set-zero ; Uncomment this for different results!
    }

allocate :=
    () :->
    {
        array := ($ 0.f32XY 2)
        (array 0) :<- (f32XY 1 2 2 1)
        (array 1) :<- (f32XY 1 2 2 1)
        array
    }

mre :=
    (i) :->
    {
        array-1 := (allocate)
        array-2 := (allocate)

        (init (array-1 0) (array-2 0))

        (? (< i 2) (array-1 i) (array-2 (% i 2)))
    }

Array 1 results

(mre 0)
(mre 1)

Array 2 results

(mre 2)
(mre 3)

So on the initial run array-2 is set to 0.01 even though it shouldn't be set to anything. If you uncomment the line in init you can see that everything is set to 0.

jklontz commented 9 years ago

Well I've been able to reduce it down to:

{
  a := 0.f32XY.$
  a :<- (f32XY 1 2 2 1)

  b := 0.f32XY.$
  b :<- (f32XY 1 2 2 1)

  a.(set 1)
  b.(set 0) ; Uncomment this for different results!

  a
}