Slice Bug from Relay from_tensorflow


An error occurs when a slice op with begin=0 and size = 0 is converted with relay.frontend.from_tensorflow. According to Tensorflow, the result of the slice op should be an empty array. It seems that StridedSliceRel from does not account for this situation.

The code to reproduce the error:

import tensorflow as tf
from tvm import relay

def main():
    slice_graph = tf.Graph()
    with slice_graph.as_default():
        shape = tf.constant([19], shape=[1], dtype=tf.int32)
        begin = tf.constant([0], shape=[1], dtype=tf.int32)
        size = tf.constant([0], shape=[1], dtype=tf.int32)
        result = tf.slice(shape, begin, size)
    slice_graph_def = slice_graph.as_graph_def(add_shapes=True)
    mod, params = relay.frontend.from_tensorflow(

if __name__ == '__main__':