Skip to content

Commit e55b29c

Browse files
committed
slightly expand discussion of channels_last in pytorch
1 parent f28f364 commit e55b29c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

hls4ml/utils/config.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,15 @@ def config_from_pytorch_model(
292292
Users are advised to inspect the returned object to tweak the conversion configuration.
293293
The return object can be passed as `hls_config` parameter to `convert_from_pytorch_model`.
294294
295+
Note that hls4ml internally follows the keras convention for nested tensors known as
296+
"channels last", wherease pytorch uses the "channels first" convention.
297+
For exampe, for a tensor encoding an image with 3 channels, pytorch will expect the data
298+
to be encoded as (Number_Of_Channels, Height , Width), whereas hls4ml expects
299+
(Height , Width, Number_Of_Channels). By default, hls4ml will perform the necessary
300+
conversions of the inputs and internal tensors automatically, but will return the output
301+
in "channels last" However, this behavior can be controlled by the user using the
302+
related arguments discussed below.
303+
295304
Args:
296305
model: PyTorch model
297306
input_shape (tuple or list of tuples): The shape of the input tensor, excluding the batch size.

0 commit comments

Comments
 (0)