Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replace max calibration batches default value with None #216

Merged
merged 1 commit into from
Sep 9, 2022
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
2 changes: 1 addition & 1 deletion alonet/torch2trt/base_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def add_argparse_args(parent_parser):
parser.add_argument("--verbose", action="store_true", help="Helpful when debugging")
parser.add_argument("--profiling_verbosity", default=0, type=int, help="Helpful when profiling the engine (default: %(default)s)")
parser.add_argument("--calibration_batch_size", type=int, default=8, help="Calibration data batch size (default: %(default)s)")
parser.add_argument("--limit_calibration_batches", type=int, default=10, help="Limits number of batches (default: %(default)s)")
parser.add_argument("--limit_calibration_batches", type=int, default=None, help="Limits number of batches (default: %(default)s)")
parser.add_argument("--cache_file", type=str, default="calib.bin", help="Path to caliaration cache file (default: %(default)s)")
parser.add_argument(
"--calibrator",
Expand Down
10 changes: 5 additions & 5 deletions alonet/torch2trt/calibrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ class DataBatchStreamer:
>>> s_dataStreamer = DataBatchStreamer(dataset=s_calib)
>>> m_dataStreamer = DataBatchStreamer(dataset=m_calib)
"""
FTYPES = ["torch.Tensor", "ndarray", "aloscene.Frame"]

def __init__(
self,
dataset=None,
Expand All @@ -76,7 +74,8 @@ def __init__(
):
for sample in dataset[0]:
if not isinstance(sample, (torch.Tensor, np.ndarray, Frame)):
raise TypeError(f"unknown sample type, expected samples to be instance of {' or '.join(self.FTYPES)} got {sample.__class__.__name__} instead")
ftypes = ["torch.Tensor", "ndarray", "aloscene.Frame"]
raise TypeError(f"unknown sample type, expected samples to be instance of {' or '.join(ftypes)} got {sample.__class__.__name__} instead")

self.batch_idx = 0
self.dataset = dataset
Expand Down Expand Up @@ -105,7 +104,8 @@ def convert_frame(frame):
elif isinstance(frame, np.ndarray):
pass
else:
raise TypeError(f"Unknown sample type, expected samples to be instance of {' or '.join(self.FTYPES)} got {frame.__class__.__name__}.")
ftypes = ["torch.Tensor", "ndarray", "aloscene.Frame"]
raise TypeError(f"Unknown sample type, expected samples to be instance of {' or '.join(ftypes)} got {frame.__class__.__name__}.")
return frame

def next_(self):
Expand All @@ -127,7 +127,7 @@ def next_(self):
return None

def __len__(self):
return max_batch
return self.max_batch


class BaseCalibrator:
Expand Down