def remove_single_tensor_op_from_sorted_graph(op: Operator) -> None:
    """
    Removes an op which only has one input and one output.
    Connects the previous op and the next op together.
    """
    # Treat reshape op specially because its shape tensors do not maintain
    # input-output dependency on the reshape op.
    if op._attrs["op"] == "reshape":
        # ensure
        for x in op._attrs["inputs"][1:]:
            assert op not in x._attrs["dst_ops"], (
                f'Invalid: shape tensor {x._attrs["name"]} has reshape op '
                f'{op._attrs["name"]} in its dst_ops'
            )
    else:
        assert len(op._attrs["inputs"]) == 1
    assert len(op._attrs["outputs"]) == 1

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

    input_tensor._attrs["dst_ops"].discard(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"]:
        assert not input_tensor._attrs[
            "is_input"
        ], f"{input_tensor._attrs['name']} can not be input and output"
        input_tensor._attrs["is_output"] = True
        input_tensor._attrs["name"] = output_tensor._attrs["name"]
        input_tensor._attrs["shape"] = output_tensor._attrs["shape"]

    remove_tensor_from_sorted_graph(output_tensor)
Removes an op which only has one input and one output.
Connects the previous op and the next op together.
python/aitemplate/compiler/transform/transform_utils.py