fastmachinelearning / hls4ml

Machine learning on FPGAs using HLS
https://fastmachinelearning.org/hls4ml
Apache License 2.0
1.29k stars 419 forks source link

Depthwise convolution for oneAPI #1131

Open laurilaatu opened 1 week ago

laurilaatu commented 1 week ago

Description

:memo: This pull request adds Depthwise convolution to oneAPI backend.

Type of change

Adding Depthwise convolution in a parallel implementation. Supports depth multiplier. When a separable convolution layer is used, it is split to depthwise and pointwise layers.

Note: Please delete options that are not relevant.

Tests

:memo: Pytests included and models compiled with depthwise and separable convolution.

Test Configuration:

model = Sequential()
model.add(DepthwiseConv2D(input_shape = (10,10,3), kernel_size=(3,3), padding="same", depth_multiplier=2, activation='relu', strides=(2,2)))
model.compile(loss='mse', optimizer=Adam())
model.summary()

config = hls4ml.utils.config_from_keras_model(model, granularity='name', default_precision='ac_fixed<16, 6>')
hls_model = hls4ml.converters.convert_from_keras_model(model=model, output_dir="model_dconv_out", backend="oneAPI", part="Agilex7", hls_config=config)
hls_model.compile()

Checklist

jmitrevs commented 1 week ago

Is it worth adding 1D versions, too?

jmitrevs commented 1 week ago

Why so many commits? Is it worth rebasing on a new branch from main?