MCPcopy Create free account
hub / github.com/pytorch/pytorch / _ScriptProfileColumn

Class _ScriptProfileColumn

torch/jit/_script.py:1581–1606  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1579
1580
1581class _ScriptProfileColumn:
1582 def __init__(self, header: str, alignment: int = 4, offset: int = 0):
1583 self.header = header
1584 self.alignment = alignment
1585 self.offset = offset
1586 self.rows: Dict[int, Any] = {}
1587
1588 def add_row(self, lineno: int, value: Any):
1589 self.rows[lineno] = value
1590
1591 def materialize(self):
1592 max_length = len(self.header)
1593 rows: List[Tuple[int, str]] = []
1594 for key, value in self.rows.items():
1595 cell = str(value)
1596 rows.append((key, cell))
1597 max_length = max(len(cell), max_length)
1598
1599 if self.alignment > 0:
1600 padding = max_length + self.alignment
1601 padding -= padding % self.alignment
1602 else:
1603 padding = 0
1604
1605 rows = [(key, pad(cell, padding, self.offset)) for key, cell in rows]
1606 return pad(self.header, padding, self.offset), rows
1607
1608
1609class _ScriptProfileTable:

Callers 1

dump_stringMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…