Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/benchmarks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ We compare our results against existing data loading platforms:
- `Pytorch DataLoader <https://pytorch.org/docs/stable/data.html#torch.utils.data.DataLoader>`_: This is the default option that comes with the Pytorch library and uses individual JPEG files as the source.
- `Webdataset <https://github.com/webdataset/webdataset>`_: This loader requires pre-processed files aggregated in multiple big `.tar` archives.
- `DALI <https://docs.nvidia.com/deeplearning/dali/user-guide/docs/>`_: Data loading pipeline developed by Nvidia. In this experiment we used the default file format which is the same as that of the Pytorch DataLoader.

The specific instantiation of DALI that we apply is the PyTorch ImageNet example DALI code found in the `NVIDIA DeepLearningExamples repository <https://github.com/NVIDIA/DeepLearningExamples/tree/master/PyTorch/Classification/ConvNets/resnet50v1.5>`_.
We use the DGX-1 configuration and remove all the model optimization, benchmarking only the dataloader.

Expand Down
4 changes: 2 additions & 2 deletions docs/ffcv_examples/custom_transforms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ Doing so requires providing implementation for two functions:
# Return the code to run this operation
@abstractmethod
def generate_code(self) -> Callable:
raise NotImplementedError
raise NotImplementedError()

@abstractmethod
def declare_state_and_memory(self, previous_state: State) -> Tuple[State, Optional[AllocationQuery]]:
raise NotImplementedError
raise NotImplementedError()

Advancing state and pre-allocating memory
------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion ffcv/benchmarks/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ def __init__(self, **kwargs):

@abstractmethod
def run(self):
raise NotImplemented()
raise NotImplementedError()
10 changes: 5 additions & 5 deletions ffcv/fields/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ class Field(ABC):
@property
@abstractmethod
def metadata_type(self) -> np.dtype:
raise NotImplemented
raise NotImplementedError()

@staticmethod
@abstractmethod
def from_binary(binary: ARG_TYPE) -> Field:
raise NotImplementedError
raise NotImplementedError()

@abstractmethod
def to_binary(self) -> ARG_TYPE:
raise NotImplementedError
raise NotImplementedError()

@abstractmethod
def encode(field, metadata_destination, malloc):
raise NotImplementedError
raise NotImplementedError()

@abstractmethod
def get_decoder_class(self) -> Type[Operation]:
raise NotImplementedError
raise NotImplementedError()
2 changes: 1 addition & 1 deletion ffcv/fields/rgb_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def decode(batch_indices, my_storage, metadata, storage_state):
@property
@abstractmethod
def get_crop_generator():
raise NotImplementedError
raise NotImplementedError()


class RandomResizedCropRGBImageDecoder(ResizedCropRGBImageDecoder):
Expand Down
2 changes: 1 addition & 1 deletion ffcv/memory_managers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def schedule_epoch(self, batches: Sequence[Sequence[int]]) -> MemoryContext:

@abstractmethod
def compile_reader(self, address, size) -> Callable:
raise NotImplemented()
raise NotImplementedError()

@property
@abstractmethod
Expand Down
31 changes: 19 additions & 12 deletions ffcv/pipeline/graph.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from distutils.log import warn
import warnings
import ast
import sys

try:
# Useful for debugging
Expand All @@ -23,11 +23,18 @@
import torch as ch
import numpy as np

# This is the starting state of the pipeline
INITIAL_STATE = State(jit_mode=True,
device=ch.device('cpu'),
dtype=np.dtype('u1'),
shape=None)
if "sphinx" in sys.modules:
# Sphinx fails on jit+gpu assert due to improper initialization of device
INITIAL_STATE = State(jit_mode=False,
device=ch.device('cpu'),
dtype=np.dtype('u1'),
shape=None)
else:
# This is the starting state of the pipeline
INITIAL_STATE = State(jit_mode=True,
device=ch.device('cpu'),
dtype=np.dtype('u1'),
shape=None)


class Node(ABC):
Expand All @@ -40,34 +47,34 @@ def __init__(self):
@property
@abstractmethod
def is_jitted(self):
raise NotImplemented()
raise NotImplementedError()

@property
@abstractmethod
def parent(self):
raise NotImplemented()
raise NotImplementedError()

@property
@abstractmethod
def arg_id(self):
raise NotImplemented()
raise NotImplementedError()

@property
@abstractmethod
def result_id(self):
raise NotImplemented()
raise NotImplementedError()

@property
@abstractmethod
def result_id(self):
raise NotImplemented()
raise NotImplementedError()

def get_shared_code_ast(self, done_ops):
return ast.Pass()

@abstractmethod
def generate_code(self):
raise NotImplemented()
raise NotImplementedError()

def recompile(self):
self._code = self.generate_code()
Expand Down
4 changes: 2 additions & 2 deletions ffcv/pipeline/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def accept_globals(self, metadata, memory_read):
# Return the code to run this operation
@abstractmethod
def generate_code(self) -> Callable:
raise NotImplementedError
raise NotImplementedError()

def declare_shared_memory(self, previous_state: State) -> Optional[AllocationQuery]:
return None
Expand All @@ -38,4 +38,4 @@ def generate_code_for_shared_state(self) -> Optional[Callable]:

@abstractmethod
def declare_state_and_memory(self, previous_state: State) -> Tuple[State, Optional[AllocationQuery]]:
raise NotImplementedError
raise NotImplementedError()
2 changes: 1 addition & 1 deletion ffcv/pipeline/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class State:

# Assess the validity of a pipeline stage
def __post_init__(self):
if self.jit_mode and self.device != ch.device('cpu'):
if self.jit_mode and self.device.type != 'cpu':
raise AssertionError("Can't be in JIT mode and on the GPU")
if self.jit_mode and isinstance(self.dtype, ch.dtype):
raise AssertionError("Can't allocate a torch tensor in JIT mode")
2 changes: 1 addition & 1 deletion ffcv/transforms/mixup.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def declare_state_and_memory(self, previous_state: State) -> Tuple[State, Option

class LabelMixup(Operation):
"""Mixup for labels. Should be initialized in exactly the same way as
:cla:`ffcv.transforms.ImageMixup`.
:class:`ffcv.transforms.ImageMixup`.
"""
def __init__(self, alpha: float, same_lambda: bool):
super().__init__()
Expand Down
2 changes: 1 addition & 1 deletion ffcv/transforms/random_resized_crop.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class RandomResizedCrop(Operation):
"""Crop a random portion of image with random aspect ratio and resize it to
a given size. Chances are you do not want to use this augmentation and
instead want to include RRC as part of the decoder, by using the
:cla:`~ffcv.fields.rgb_image.ResizedCropRGBImageDecoder` class.
:class:`~ffcv.fields.rgb_image.ResizedCropRGBImageDecoder` class.

Parameters
----------
Expand Down
2 changes: 1 addition & 1 deletion ffcv/traversal_order/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ def __init__(self, loader: 'Loader'):

@abstractmethod
def sample_order(self, epoch:int) -> Sequence[int]:
raise NotImplemented()
raise NotImplementedError()