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

Method log

caffe2/python/experiment_util.py:81–113  ·  view source on GitHub ↗
(self, input_count, batch_count, additional_values)

Source from the content-addressed store, hash-verified

79 logging.getLogger("experiment_logger").info(str)
80
81 def log(self, input_count, batch_count, additional_values):
82 logdict = OrderedDict()
83 delta_t = time.time() - self.last_time
84 delta_count = input_count - self.last_input_count
85 self.last_time = time.time()
86 self.last_input_count = input_count
87
88 logdict['time_spent'] = delta_t
89 logdict['cumulative_time_spent'] = time.time() - self.start_time
90 logdict['input_count'] = delta_count
91 logdict['cumulative_input_count'] = input_count
92 logdict['cumulative_batch_count'] = batch_count
93 if delta_t > 0:
94 logdict['inputs_per_sec'] = delta_count / delta_t
95 else:
96 logdict['inputs_per_sec'] = 0.0
97
98 for k in sorted(additional_values.keys()):
99 logdict[k] = additional_values[k]
100
101 # Write the headers if they are not written yet
102 if self.headers is None:
103 self.headers = list(logdict.keys())
104 self.logstr(",".join(self.headers))
105
106 self.logstr(",".join(str(v) for v in logdict.values()))
107
108 for logger in self.external_loggers:
109 try:
110 logger.log(logdict)
111 except Exception as e:
112 logging.warning(
113 "Failed to call ExternalLogger: {}".format(e), e)

Callers

nothing calls this directly

Calls 8

logstrMethod · 0.95
listFunction · 0.85
warningMethod · 0.80
keysMethod · 0.45
joinMethod · 0.45
valuesMethod · 0.45
logMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected