makslevental / openhls

PyTorch model to RTL flow for low latency inference
MIT License
121 stars 11 forks source link

Issue with running resnet18.py. #8

Open sul243 opened 8 months ago

sul243 commented 8 months ago

After compiling the resnet18.mlir file I get an error when I try to compile the .sv file for this example. Mainly it failes when it tries to translate the mlir file back to Python.

Here is the command I run to generate resnet18.mlir:

OPENHLS_CONFIG_FP=$(pwd)/openhls_config.ini python $(pwd)/examples/full_nns.py resnet18 12

Here is the command I run to generate the .sv file:

OPENHLS_CONFIG_FP=$(pwd)/openhls_config.ini openhls_compiler $(pwd)/examples/resnet18_12/resnet18.mlir -t -r -s -v -b

Here is the error:

Traceback (most recent call last): File "/usr/local/bin/openhls_compiler", line 8, in sys.exit(main()) File "/usr/local/lib/python3.10/site-packages/openhls/compiler/compile.py", line 333, in main compile( File "/usr/local/lib/python3.10/site-packages/openhls/compiler/compile.py", line 134, in compile pythonized_mlir = translate(affine_mlir_str) File "/usr/local/lib/python3.10/site-packages/openhls/compiler/compile.py", line 43, in translate raise Exception(f"translation failed {err.decode()}") Exception: translation failed :149:11: error: 'memref.subview' op is unsupported operation. %23 = memref.subview %22[0, 0, 1, 1] [1, 3, 12, 12] [1, 1, 1, 1] : memref<1x3x14x14xf32> to memref<1x3x12x12xf32, #map0> ^

:149:11: note: see current operation: %40 = "memref.subview"(%39) {operand_segment_sizes = dense<[1, 0, 0, 0]> : vector<4xi32>, static_offsets = [0, 0, 1, 1], static_sizes = [1, 3, 12, 12], static_strides = [1, 1, 1, 1]} : (memref<1x3x14x14xf32>) -> memref<1x3x12x12xf32, affine_map<(d0, d1, d2, d3) -> (d0 * 588 + d1 * 196 + d2 * 14 + d3 + 15)>> **Here is the stack dump.** Stack dump: 0. Program arguments: /usr/local/bin/openhls/openhls_translate --emit-hlspy --mlir-print-elementsattrs-with-hex-if-larger=-1 Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /usr/local/bin/openhls/openhls_translate(+0x1479b0)[0x563d72f499b0] /usr/local/bin/openhls/openhls_translate(+0x1454fc)[0x563d72f474fc] /lib/x86_64-linux-gnu/libpthread.so.0(+0x13140)[0x7fe3080e0140] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x141)[0x7fe307bd6ce1] /lib/x86_64-linux-gnu/libc.so.6(abort+0x123)[0x7fe307bc0537] /usr/local/bin/openhls/openhls_translate(+0x10b9cd)[0x563d72f0d9cd] /usr/local/bin/openhls/openhls_translate(+0x1140e5)[0x563d72f160e5] /usr/local/bin/openhls/openhls_translate(+0x116c4b)[0x563d72f18c4b] /usr/local/bin/openhls/openhls_translate(+0x1177c5)[0x563d72f197c5] /usr/local/bin/openhls/openhls_translate(+0x109fd3)[0x563d72f0bfd3] /usr/local/bin/openhls/openhls_translate(+0x56e208)[0x563d73370208] /usr/local/bin/openhls/openhls_translate(+0x56c706)[0x563d7336e706] /usr/local/bin/openhls/openhls_translate(+0x56c87f)[0x563d7336e87f] /usr/local/bin/openhls/openhls_translate(+0x65c127)[0x563d7345e127] /usr/local/bin/openhls/openhls_translate(+0x56cbd1)[0x563d7336ebd1] /usr/local/bin/openhls/openhls_translate(+0x1083f7)[0x563d72f0a3f7] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xea)[0x7fe307bc1d0a] /usr/local/bin/openhls/openhls_translate(+0x109eda)[0x563d72f0beda]
MX-Liu commented 7 months ago

I also have the same problem, have you fixed it?

salkha21 commented 7 months ago

Honestly I ended up using the docker image.

salkha21 commented 7 months ago

Resnet18 does not work for this tool as well.

MX-Liu commented 7 months ago

I used the docker image, both Resnet18 and mobilenet do not work, an issue happened to the Lenet, because the comment slash can not be recognized in the lenet.sv.

salkha21 commented 7 months ago

I used the docker image, and both Resnet18 and mobilenet do not work, an issue happened to the Lenet because the comment slash can not be recognized in the lenet.sv.

Yeah, so you are correct. None of the models you mentioned work. However, I was able to get Lenet working by contacting the creator of the tool, however, even when I was able to get the sv file for the Lenet it was not able to synthesize. I recommend using one of the simple nns in simple_nns.py.