TensorFlow:dequeue_up_to 是否比 tf.train.batch 中的 dequeue_many 慢?

TensorFlow: Is dequeue_up_to slower than dequeue_many in tf.train.batch?

source code on GitHub, If I use allow_smaller_final_batch=True in train.batch, dequeue_up_to is used instead of dequeue_many for all batches. Is dequeue_up_to slower? I cannot find the source code for this somehow even after a search in the TensorFlow repository. I have traced the dequeue_many and dequeue_up_to functions up till this file here 中,但我找不到什么是 gen_data_flow_ops 及其功能,并且在 repo 中搜索只有 returns 导入 gen_data_flow_ops 结果。为什么会这样?

难以跟踪代码 Python 通过 C++ 操作的代码路径是 TensorFlow 操作包装技术的不幸结果。通常,C++ 实现被命名为 FooBarOp,而 Python 最终在生成的代码中调用 foo_bar。

在这种情况下 gen_data_flow_ops._queue_dequeue_up_to_v2 is an automatically generated Python wrapper for the registration of QueueDequeueUpToV2, which is an alias for the C++ DequeueUpToOp

为了回答您最初的问题,队列本身不太可能有任何显着的性能差异(出列的 UpTo 版本仅在队列关闭后才做一些不同的事情)。启用 allow_small_batch 将从图中删除一些静态形状信息(批量大小),但是,如果它们基于静态形状进行优化,这可能会使下游的一些操作变慢一点。