Skip to content

Choosing new variable names during codegen bug #506

Open
@SamirDroubi

Description

@SamirDroubi

How to reproduce:

def dot(n: size, x: [R][n] @ DRAM, y: [R][n] @ DRAM,
                 result: R @ DRAM):
    result = 0.0
    for i in seq(0, n):
        result += x[i] * y[i]

Schedule:

dot = stage_mem(dot, dot.body(), "result", "result_")
dot = stage_mem(dot, dot.body(), "result", "result_")

Result:

def exo_sdot_stride_1(n: size, x: [f32][n] @ DRAM, y: [f32][n] @ DRAM,
                      result: f32 @ DRAM):
    assert stride(x, 0) == 1
    assert stride(y, 0) == 1
    result_: f32 @ DRAM
    result__1: f32 @ DRAM
    result__1 = 0.0
    for i in seq(0, n):
        result__1 += x[i] * y[i]
    result_ = result__1
    result = result_

Error:

Traceback (most recent call last):
  File "/home/samir/.local/bin/exocc", line 8, in <module>
    sys.exit(main())
  File "/home/samir/.local/lib/python3.9/site-packages/exo/main.py", line 46, in main
    exo.compile_procs(library, outdir, f"{args.stem}.c", f"{args.stem}.h")
  File "/home/samir/.local/lib/python3.9/site-packages/exo/API.py", line 151, in compile_procs
    c_data, h_data = compile_procs_to_strings(proc_list, h_file)
  File "/home/samir/.local/lib/python3.9/site-packages/exo/API.py", line 159, in compile_procs_to_strings
    return run_compile([p._loopir_proc for p in proc_list], h_file_name)
  File "/home/samir/.local/lib/python3.9/site-packages/exo/LoopIR_compiler.py", line 317, in run_compile
    fwd_decls, body = compile_to_strings(lib_name, proc_list)
  File "/home/samir/.local/lib/python3.9/site-packages/exo/LoopIR_compiler.py", line 402, in compile_to_strings
    comp = Compiler(p, ctxt_name, is_public_decl=is_public_decl)
  File "/home/samir/.local/lib/python3.9/site-packages/exo/LoopIR_compiler.py", line 579, in __init__
    self.comp_stmts(self.proc.body)
  File "/home/samir/.local/lib/python3.9/site-packages/exo/LoopIR_compiler.py", line 637, in comp_stmts
    self.comp_s(b)
  File "/home/samir/.local/lib/python3.9/site-packages/exo/LoopIR_compiler.py", line 890, in comp_s
    name = self.new_varname(s.name, typ=s.type, mem=s.mem)
  File "/home/samir/.local/lib/python3.9/site-packages/exo/LoopIR_compiler.py", line 659, in new_varname
    s = f"{m[1]}_{int(m[2]) + 1}"
ValueError: invalid literal for int() with base 10: ''
ninja: build stopped: subcommand failed.

Metadata

Metadata

Assignees

Labels

C: CodegenThe final C code generationS: AvailableAvailable to be worked uponT: BugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions