|
@@ -72,7 +72,7 @@ class OprProfRst: |
|
|
of corresponding operations""" |
|
|
of corresponding operations""" |
|
|
|
|
|
|
|
|
def __init__(self, entry: dict): |
|
|
def __init__(self, entry: dict): |
|
|
"""Opr profiling init, setup name, id, type of opr_info. |
|
|
|
|
|
|
|
|
"""Opr profiling initialization, which sets up name, type and id of opr_info. |
|
|
|
|
|
|
|
|
:param entry: profiling json exec_graph items |
|
|
:param entry: profiling json exec_graph items |
|
|
""" |
|
|
""" |
|
@@ -84,7 +84,7 @@ class OprProfRst: |
|
|
self.footprint = collections.defaultdict(NonExistNum) |
|
|
self.footprint = collections.defaultdict(NonExistNum) |
|
|
|
|
|
|
|
|
def update_device_prof_info(self, dev_time: dict): |
|
|
def update_device_prof_info(self, dev_time: dict): |
|
|
"""Update device prof info |
|
|
|
|
|
|
|
|
"""Updates device profiling info |
|
|
|
|
|
|
|
|
:param dev_time: device time for single opr, |
|
|
:param dev_time: device time for single opr, |
|
|
is an attribute of profiling result. |
|
|
is an attribute of profiling result. |
|
@@ -93,7 +93,7 @@ class OprProfRst: |
|
|
self.time_dict["device"].append(copy.deepcopy(dev_time)) |
|
|
self.time_dict["device"].append(copy.deepcopy(dev_time)) |
|
|
|
|
|
|
|
|
def update_host_prof_info(self, host_time: dict): |
|
|
def update_host_prof_info(self, host_time: dict): |
|
|
"""Update host profiling info |
|
|
|
|
|
|
|
|
"""Updates host profiling info |
|
|
|
|
|
|
|
|
:param host_time: host time for single opr, |
|
|
:param host_time: host time for single opr, |
|
|
is an attribute of profiling result. |
|
|
is an attribute of profiling result. |
|
@@ -102,7 +102,7 @@ class OprProfRst: |
|
|
self.time_dict["host"].append(copy.deepcopy(host_time)) |
|
|
self.time_dict["host"].append(copy.deepcopy(host_time)) |
|
|
|
|
|
|
|
|
def update_footprint(self, footprint: dict): |
|
|
def update_footprint(self, footprint: dict): |
|
|
"""Update opr footprint |
|
|
|
|
|
|
|
|
"""Updates opr footprint |
|
|
|
|
|
|
|
|
:param footprint: footprint for single opr, |
|
|
:param footprint: footprint for single opr, |
|
|
is an attribute of profiling result. |
|
|
is an attribute of profiling result. |
|
@@ -128,7 +128,7 @@ class Record: |
|
|
] |
|
|
] |
|
|
|
|
|
|
|
|
def __init__(self, time: float, info: dict, footprint: dict): |
|
|
def __init__(self, time: float, info: dict, footprint: dict): |
|
|
"""Init single record |
|
|
|
|
|
|
|
|
"""Initializes single record |
|
|
|
|
|
|
|
|
:param time: opr running time, evaluated by applying users providing |
|
|
:param time: opr running time, evaluated by applying users providing |
|
|
function to OprProfRst. |
|
|
function to OprProfRst. |
|
@@ -153,7 +153,7 @@ class Record: |
|
|
self.opr_id = int(self.opr_id) |
|
|
self.opr_id = int(self.opr_id) |
|
|
|
|
|
|
|
|
def get_column_by_name(self, name: str = None): |
|
|
def get_column_by_name(self, name: str = None): |
|
|
"""extract column value by its column name |
|
|
|
|
|
|
|
|
"""extracts column value by its column name |
|
|
|
|
|
|
|
|
:param name: column name, None for time. |
|
|
:param name: column name, None for time. |
|
|
""" |
|
|
""" |
|
@@ -165,7 +165,7 @@ class Record: |
|
|
|
|
|
|
|
|
class ProfileAnalyzer: |
|
|
class ProfileAnalyzer: |
|
|
def __init__(self, obj: dict, opr_filter: Callable = lambda opr, inp, out: True): |
|
|
def __init__(self, obj: dict, opr_filter: Callable = lambda opr, inp, out: True): |
|
|
"""initialize ProfileAnalyzer |
|
|
|
|
|
|
|
|
"""Initializes ProfileAnalyzer |
|
|
|
|
|
|
|
|
:param obj: dict dumped from json str. |
|
|
:param obj: dict dumped from json str. |
|
|
:param opr_filter: function that filter oprs. |
|
|
:param opr_filter: function that filter oprs. |
|
@@ -202,12 +202,12 @@ class ProfileAnalyzer: |
|
|
def _aggregate( |
|
|
def _aggregate( |
|
|
self, records: List[Record], aop: Union[str, Callable], atype: Optional[str] |
|
|
self, records: List[Record], aop: Union[str, Callable], atype: Optional[str] |
|
|
) -> List[Record]: |
|
|
) -> List[Record]: |
|
|
"""aggragate operation |
|
|
|
|
|
|
|
|
"""Aggregate operation |
|
|
|
|
|
|
|
|
:param records: records that selected: |
|
|
|
|
|
:param aop: aggragate operation, if aop is str, we would replace it |
|
|
|
|
|
|
|
|
:param records: selected records |
|
|
|
|
|
:param aop: aggregate operation, if aop is str, we would replace it |
|
|
with associated numpy function wth aop name" |
|
|
with associated numpy function wth aop name" |
|
|
:param atype: the type aggragte by, None for aggragte all into single |
|
|
|
|
|
|
|
|
:param atype: the type aggregated by, None for aggregating all into single |
|
|
record. |
|
|
record. |
|
|
""" |
|
|
""" |
|
|
if aop is None: |
|
|
if aop is None: |
|
@@ -304,7 +304,7 @@ class TimeFuncHelper: |
|
|
|
|
|
|
|
|
@staticmethod |
|
|
@staticmethod |
|
|
def _eval_time(prof_type, end_key, func, opr_prof): |
|
|
def _eval_time(prof_type, end_key, func, opr_prof): |
|
|
"""eval time |
|
|
|
|
|
|
|
|
"""Eval time |
|
|
|
|
|
|
|
|
:type prof_type: str |
|
|
:type prof_type: str |
|
|
:param prof_type: 'host' or 'device' |
|
|
:param prof_type: 'host' or 'device' |
|
@@ -338,7 +338,7 @@ class TimeFuncHelper: |
|
|
def _min_start( |
|
|
def _min_start( |
|
|
prof_type, end_key, func, opr_prof |
|
|
prof_type, end_key, func, opr_prof |
|
|
): # pylint: disable=unused-argument |
|
|
): # pylint: disable=unused-argument |
|
|
"""eval time |
|
|
|
|
|
|
|
|
"""Eval minimum start time |
|
|
|
|
|
|
|
|
:type prof_type: str |
|
|
:type prof_type: str |
|
|
:param prof_type: 'host' or 'device' |
|
|
:param prof_type: 'host' or 'device' |
|
@@ -360,7 +360,7 @@ class TimeFuncHelper: |
|
|
def min_start_func( |
|
|
def min_start_func( |
|
|
prof_type: str, end_key: str, func: Callable |
|
|
prof_type: str, end_key: str, func: Callable |
|
|
) -> float: # pylint: disable=unused-argument |
|
|
) -> float: # pylint: disable=unused-argument |
|
|
"""Eval oprerator profile time with ``np.min``. |
|
|
|
|
|
|
|
|
"""Eval oprerator profile min start time |
|
|
|
|
|
|
|
|
:param prof_type: 'host' or 'device' |
|
|
:param prof_type: 'host' or 'device' |
|
|
:param end_key: 'kern' or 'end' |
|
|
:param end_key: 'kern' or 'end' |
|
@@ -371,7 +371,7 @@ class TimeFuncHelper: |
|
|
|
|
|
|
|
|
@staticmethod |
|
|
@staticmethod |
|
|
def _max_end(prof_type, end_key, func, opr_prof): # pylint: disable=unused-argument |
|
|
def _max_end(prof_type, end_key, func, opr_prof): # pylint: disable=unused-argument |
|
|
"""eval time |
|
|
|
|
|
|
|
|
"""Eval maximum end time |
|
|
|
|
|
|
|
|
:type prof_type: str |
|
|
:type prof_type: str |
|
|
:param prof_type: 'host' or 'device' |
|
|
:param prof_type: 'host' or 'device' |
|
@@ -391,7 +391,7 @@ class TimeFuncHelper: |
|
|
|
|
|
|
|
|
@staticmethod |
|
|
@staticmethod |
|
|
def max_end_func(prof_type: str, end_key: str, func: Callable) -> float: |
|
|
def max_end_func(prof_type: str, end_key: str, func: Callable) -> float: |
|
|
"""Eval max end time |
|
|
|
|
|
|
|
|
"""Eval oprerator profile max end time |
|
|
|
|
|
|
|
|
:param prof_type: 'host' or 'device' |
|
|
:param prof_type: 'host' or 'device' |
|
|
:param end_key: 'kern' or 'end' |
|
|
:param end_key: 'kern' or 'end' |
|
|