Extension API support for VivadoAccelerator backend #1058
-
HI, first of all, I want to say thank you! I am trying to use Extension API for VivadoAccelerator(not Vivado) backend. Because I'm planning to deploy the IP block on FPGA and use PYNQ's overlay to solve the communication between PS & PL. I read the documentation, https://fastmachinelearning.org/hls4ml/advanced/extension.html# and wrote the super simple class, PReverse. It means the pytorch version of KReverse in the documentation :)
When I used the Vivado backend, everything is ok!! The hls model's output is almost same with the output of pytorch
full error log
Any comment will be great help to me. Please give me some advice to solve the problem. Or where should I look more to solve this problem? :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi, I found the reason of the error and I want to share my experience. # hls4ml layer implementation
class HReverse(hls4ml.model.layers.Layer):
'''hls4ml implementation of a hypothetical custom layer'''
def initialize(self):
inp = self.get_input_variable()
shape = inp.shape
dims = inp.dim_names
self.add_output_variable(shape, dims) Because the input and output have the same shape in reverse operation, you can see that the input's To start with the solution, a separate Solution# dims = inp.dim_names
dims = [f'N_OUTPUT_{i}_{self.index}' for i in range(1, len(shape) + 1)] Details
There are some logics that checks & replace & write in https://github.com/fastmachinelearning/hls4ml/blob/main/hls4ml/writer/vivado_accelerator_writer.py#L343-L360 elif inp.size_cpp() in line or inp.name in line or inp.type.name in line:
newline = line.replace(inp.size_cpp(), 'N_IN').replace(inp.type.name, 'input_axi_t')
elif out.size_cpp() in line or out.name in line or out.type.name in line:
newline = line.replace(out.size_cpp(), 'N_OUT').replace(out.type.name, 'output_axi_t') Every conditions are connected with |
Beta Was this translation helpful? Give feedback.
Hi, I found the reason of the error and I want to share my experience.
I wrote my class using the example in documentation and specially descripting hls4ml's layer is same.
Because the input and output have the same shape in reverse operation, you can see that the input's
shape
anddims
are used when adding the output variable. Actually,dims
are strings that describe the dimension of an ar…