MCPcopy Create free account
hub / github.com/PythonOT/POT / randperm

Method randperm

ot/backend.py:2261–2275  ·  view source on GitHub ↗
(self, size, type_as=None)

Source from the content-addressed store, hash-verified

2259 return torch.randn(size=size, generator=self.rng_)
2260
2261 def randperm(self, size, type_as=None):
2262 if not isinstance(size, int):
2263 raise ValueError("size must be an integer")
2264 if type_as is not None:
2265 generator = (
2266 self.rng_cuda_ if self.device_type(type_as) == "GPU" else self.rng_
2267 )
2268 return torch.randperm(
2269 n=size,
2270 dtype=type_as.dtype,
2271 generator=generator,
2272 device=type_as.device,
2273 )
2274 else:
2275 return torch.randperm(n=size, generator=self.rng_)
2276
2277 def coo_matrix(self, data, rows, cols, shape=None, type_as=None):
2278 if type_as is None:

Callers

nothing calls this directly

Calls 2

device_typeMethod · 0.95
randpermMethod · 0.45

Tested by

no test coverage detected