Multidimensional array with dimension size 1 is not eliminated
Opened this issue · 0 comments
chhzh123 commented
In this example, the 0th dimension of A
is useless, since it only has size 1.
def test_multidimensional_array():
hcl.init()
A = hcl.placeholder((1, 100), "A")
def kernel(A):
B = hcl.compute(A.shape, lambda x, y: A[x, y] + 1, "B")
return B
s = hcl.create_schedule([A], kernel)
target = hcl.platform.zc706
target.config(compile="vivado_hls",mode="csim")
f = hcl.build(s, target=target)
hcl_A = hcl.asarray(np.zeros((1,100)))
hcl_B = hcl.asarray(np.zeros((1,100)))
f(hcl_A,hcl_B)
The generated code outputs a constant as a placeholder. However, A
and B
can be both optimized to 1D arrays.
void test(bit32 B[1][100], bit32 A[1][100]) {
B_y: for (bit32 y = 0; y < 100; ++y) {
B[0][y] = (A[0][y] + 1);
}
}