提交 d0440800 编写于 作者: L liangyongxiong

Drop histogram steps if original_buckets_count is too large.

上级 f78d7f6d
...@@ -72,6 +72,10 @@ class Bucket: ...@@ -72,6 +72,10 @@ class Bucket:
class HistogramContainer: class HistogramContainer:
# Max quantity of original buckets.
MAX_ORIGINAL_BUCKETS_COUNT = 90
""" """
Histogram data container. Histogram data container.
...@@ -114,6 +118,11 @@ class HistogramContainer: ...@@ -114,6 +118,11 @@ class HistogramContainer:
"""Gets original proto message.""" """Gets original proto message."""
return self._msg return self._msg
@property
def original_buckets_count(self):
"""Gets original buckets quantity."""
return len(self._original_buckets)
def set_visual_range(self, max_val: float, min_val: float, bins: int) -> None: def set_visual_range(self, max_val: float, min_val: float, bins: int) -> None:
""" """
Sets visual range for later re-sampling. Sets visual range for later re-sampling.
......
...@@ -239,6 +239,11 @@ class MSDataLoader: ...@@ -239,6 +239,11 @@ class MSDataLoader:
if value.HasField('histogram'): if value.HasField('histogram'):
histogram_msg = HistogramContainer(value.histogram) histogram_msg = HistogramContainer(value.histogram)
# Drop steps if original_buckets_count exceeds HistogramContainer.MAX_ORIGINAL_BUCKETS_COUNT
# to avoid time-consuming re-sample process.
if histogram_msg.original_buckets_count > HistogramContainer.MAX_ORIGINAL_BUCKETS_COUNT:
logger.warning('original_buckets_count exceeds HistogramContainer.MAX_ORIGINAL_BUCKETS_COUNT')
else:
tag = '{}/{}'.format(value.tag, PluginNameEnum.HISTOGRAM.value) tag = '{}/{}'.format(value.tag, PluginNameEnum.HISTOGRAM.value)
tensor_event = TensorEvent(wall_time=event.wall_time, tensor_event = TensorEvent(wall_time=event.wall_time,
step=event.step, step=event.step,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册