cornell-zhang / heterocl

HeteroCL: A Multi-Paradigm Programming Infrastructure for Software-Defined Heterogeneous Computing
https://cornell-zhang.github.io/heterocl/
Apache License 2.0
322 stars 92 forks source link

hcl.select HLS codegen bug #258

Open wyanzhao opened 4 years ago

wyanzhao commented 4 years ago

Hi,

I am trying to generate HLS code for a Shift right op, here's the example:

with hcl.elif_(alu_opcode.v == VTA_ALU_OPCODE_SHR):        
                      dst_tensor[x][y] = hcl.select(src >= 0, dst >> src, dst << (-src))

While compiling this code using the HLS backend for this hcl.select statement, will raise an error like: heterocl.tvm._ffi.base.TVMError: [17:10:16] src/codegen/codegen_c.cc:49: unknown type of shift_left(int32(acc_mem[(uint32(i) + ((uint32(scalar0[0]) + uint32(((j*dst_factor_in[0]) + (i*dst_factor_out[0]))))*(uint32)16))]), (tvm_if_then_else((uint32(use_imm[0]) == (uint32)1), int32(int16(imm[0])), int32(acc_mem[(uint32(i) + ((uint32(scalar1[0]) + uint32(((j*src_factor_in[0]) + (i*src_factor_out[0]))))*(uint32)16))]))*-1))

However, if I replace hcl.select statement with a if else statement like this:

with hcl.elif_(alu_opcode.v == VTA_ALU_OPCODE_SHR):
                    with hcl.if_(src >= 0):
                        dst_tensor[x][y] = dst >> src
                    with hcl.else_():
                        dst_tensor[x][y] = dst << (-src)

This compilation will work.

Could you please fix this bug?