• Shucai Xiao's avatar
    Non std shape auto contiguous (#1001) · 2d4dcc47
    Shucai Xiao authored
    Resolves a problem in parsing the ssd-10 model.
    
    The problem is, after inserting contiguous in the auto_contiguous pass, standard output shape of some operators becomes non-standard. Then, if the next operator requires standard input shape, an exception is throw.
    
    For example, if we pass the following model:
    Input (standard shape) -> transpose (transposed) -> softmax (transposed) -> transpose (standard) -> gather.
    It works fine, and no contiguous is required.
    
    In the auto_contiguous pass, a contiguous is inserted after the first transpose. Then we need to replace the first transpose with the contiguous and recompute all shapes. When it comes to the gather operator, its input is a transposed shape, and an exception is thrown.
    
    The solution is in the recompute_shape() function. If it is called by the auto_contiguous pass and shape of an instruction is changed, and the shape is non_standard, we do not recompute shape of its output. The reason is: since its output shape is non_standard, a contiguous op will be added after the instruction, which will recompute shape for later operators.
    2d4dcc47
test_nonstd_gather.cpp 986 Bytes