Closed paldebjit closed 3 years ago
It seems the Github file does not match the error message. Am I referring to the wrong file?
Interesting. I double-checked, And that's the file I am trying to compile with that commit of HCL.
I mean it doesn't match with the error message you paste. If you look at line 38, there is no p[i][j] = c / (p[i][j - 1])
.
Oh I see. The actual line is the code that you see in the file. I removed everything but c
and still error happened (Was trying to narrow down the cause). You are seeing the line with c
only in the error message because I generated the error message with that modified line of p[i][j] = c / (p[i][j - 1])
. When you remove all the a
, b
, and c
the code runs.
I believe the problem is you cannot directly operate numpy numbers with HeteroCL expressions.
You should convert them to Python numbers first. I guess that should solve the problem.
But then the Python float is 64 bits. It used to cause result mismatch.
What do you mean? I believe there exist NumPy methods that can transform NumPy numbers to Python numbers without losing accuracy.
Ok. I shall double-check and update here. I think you are referring to .item()
method in NumPy.
In the worst case you can wrap them with HeteroCL empty placeholders, i.e., a = placeholder(())
.
Seems like .item()
worked. Thanks!
But is there a way we can add a more informative error message?
Another solution is to switch numpy numbers to the RHS. If the numpy number is in the LHS, Python will be using its operator (e.g., +, -, *, /).
@paldebjit please try #343 and let me know if that works. Thanks.
@paldebjit any update?
No. I was busy with something else. I will update you in another 1-2 days. I have come back to this one today!
ok, thanks.
Generating code for the non-optimized kernel...
File "codegens/codegen_adi.py", line 56, in
I get this error message and the last line is color-coded. This is much helpful. Thanks, @seanlatias for this. I will be closing issue now.
Error message
riginal exception was:
hcl.mutate((NT,), lambda m: sweep(u, v, p, q), "main_loop")
File "/scratch/users/dp638/Work/PolyHCL/examples/polybench_fpga/stencils/adi/adi.py", line 38, in sweep
p[i][j] = c / (p[i][j - 1])
File "/scratch/users/dp638/Work/heterocl_pocc/python/heterocl/tensor.py", line 184, in getattr
"Cannot access attribute if type is not struct")
heterocl.debug.TensorError: [Tensor] Cannot access attribute if type is not struct
Traceback (most recent call last):
File "codegens/codegen_adi.py", line 56, in
mu2, a, b, c, d, e, f, dtype, target=target) File "/scratch/users/dp638/Work/PolyHCL/examples/polybench_fpga/stencils/adi/adi.py", line 58, in top_adi s = hcl.create_schedule([u, v, p, q], kernel_adi) File "/scratch/users/dp638/Work/heterocl_pocc/python/heterocl/api.py", line 210, in create_schedule ret = func(inputs) File "/scratch/users/dp638/Work/PolyHCL/examples/polybench_fpga/stencils/adi/adi.py", line 56, in kernel_adi hcl.mutate((NT,), lambda m: sweep(u, v, p, q), "main_loop") File "/scratch/users/dp638/Work/heterocl_pocc/python/heterocl/compute_api.py", line 433, in mutate fcompute(var_list) File "/scratch/users/dp638/Work/PolyHCL/examples/polybench_fpga/stencils/adi/adi.py", line 56, in
How to reproduce
git clone https://github.com/cornell-zhang/poly-heterocl.git -b mpr-feb2021 cd poly-heterocl/polybench_fpga python codegens/codegen_adi.py -S MINI -D Float -B adi -T merlinc
Location of necessary artifacts
Source code:
stencils/adi
Codegen:codegens
Observation
If I remove the
a
,b
, andc
in line 37, the code works. By defaulta
,b
, andc
are of NumPy Float data type coming from thecodegens/codegen_adi.py
. All parameters are defined instencils/adi/config.py
.HeteroCL commit used
commit c51ac660412fa909279d4628e4a0b7d12f64a85a