Skip to content

Commit f7c093f

Browse files
Documentation update
1 parent 40847f6 commit f7c093f

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

docs/api/hls-model.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,22 @@ The trace method is an advanced version of the ``predict`` method. It's used to
100100
101101
#We also support a similar function for keras
102102
keras_trace = hls4ml.model.profiling.get_ymodel_keras(keras_model, X)
103+
104+
.. _hw_predict-method:
105+
106+
``hw_predict`` method
107+
======================
108+
109+
An specialized version of the ``predict`` method, for the VitisAccelerator backend after a successful build. Runs the project on the FPGA and obtains prediction for the supplied numpy array.
110+
111+
Note that the host code being run under the hood is an example written for generic benchmarking purposes, helpful for validating projects and gauging maximum throughput. It should be further adapted for more specific applications.
112+
113+
.. code-block:: python
114+
115+
# Suppose that you already have input array X
116+
# Note that you have to do both hls_model.compile() and hls_model.build(), ensuring the .xclbin file is successfully created, before using hw_predict
117+
118+
y = hls_model.hw_predict(X)
119+
120+
The maximum of number of input samples that can processed is ``batchsize * num_cu * num_buffer``. If the input array exceeds that size the additional samples will be ignored.
121+
----

hls4ml/backends/vitis_accelerator/vitis_accelerator_backend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def hardware_predict(self, model, x):
147147

148148
currdir = os.getcwd()
149149
os.chdir(model.config.get_output_dir())
150-
os.system("./host build/kernel_wrapper.xclbin")
150+
os.system("make run")
151151
os.chdir(currdir)
152152

153153
return self.dat_to_numpy(model)

hls4ml/templates/vitis_accelerator/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ else
7070
# Optimization flags can be added here
7171
endif
7272

73-
.PHONY: all xclbin hls clean cleanhls cleanxclbin ultraclean
73+
.PHONY: all xclbin hls run clean cleanhls cleanxclbin ultraclean
7474

7575
all: xclbin host
7676

@@ -118,6 +118,11 @@ INCLUDES += -I$(PWD)/libs/ -I$(PWD)/firmware/ -I$(PWD)/firmware/nnet_utils/
118118
host: $(KERNEL_NAME)_host_cl.cpp libs/xcl2.cpp
119119
$(CXX) $(CXXFLAGS) $^ -o $@ $(INCLUDES) $(LDFLAGS)
120120

121+
# Execute program #############################################################
122+
123+
run: ./host $(BUILD_DIR)/$(WRAPPER_NAME).xclbin
124+
./host $(BUILD_DIR)/$(WRAPPER_NAME).xclbin
125+
121126
# Cleanup #####################################################################
122127

123128
cleanxclbin:

0 commit comments

Comments
 (0)