(c-lisp
(define ((mat-cons void) (arr (ptr float)) (len int))
(declare (n int))
(for((set n 0) (lt n len)) (set i (add n 1))
(store (ptradd arr n) n )
)
(ret)
)
(define ((fprint float) (n float) ))
(define ((matmul_print void) (arr (ptr float)) (len int))
(declare (i int))
(for ((set i 0) (lt i len) (set i (add i 1)))
(call fprint (load (ptradd arr i)))
)
(ret)
)
;x is 10 , xout and w is 100 . d is 10 . n is 10
(define ((mat_mul void) (xout (ptr float)) (x (ptr float)) (w (ptr float)) (n int) (d int))
(declare (i int))
(for ( (set i 2) (lt i d) (set i (add i 1)) )
(declare (val float))
(set val 0.0)
(declare (j int))
(for ((set j 0) (lt j n) (set j (add j 1)))
(set val (fadd val (fmul (load (ptradd w (add (mul i n) j))) (load (ptradd x j)))))
)
(store (ptradd xout i) val)
)
(ret)
)
(define ((main void))
(declare (xout (ptr float)))
(declare (x (ptr float)))
(declare (w (ptr float)))
(declare (n int ))
(declare (d int))
(set xout (alloc float 100))
(set x (alloc float 10))
(set w (alloc float 100))
(set n 10)
(set d 10)
(call mat-cons w 100)
(call mat-cons x 10)
(call mat_mul xout x w n d)
(call matmul_print xout 100)
(call fprint xout)
(ret)
)
)
output received.
Error in statement: ['for', [['set', 'n', 0], ['lt', 'n', 'len']], ['set', 'i', ['add', 'n', 1]], ['store', ['ptradd', 'arr', 'n'], 'n']]
Traceback (most recent call last):
File "/home/aadithya.bhat/c_lisp/bril/bril-txt/llama.lisp/src/backend/tests/llama2.c/../../c-lisp.py", line 430, in <module>
json.dump(brilisp_code_generator.c_lisp(json.loads(sys.stdin.read())), sys.stdout)
File "/home/aadithya.bhat/c_lisp/bril/bril-txt/llama.lisp/src/backend/tests/llama2.c/../../c-lisp.py", line 58, in c_lisp
return ["brilisp"] + [self.gen_function(fn) for fn in prog[1:]]
File "/home/aadithya.bhat/c_lisp/bril/bril-txt/llama.lisp/src/backend/tests/llama2.c/../../c-lisp.py", line 58, in <listcomp>
return ["brilisp"] + [self.gen_function(fn) for fn in prog[1:]]
File "/home/aadithya.bhat/c_lisp/bril/bril-txt/llama.lisp/src/backend/tests/llama2.c/../../c-lisp.py", line 93, in gen_function
*self.gen_compound_stmt(func[2:], new_scope=False),
File "/home/aadithya.bhat/c_lisp/bril/bril-txt/llama.lisp/src/backend/tests/llama2.c/../../c-lisp.py", line 256, in gen_compound_stmt
instr_list += self.gen_stmt(s)
File "/home/aadithya.bhat/c_lisp/bril/bril-txt/llama.lisp/src/backend/tests/llama2.c/../../c-lisp.py", line 119, in gen_stmt
raise e
File "/home/aadithya.bhat/c_lisp/bril/bril-txt/llama.lisp/src/backend/tests/llama2.c/../../c-lisp.py", line 110, in gen_stmt
return self.gen_for_stmt(stmt)
File "/home/aadithya.bhat/c_lisp/bril/bril-txt/llama.lisp/src/backend/tests/llama2.c/../../c-lisp.py", line 168, in gen_for_stmt
iter_expr_instr = self.gen_expr(stmt[1][2])
IndexError: list index out of range
This is a syntax error that is not caught by C-Lisp yet. In the for loop inside mat-cons, (set i (add n 1)) is in the wrong place. It should have been:
Command executed .
output received.