def remove_view_op_from_sorted_graph(op: Operator) -> None:
    """
    Removes a view op, including reshape, squeeze, unsqueeze and flatten.
    """
    # Treat reshape op specially because it may have multiple inputs.
    if op._attrs["op"] != "reshape":
        remove_single_tensor_op_from_sorted_graph(op)
        return

    input_tensor = op._attrs["inputs"][0]
    output_tensor = op._attrs["outputs"][0]

    input_tensor._attrs["dst_ops"].remove(op)
    input_tensor._attrs["dst_ops"].update(output_tensor._attrs["dst_ops"])
    for dst_op in output_tensor._attrs["dst_ops"]:
        dst_op.replace_input_tensor(output_tensor, input_tensor)
    if output_tensor._attrs["is_output"]:
        input_tensor._attrs["is_output"] = True
        input_tensor._attrs["name"] = output_tensor._attrs["name"]
        input_tensor._attrs["shape"] = output_tensor._attrs["shape"]

    # Now we remove this reshape op from its shape tensors' dst_ops
    # Note that a single shape_tensor may be passed to this reshape op multiple
    # times, so we place all shape_tensors into a set to remove duplicates.
    for shape_tensor in set(op._attrs["inputs"][1:]):
        shape_tensor._attrs["dst_ops"].remove(op)

    remove_tensor_from_sorted_graph(output_tensor)
Removes a view op, including reshape, squeeze, unsqueeze and flatten.
python/aitemplate/compiler/transform/transform_utils.py