Ejemplo n.º 1
0
def operation_mode():
    # Set to share the coordinate_manager by default
    ME.set_sparse_tensor_operation_mode(
        ME.SparseTensorOperationMode.SHARE_COORDINATE_MANAGER)
    print(ME.sparse_tensor_operation_mode())

    coords0, feats0 = to_sparse_coo(data_batch_0)
    coords0, feats0 = ME.utils.sparse_collate(coords=[coords0], feats=[feats0])

    coords1, feats1 = to_sparse_coo(data_batch_1)
    coords1, feats1 = ME.utils.sparse_collate(coords=[coords1], feats=[feats1])

    for _ in range(2):
        # sparse tensors
        A = ME.SparseTensor(coordinates=coords0, features=feats0)
        B = ME.SparseTensor(
            coordinates=coords1,
            features=feats1,
            # coords_manager=A.coordinate_manager,  No need to feed the coordinate_manager
        )

        C = A + B

        # When done using it for forward and backward, you must cleanup the coords man
        ME.clear_global_coordinate_manager()