Skip to content

Instantly share code, notes, and snippets.

@Cadene
Cadene / async_inference.py
Last active September 17, 2024 23:43
Async inference
import threading
import time
from collections import deque
from threading import Thread
import numpy as np
class TemporalQueue:
def __init__(self):
@Cadene
Cadene / bug_pytorch03.py
Created August 8, 2019 07:20
Bug indexing
import time
import torch
import itertools
def make_pairs_ids(nregion, bsize):
pairs_ids = []
for batch_id in range(bsize):
pairs_id = torch.LongTensor([
(batch_id,i,j) for i,j in \
itertools.product(range(nregion),repeat=2)])