import tensorflow as tf

    def _conv_nonzero():
        # Gather patches.
        p = tf.gather_nd(x_, blk_indices_)

        # Reshape patches.
        p = tf.reshape(p, [blk_shape[0], blk_shape[1], blk_shape[2], -1])

        # Convolution on patches.
        q = tf.nn.conv2d(p, w, strides, 'VALID', use_cudnn_on_gpu=True)

        # Paste convolution results.
        q_shape = tf.shape(q)

        def _strides_gt_one():
            # Calculate output indices when strides > 1.
            blk_indices_crop = tf.strided_slice(blk_indices, [0, 0, 0, 0], [
                blk_shape[0], q_shape[1] * strides[1], q_shape[2] * strides[2], 3
            ], strides)
            blk_indices_crop = blk_indices_crop // tf.stack([1, strides[1], strides[2]])
            return blk_indices_crop

        def _strides_one():
