我正在尝试了解在我的input_fn
中与tf.data.Dataset
相关的瓶颈问题,因此我想使用tf.profiler
,但它只显示迭代器操作。如何让分析工具输出我的Dataset管道中相关的操作呢?
示例
dataset = input_fn()
iterator = dataset.make_one_shot_iterator()
minibatch = iterator.get_next()
run_metadata = tf.RunMetadata()
with tf.Session() as session:
features, labels = session.run(minibatch,
options=tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE),
run_metadata=run_metadata)
tf.profiler.advise(tf.get_default_graph(), run_metadata)
输出:
checkers {
key: "AcceleratorUtilizationChecker"
value {
}
}
checkers {
key: "ExpensiveOperationChecker"
value {
reports: "top 1 operation type: IteratorGetNext, cpu: 79.89sec, accelerator: 0us, total: 79.89sec (99.96%)\ntop 2 operation type: OneShotIterator, cpu: 27.92ms, accelerator: 0us, total: 27.92ms (0.03%)\ntop 3 operation type: _retval_IteratorGetNext_3_3, cpu: 57us, accelerator: 0us, total: 57us (0.00%)"
reports: "top 1 graph node: IteratorGetNext, cpu: 79.89sec, accelerator: 0us, total: 79.89sec\ntop 2 graph node: OneShotIterator, cpu: 27.92ms, accelerator: 0us, total: 27.92ms"
reports: "<ipython-input-2-c5f67ba0356f>:49:<module>, cpu: 79.89sec, accelerator: 0us, total: 79.89sec\n<ipython-input-2-c5f67ba0356f>:48:<module>, cpu: 27.92ms, accelerator: 0us, total: 27.92ms"
}
}
checkers {
key: "OperationChecker"
value {
}
}