Ejemplo n.º 1
0
def advise(graph, run_meta=None, options=_DEFAULT_ADVISE_OPTIONS):
    """Auto profile and advise.

    Builds profiles and automatically check anomalies of various
    aspects. For more details:
    https://github.com/tensorflow/tensorflow/tree/master/tensorflow/core/profiler/README.md

  Args:
    graph: required tf.Graph.
    run_meta: optional tensorflow.RunMetadata proto. It is necessary to
        to support run time information profiling, such as time and memory.
    options: see ALL_ADVICE example above. Default checks everything.
  Returns:
    Returns AdviceProto proto
  """
    if options == _DEFAULT_ADVISE_OPTIONS:
        options = ALL_ADVICE.copy()

    # pylint: disable=protected-access
    op_log = tfprof_logger._merge_default_with_oplog(graph,
                                                     None,
                                                     run_meta,
                                                     add_trace=True)
    # pylint: enable=protected-access

    run_meta_str = run_meta.SerializeToString() if run_meta else b''

    opts = _build_advisor_options(options)
    ret = tfprof_output_pb2.AdviceProto()
    ret.ParseFromString(
        print_mdl.PrintModelAnalysis(
            graph.as_graph_def(add_shapes=True).SerializeToString(),
            run_meta_str, op_log.SerializeToString(), 'advise'.encode('utf-8'),
            opts.SerializeToString()))
    return ret
Ejemplo n.º 2
0
  def advise(self, options):
    """Automatically detect problems and generate reports.

    Args:
      options: A dict of options. See ALL_ADVICE example above.
    Returns:
      A Advise proto that conains the reports from all checkers.
    """
    advise_pb = tfprof_output_pb2.AdviceProto()
    opts = _build_advisor_options(options)
    advise_pb.ParseFromString(
        print_mdl.Profile('advise'.encode('utf-8'), opts.SerializeToString()))
    return advise_pb