Skip to content

Commit

Permalink
Renaming Dataloader into Dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
KodiaqQ committed Apr 3, 2022
1 parent 3d8d0d3 commit 3826d8d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
10 changes: 5 additions & 5 deletions tests/onnx/quantization/test_classification_models_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
REFERENCE_GRAPHS_TEST_ROOT = 'data/reference_graphs/quantization'


class TestDataloader(Dataset):
class TestDataset(Dataset):
def __init__(self, input_shape):
super().__init__()
self.input_shape = input_shape
Expand All @@ -88,10 +88,10 @@ def test_min_max_quantization_graph(tmp_path, model, path_ref_graph, input_shape

original_model = onnx.load(onnx_model_path)

dataloader = TestDataloader(input_shape)
dataset = TestDataset(input_shape)
builder = CompressionBuilder()
builder.add_algorithm(ONNXMinMaxQuantization(MinMaxQuantizationParameters(number_samples=1)))
quantized_model = builder.apply(original_model, dataloader)
quantized_model = builder.apply(original_model, dataset)

nncf_graph = GraphConverter.create_nncf_graph(quantized_model)
nx_graph = nncf_graph.get_graph_for_structure_analysis(extended=True)
Expand All @@ -115,10 +115,10 @@ def test_post_training_quantization_graph(tmp_path, model, path_ref_graph, input

original_model = onnx.load(onnx_model_path)

dataloader = TestDataloader(input_shape)
dataset = TestDataset(input_shape)
builder = CompressionBuilder()
builder.add_algorithm(PostTrainingQuantization(PostTrainingQuantizationParameters(number_samples=1)))
quantized_model = builder.apply(original_model, dataloader)
quantized_model = builder.apply(original_model, dataset)

nncf_graph = GraphConverter.create_nncf_graph(quantized_model)
nx_graph = nncf_graph.get_graph_for_structure_analysis(extended=True)
Expand Down
6 changes: 3 additions & 3 deletions tests/onnx/quantization/test_detection_models_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from tests.common.helpers import TEST_ROOT
from tests.onnx.test_nncf_graph_builder import check_nx_graph

from tests.onnx.quantization.test_classification_models_graph import TestDataloader
from tests.onnx.quantization.test_classification_models_graph import TestDataset

from nncf.experimental.post_training.compression_builder import CompressionBuilder
from nncf.experimental.onnx.algorithms.quantization.min_max_quantization import ONNXMinMaxQuantization
Expand Down Expand Up @@ -66,10 +66,10 @@ def test_min_max_quantization_graph(tmp_path, model_name, model_url, path_ref_gr

original_model = onnx.load(onnx_model_path)

dataloader = TestDataloader(input_shape)
dataset = TestDataset(input_shape)
builder = CompressionBuilder()
builder.add_algorithm(ONNXMinMaxQuantization(MinMaxQuantizationParameters(number_samples=1)))
quantized_model = builder.apply(original_model, dataloader)
quantized_model = builder.apply(original_model, dataset)

nncf_graph = GraphConverter.create_nncf_graph(quantized_model)
nx_graph = nncf_graph.get_graph_for_structure_analysis(extended=True)
Expand Down
14 changes: 7 additions & 7 deletions tests/onnx/test_samplers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
(100 * np.ones(INPUT_SHAPE), 2)]


class TestDataloader(Dataset):
class TestDataset(Dataset):
def __init__(self, samples: List[Tuple[np.ndarray, int]]):
super().__init__(shuffle=False)
self.samples = samples
Expand All @@ -43,9 +43,9 @@ def __len__(self):

@pytest.mark.parametrize("batch_size", (1, 2, 3))
def test_batch_sampler(batch_size):
dataloader = TestDataloader(DATASET_SAMPLES)
dataloader.batch_size = batch_size
sampler = ONNXBatchSampler(dataloader)
dataset = TestDataset(DATASET_SAMPLES)
dataset.batch_size = batch_size
sampler = ONNXBatchSampler(dataset)
for i, sample in enumerate(sampler):
ref_sample = []
ref_target = []
Expand All @@ -61,9 +61,9 @@ def test_batch_sampler(batch_size):
@pytest.mark.parametrize("batch_size", (1, 2, 3))
def test_random_batch_sampler(batch_size):
np.random.seed(0)
dataloader = TestDataloader(DATASET_SAMPLES)
dataloader.batch_size = batch_size
sampler = ONNXRandomBatchSampler(dataloader)
dataset = TestDataset(DATASET_SAMPLES)
dataset.batch_size = batch_size
sampler = ONNXRandomBatchSampler(dataset)
random_permuated_indices = [0, 2, 1]
for i, sample in enumerate(sampler):
ref_sample = []
Expand Down
8 changes: 4 additions & 4 deletions tests/onnx/test_sanity_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
]


class TestDataloader(Dataset):
class TestDataset(Dataset):
def __init__(self, samples: List[Tuple[np.ndarray, int]]):
super().__init__(shuffle=False)
self.samples = samples
Expand All @@ -59,14 +59,14 @@ def __len__(self):
return 1


def mock_dataloader_creator(dataset_path, input_shape, batch_size, shuffle):
return TestDataloader([(np.zeros(input_shape[1:]), 0), ])
def mock_dataset_creator(dataset_path, input_shape, batch_size, shuffle):
return TestDataset([(np.zeros(input_shape[1:]), 0), ])


@pytest.mark.parametrize(("model, input_shape"),
zip(MODELS, INPUT_SHAPES))
@patch('examples.experimental.onnx.onnx_ptq_classification.create_imagenet_torch_dataset',
new=mock_dataloader_creator)
new=mock_dataset_creator)
def test_sanity_quantize_sample(tmp_path, model, input_shape):
model_name = str(model.__class__)
onnx_model_dir = str(TEST_ROOT.joinpath('onnx', 'data', 'models'))
Expand Down
6 changes: 3 additions & 3 deletions tests/onnx/test_statistics_aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from nncf.experimental.post_training.algorithms.quantization.min_max_quantization import RangeType

from tests.onnx.models import OneConvolutionalModel
from tests.onnx.test_samplers import TestDataloader
from tests.onnx.test_samplers import TestDataset

INPUT_SHAPE = [3, 10, 10]

Expand Down Expand Up @@ -59,7 +59,7 @@ def __init__(self, number_samples, activation_float_range, weight_float_range):
def test_statistics_aggregator(range_type, test_parameters):
model = OneConvolutionalModel().onnx_model

dataloader = TestDataloader(DATASET_SAMPLES)
dataset = TestDataset(DATASET_SAMPLES)
compression_builder = CompressionBuilder()

quantization = ONNXMinMaxQuantization(MinMaxQuantizationParameters(
Expand All @@ -68,7 +68,7 @@ def test_statistics_aggregator(range_type, test_parameters):
))

compression_builder.add_algorithm(quantization)
quantized_model = compression_builder.apply(model, dataloader)
quantized_model = compression_builder.apply(model, dataset)

onnx_graph = ONNXGraph(quantized_model)
num_q = 0
Expand Down

0 comments on commit 3826d8d

Please sign in to comment.