def _get_dump_file_path(dump_root, device_name, debug_node_name): """Get the file path of the dump file for a debug node. Args: dump_root: (str) Root dump directory. device_name: (str) Name of the device that the debug node resides on. debug_node_name: (str) Name of the debug node, e.g., cross_entropy/Log:0:DebugIdentity. Returns: (str) Full path of the dump file. """ dump_root = os.path.join( dump_root, debug_data.device_name_to_device_path(device_name)) if "/" in debug_node_name: dump_dir = os.path.join(dump_root, os.path.dirname(debug_node_name)) dump_file_name = re.sub(":", "_", os.path.basename(debug_node_name)) else: dump_dir = dump_root dump_file_name = re.sub(":", "_", debug_node_name) now_microsec = int(round(time.time() * 1000 * 1000)) dump_file_name += "_%d" % now_microsec return os.path.join(dump_dir, dump_file_name)
def _get_dump_file_path(dump_root, device_name, debug_node_name): """Get the file path of the dump file for a debug node. Args: dump_root: (str) Root dump directory. device_name: (str) Name of the device that the debug node resides on. debug_node_name: (str) Name of the debug node, e.g., cross_entropy/Log:0:DebugIdentity. Returns: (str) Full path of the dump file. """ dump_root = os.path.join( dump_root, debug_data.device_name_to_device_path(device_name)) if "/" in debug_node_name: dump_dir = os.path.join(dump_root, os.path.dirname(debug_node_name)) dump_file_name = re.sub(":", "_", os.path.basename(debug_node_name)) else: dump_dir = dump_root dump_file_name = re.sub(":", "_", debug_node_name) now_microsec = int(round(time.time() * 1000 * 1000)) dump_file_name += "_%d" % now_microsec return os.path.join(dump_dir, dump_file_name)
def _write_graph_def(self, graph_def, device_name, wall_time): encoded_graph_def = graph_def.SerializeToString() graph_hash = int(hashlib.md5(encoded_graph_def).hexdigest(), 16) event = event_pb2.Event(graph_def=encoded_graph_def, wall_time=wall_time) graph_file_path = os.path.join( self._dump_dir, debug_data.device_name_to_device_path(device_name), debug_data.METADATA_FILE_PREFIX + debug_data.GRAPH_FILE_TAG + debug_data.HASH_TAG + "%d_%d" % (graph_hash, wall_time)) self._try_makedirs(os.path.dirname(graph_file_path)) with open(graph_file_path, "wb") as f: f.write(event.SerializeToString())
def _write_graph_def(self, graph_def, device_name, wall_time): encoded_graph_def = graph_def.SerializeToString() graph_hash = int(hashlib.md5(encoded_graph_def).hexdigest(), 16) event = event_pb2.Event(graph_def=encoded_graph_def, wall_time=wall_time) graph_file_path = os.path.join( self._dump_dir, debug_data.device_name_to_device_path(device_name), debug_data.METADATA_FILE_PREFIX + debug_data.GRAPH_FILE_TAG + debug_data.HASH_TAG + "%d_%d" % (graph_hash, wall_time)) self._try_makedirs(os.path.dirname(graph_file_path)) with open(graph_file_path, "wb") as f: f.write(event.SerializeToString())
def testDeviceNameToDevicePath(self): self.assertEqual( debug_data.METADATA_FILE_PREFIX + debug_data.DEVICE_TAG + ",job_ps,replica_1,task_2,cpu_0", debug_data.device_name_to_device_path( "/job:ps/replica:1/task:2/cpu:0"))
def testDeviceNameToDevicePath(self): self.assertEqual( debug_data.METADATA_FILE_PREFIX + debug_data.DEVICE_TAG + ",job_ps,replica_1,task_2,cpu_0", debug_data.device_name_to_device_path("/job:ps/replica:1/task:2/cpu:0"))