-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release 0.2.0 See merge request hpi-xnor/bmxnet-projects/bitorch!43
- Loading branch information
Showing
75 changed files
with
1,598 additions
and
1,326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,42 @@ | ||
image: python:3.8 | ||
image: python:3.7 | ||
|
||
before_script: | ||
- python --version | ||
- pip install --find-links https://download.pytorch.org/whl/torch_stable.html "torch==1.9.0+cu111" "torchvision==0.10.0+cu111" | ||
- pip install -e .[dev] | ||
- flake8 --version | ||
- mypy --version | ||
- pytest --version | ||
- python --version | ||
- pip install -e .[dev] --extra-index-url https://download.pytorch.org/whl/cu113 | ||
- pwd | ||
- ls -l | ||
- python -c "import sys;print(sys.path)" | ||
|
||
test-codestyle:3.7: | ||
.codestyle: | ||
stage: test | ||
image: python:3.7 | ||
script: | ||
- pwd | ||
- ls -l | ||
- python -c "import sys;print(sys.path)" | ||
- flake8 --config=setup.cfg | ||
- flake8 --version | ||
- mypy --version | ||
- flake8 | ||
- mypy --config-file mypy.ini | ||
|
||
test-units:3.7: | ||
codestyle: | ||
extends: .codestyle | ||
|
||
codestyle:3.8: | ||
extends: .codestyle | ||
image: python:3.8 | ||
|
||
.test: | ||
stage: test | ||
image: python:3.7 | ||
script: | ||
- pwd | ||
- ls -l | ||
- python -c "import sys;print(sys.path)" | ||
- pytest --version | ||
- python -m pytest . | ||
|
||
test-codestyle: | ||
stage: test | ||
script: | ||
- pwd | ||
- ls -l | ||
- python -c "import sys;print(sys.path)" | ||
- flake8 --config=setup.cfg | ||
- mypy --config-file mypy.ini | ||
test: | ||
extends: .test | ||
|
||
test:3.8: | ||
extends: .test | ||
image: python:3.8 | ||
|
||
test-units: | ||
test-build-doc: | ||
stage: test | ||
script: | ||
- pwd | ||
- ls -l | ||
- python -c "import sys;print(sys.path)" | ||
- python -m pytest . | ||
- apt-get update && apt-get install -y pandoc | ||
- sphinx-build -b html docs/source/ docs/build/ -a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,23 @@ | ||
from typing import Union, Tuple | ||
|
||
from torch.utils.data import Dataset | ||
import torch | ||
from typing import Tuple | ||
|
||
|
||
class DummyDataset(object): | ||
class DummyDataset(Dataset): | ||
"""An iterator that produces repeated dummy data. | ||
Args: | ||
data_sample: a data sample that should be produced at each step. | ||
batch_size: the batch size for storing. | ||
sample_count: number of `data` samples in the dummy dataset. | ||
""" | ||
|
||
def __init__(self, data_sample: Union[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]], | ||
batch_size: int, sample_count: int): | ||
self._data_sample = data_sample | ||
def __init__(self, data_shape: torch.Size, num_classes: int, sample_count: int) -> None: | ||
self._data_sample = torch.zeros(data_shape) | ||
self._class_sample = torch.zeros((num_classes,), dtype=torch.int64) | ||
self._sample_count = sample_count | ||
self.batch_size = batch_size | ||
self._count = 0 | ||
|
||
def __iter__(self) -> "DummyDataset": | ||
return DummyDataset(self._data_sample, self.batch_size, self._sample_count) | ||
|
||
def __len__(self) -> int: | ||
return self._sample_count | ||
|
||
def __next__(self) -> Union[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]]: | ||
return self.next() | ||
|
||
def next(self) -> Union[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]]: | ||
if self._count >= self._sample_count: | ||
raise StopIteration | ||
self._count += 1 | ||
return self._data_sample | ||
def __getitem__(self, idx: int) -> Tuple[torch.Tensor, torch.Tensor]: | ||
return self._data_sample, self._class_sample |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.