Skip to content

Conversation

Xreki
Copy link
Contributor

@Xreki Xreki commented Jun 11, 2020

修改resnet、mobilenet、seq2seq、ptb、transformer共5个模型的计时方式,使得每个模型会有一下计时信息输出:

  • batch_cost,为一个batch计算所需的总时间,包括读数据的时间
  • reader_cost,读数据的时间
  • epoch_cost,一个epoch的时间

这种计时方式得到的batch_cost和epoch_cost结论才是一致的。计时插入模式如下:

for epoch_id in range(num_epoches):
    epoch_start = time.time()
    ...
    batch_start = time.time()
    for XXX in data_loader():
        batch_reader_end = time.time()
        # network, backward, fetching
        ...
        train_batch_cost = time.time() - batch_start
        train_reader_cost = batch_reader_end - batch_start
        batch_start = time.time()
    train_epoch_cost = time.time() - epoch_start

另外,seq2seq中所有源码文件都有x权限,所以修改了文件的权限,并用pre-commit调了下格式。

说明和TODO:

  • ptb的数据全部都加载到内存里面了,没用DataLoader,但普通reader也不太耗时,所以没加reader计时。后续PR可以加上。
  • seq2seq也没用DataLoader,数据不确定是否在内存中,但reader_cost显示耗时也不多,后续可以再检查一下。
  • transformer没有打印reader_cost,因为log里面加reader_cost打印时出错,后续PR再加上。

@Xreki Xreki changed the title Polish the timing method and log of some dygraph models. [dygraph] Polish the timing method and log of some dygraph models. Jun 16, 2020
@Xreki Xreki requested review from phlrain and chenwhql June 16, 2020 08:33
Copy link
Contributor

@chenwhql chenwhql left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Xreki Xreki merged commit 5c6dded into PaddlePaddle:develop Jun 16, 2020
@Xreki Xreki deleted the dygraph/time branch June 16, 2020 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants