Skip to content

Add Conv3DTranspose, UpSampling3D, and stride-1 fast path for Conv3D - #456

Merged
Dobiasd merged 1 commit into
masterfrom
conv-3d-followups
Apr 27, 2026
Merged

Add Conv3DTranspose, UpSampling3D, and stride-1 fast path for Conv3D#456
Dobiasd merged 1 commit into
masterfrom
conv-3d-followups

Conversation

@Dobiasd

@Dobiasd Dobiasd commented Apr 27, 2026

Copy link
Copy Markdown
Owner

Follow-up to #455. Builds out the rest of the 3D layer family that Keras supports.

Summary

  • Conv3DTranspose: dilates the input, then runs a forward conv with strides (1,1,1) and filters reversed along all three spatial axes. New layer class conv_3d_transpose_layer, JSON dispatch entry, and Python exporter (prepare_filter_weights_conv_3d_transpose + show_conv_3d_transpose_layer).
  • UpSampling3D: nearest-neighbor resize for volumetric tensors (Keras only supports nearest for the 3D variant). New layer class upsampling_3d_layer, resize3d_nearest helper in tensor.hpp, JSON dispatch, config-only Python exporter.
  • Stride-1×1×1 fast path (convolve_accumulative_s1x1x1_3d): collapses the spatial output loops into one big im2col mapping, mirroring convolve_accumulative_s1x1 from the 2D path. Triggers automatically when all strides are 1, so it also speeds up Conv3DTranspose (which always uses internal stride 1).
  • Tiny supporting changes: preprocess_convolution_3d gains an optional transposed flag; dilate_tensor_3d gains optional trailing_zeros; generate_filters_3d gains optional transpose; new reverse_size_dim_4_dimension helper.
  • Tests: Conv3DTranspose ×5 variants and UpSampling3D ×3 variants added to generate_test_models.py.
  • README: Conv3DTranspose added to supported list, Upsampling3D removed from unsupported list, UpSampling1D/2D updated to 1D/2D/3D.

Test plan

  • Standalone C++ correctness vs brute-force reference still passes (~1e-6 max diff) with the fast path active for stride-1 cases
  • End-to-end Keras → fdeep round-trip passes for all four Conv3DTranspose variants (basic, same, strided 2×2×2, no-bias) and all three UpSampling3D variants (2×2×2, 1×3×5, 2×1×1)
  • Conv2D, Conv3D, and the multi-input round-trip from Add Conv3D layer support #455 still pass
  • CI runs test_model_exhaustive_test against the updated generate_test_models.py

Out of scope

  • SeparableConv3D and DepthwiseConv3D: Keras 3 doesn't expose them (hasattr(keras.layers, ...) == False), so there's nothing to import from
  • Further fast-path optimization beyond stride-1×1×1

🤖 Generated with Claude Code

Builds on the Conv3D foundation:
- Conv3DTranspose: dilates input then runs forward conv with strides (1,1,1)
  and reversed filters along all three spatial axes.
- UpSampling3D: nearest-neighbor resize for volumetric tensors.
- convolve_accumulative_s1x1x1_3d: collapses the spatial output loops into
  one big im2col mapping, mirroring the 2D fast path. Triggers automatically
  when strides are (1,1,1), so it also speeds up Conv3DTranspose.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Dobiasd
Dobiasd merged commit 2d34693 into master Apr 27, 2026
4 checks passed
@Dobiasd
Dobiasd deleted the conv-3d-followups branch April 27, 2026 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant