Merge request 3 (c29d658f64268a71c2315e596e0b66cdea2ca360 -> 2c59b6183da0938759bbf87662ed8ce1e4865277)
By: anonymous
Against ref: refs/heads/master
Date: 2019-03-18 03:27
This merge request can be merged without conflicts.
Commit 2c59b6183da0938759bbf87662ed8ce1e4865277
- support pin memory
Author: Xiangru Lian
Author date (UTC): 2019-03-18 03:24
Committer name: Xiangru Lian
Committer date (UTC): 2019-03-18 03:24
Parent(s): c29d658f64268a71c2315e596e0b66cdea2ca360
Signing key:
Tree: 0a0900f6f7f99e711fdcbf3ae3f61160728d2807
File persia_pytorch_toolkit/tensor_utils.py changed (mode: 100644) (index 4899dc5..8fcc6a2) |
... |
... |
def _numpy_dtype_to_torch_dtype(dtype: np.dtype): |
35 |
35 |
raise Exception("Unknown numpy dtype: " + str(t)) |
raise Exception("Unknown numpy dtype: " + str(t)) |
36 |
36 |
|
|
37 |
37 |
|
|
38 |
|
def to_device_from_numpy(container, device): |
|
|
38 |
|
def to_device_from_numpy(container, device, pin_memory=False): |
39 |
39 |
"""The device could be cuda:0 for example.""" |
"""The device could be cuda:0 for example.""" |
40 |
40 |
device = torch.device(device) |
device = torch.device(device) |
41 |
41 |
return _iterate_over_container(container, |
return _iterate_over_container(container, |
42 |
|
lambda x: torch.as_tensor(x, dtype=_numpy_dtype_to_torch_dtype(x.dtype), device=device), |
|
|
42 |
|
lambda x: torch.as_tensor(x, dtype=_numpy_dtype_to_torch_dtype(x.dtype), device=device).pin_memory() if pin_memory else torch.as_tensor(x, dtype=_numpy_dtype_to_torch_dtype(x.dtype), device=device), |
43 |
43 |
np.ndarray |
np.ndarray |
44 |
44 |
) |
) |
File setup.py changed (mode: 100644) (index bc4112e..6114cc0) |
1 |
1 |
from setuptools import setup |
from setuptools import setup |
2 |
2 |
|
|
3 |
3 |
setup(name='persia_pytorch_toolkit', |
setup(name='persia_pytorch_toolkit', |
4 |
|
version='0.0.5', |
|
|
4 |
|
version='0.0.6', |
5 |
5 |
description="Xiangru Lian's toolkit with PyTorch.", |
description="Xiangru Lian's toolkit with PyTorch.", |
6 |
6 |
url='https://github.com/ikzk/persia_pytorch_toolkit', |
url='https://github.com/ikzk/persia_pytorch_toolkit', |
7 |
7 |
author="Xiangru Lian", |
author="Xiangru Lian", |
Hints:
How to merge on your machine?
git fetch origin refs/mr/3:mr-3
git checkout main
git merge mr-3
To "see" all the merge requests as branches,
add, in the config file (.git/config), under the remote you want,
a line like this:
fetch = +refs/mr/*:refs/remotes/your_remote_name_for_example_origin/mr/*
After you run a git fetch, you will have all the pull requests locally.
For example, you can merge one of them:
git checkout main
git merge mr/3