From 940e1d20637c950f984f77ab6c1048c522632dea Mon Sep 17 00:00:00 2001 From: "Bobby R. Bruce" Date: Wed, 27 Mar 2024 10:01:21 -0700 Subject: [PATCH] stdlib: Fix PyStats Distribution to be vector of Scalars As Distribution inherits from Vector, it should be constructed with a Dictionary of scalars (in our implementation, a dictionary mapping the vector position's unique id for each bin and the value of that bin). Change-Id: Ie603c248e5db4b6dd7f71cc453eebd78793f69a3 --- src/python/m5/ext/pystats/statistic.py | 2 +- src/python/m5/stats/gem5stats.py | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/python/m5/ext/pystats/statistic.py b/src/python/m5/ext/pystats/statistic.py index 3fb4fc11f6..ebe24fbbca 100644 --- a/src/python/m5/ext/pystats/statistic.py +++ b/src/python/m5/ext/pystats/statistic.py @@ -164,7 +164,7 @@ class Distribution(Vector): def __init__( self, - value: Iterable[int], + value: Dict[Union[int, float], Scalar], min: Union[float, int], max: Union[float, int], num_bins: int, diff --git a/src/python/m5/stats/gem5stats.py b/src/python/m5/stats/gem5stats.py index 5e0d57ec15..bd17994a59 100644 --- a/src/python/m5/stats/gem5stats.py +++ b/src/python/m5/stats/gem5stats.py @@ -167,8 +167,16 @@ def __get_distribution(statistic: _m5.stats.DistInfo) -> Distribution: overflow = statistic.overflow logs = statistic.logs + parsed_values = {} + for index in range(len(value)): + parsed_values[index] = Scalar( + value=value[index], + unit=statistic.unit, + datatype=StorageType["f64"], + ) + return Distribution( - value=value, + value=parsed_values, min=min, max=max, num_bins=num_bins,