def operation_mode(): # Set to share the coords_man by default ME.set_sparse_tensor_operation_mode( ME.SparseTensorOperationMode.SHARE_COORDS_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(coords=coords0, feats=feats0) B = ME.SparseTensor( coords=coords1, feats=feats1, # coords_manager=A.coords_man, No need to feed the coords_man force_creation=True) C = A + B # When done using it for forward and backward, you must cleanup the coords man ME.clear_global_coords_man()
def operation_mode(): # Set to share the coords_man by default ME.set_sparse_tensor_operation_mode( ME.SparseTensorOperationMode.SHARE_COORDS_MANAGER) print(ME.sparse_tensor_operation_mode()) coords, feats = data_generation() new_coords = torch.IntTensor([[0, 1], [2, 3], [4, 5]]) new_feats = torch.rand(len(new_coords), feats.size(1)) for _ in range(2): # sparse tensors A = ME.SparseTensor(coords=coords, feats=feats) B = ME.SparseTensor( coords=new_coords, feats=new_feats, # coords_manager=A.coords_man, No need to feed the coords_man force_creation=True) C = A + B # When done using it for forward and backward, you must cleanup the coords man ME.clear_global_coords_man()