code generation for custom layer 'PatchEmbedding' for target 'none' is not supported as it returns a dlarray object with data format'SCB' as output 'out'

9 views (last 30 days)

Accepted Answer

Akanksha
Akanksha on 21 Nov 2025
Hi 素蓬,
This error occurs because code generation does not support custom layers that return dlarray objects with data format SCB (Sequence, Channel, Batch). The PatchEmbedding layer in Vision Transformers outputs dlarray with SCB, which is currently unsupported for target 'none'.
You can try out these following troubleshooting steps -
  • Use predict in MATLAB onlyRun inference in MATLAB without generating code.
  • Convert output to numeric arrayInside your custom layer, convert dlarray to single or double before returning:
out = extractdata(out);
This removes dlarray formatting but may break downstream layers.
  • Avoid unsupported formatsIf code generation is required, design layers to output supported formats.
Kindly refer the following links for further information -
Hope this helps!

More Answers (1)

素蓬
素蓬 on 21 Nov 2025
give a example of code generation of transformer in matlab R2025a

Categories

Find more on Deep Learning with GPU Coder in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!