import tensorflow as tf

    # Convolution when number of indices is larger than zero.
    def _conv_nonzero():
        # Gather patches.
        p = tf.gather_nd(x_, blk_indices_)
        p_ = tf.reshape(p, [-1, ksize[0] * ksize[1] * ksize[2]])

        # Convolution on patches.
        w_ = tf.reshape(w, [ksize[0] * ksize[1] * ksize[2], -1])
