Dump the memory state of the model and sub-models. Args: prefix (str, optional): The prefix to add to the layer names. Defaults to "". Returns: str: The memory state information.
(self, prefix: str = "")
| 138 | return current_node |
| 139 | |
| 140 | def dump(self, prefix: str = "") -> str: |
| 141 | """ |
| 142 | Dump the memory state of the model and sub-models. |
| 143 | |
| 144 | Args: |
| 145 | prefix (str, optional): The prefix to add to the layer names. Defaults to "". |
| 146 | |
| 147 | Returns: |
| 148 | str: The memory state information. |
| 149 | """ |
| 150 | cur_prefix = prefix + "." + self.layer_name if prefix != "" else self.layer_name |
| 151 | res = f"layer: {cur_prefix}, layer_mem: {self.layer_mem / mb:.2f} MB, total_mem: {self.total_mem / mb:.2f} MB\n" |
| 152 | |
| 153 | for sub_layer in self.sub_model_stats.values(): |
| 154 | res += sub_layer.dump(cur_prefix) |
| 155 | |
| 156 | return res |
| 157 | |
| 158 | def to_json(self, base: int = 1024 * 1024) -> dict: |
| 159 | """ |
no outgoing calls
no test coverage detected