profile.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:seq2seq 作者: google 项目源码 文件源码
def merge_default_with_oplog(graph, op_log=None, run_meta=None):
  """Monkeypatch. There currently is a bug in tfprof_logger that
    prevents it from being used with Python 3. So we override the method
    manually until the fix comes in.
  """
  tmp_op_log = tfprof_log_pb2.OpLog()
  # pylint: disable=W0212
  logged_ops = tfprof_logger._get_logged_ops(graph, run_meta)
  if not op_log:
    tmp_op_log.log_entries.extend(logged_ops.values())
  else:
    all_ops = dict()
    for entry in op_log.log_entries:
      all_ops[entry.name] = entry
    for op_name, entry in six.iteritems(logged_ops):
      if op_name in all_ops:
        all_ops[op_name].types.extend(entry.types)
        if entry.float_ops > 0 and all_ops[op_name].float_ops == 0:
          all_ops[op_name].float_ops = entry.float_ops
      else:
        all_ops[op_name] = entry
    tmp_op_log.log_entries.extend(all_ops.values())
  return tmp_op_log
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号