TF backend: conv2d fails on TF-CPU when using channel_first
Author: fhchlCreated Sep 16, 2026Updated Sep 16, 2026
Labelstype:Bugbackend:tensorflow
This is a report of a similar issue to #23031. The following fails with Tensorflow on CPU
import numpy as np
from keras import ops
input_shape = (2, 3, 10, 10)
inputs_2d = np.arange(600, dtype=float).reshape(input_shape)
kernel = np.arange(24, dtype=float).reshape([2, 2, 3, 2])
outputs = ops.conv(
inputs_2d,
kernel,
data_format="channels_first"
)
# UnimplementedError: The Conv2D op currently only supports the NHWC tensor format on the CPU. The op was given the format: NCHW
See also this gist.
A simple fix is to just add this case to the XLA workaround here.
Source: keras-team/keras