Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize of_include_copy #5978

Merged
merged 24 commits into from
Aug 23, 2021
Merged

optimize of_include_copy #5978

merged 24 commits into from
Aug 23, 2021

Conversation

daquexian
Copy link
Contributor

@daquexian daquexian commented Aug 20, 2021

  1. 把拷贝第三方库头文件的操作移动到 prepare_oneflow_third_party 里,使得 -DTHIRD_PARTY=OFF 的时候不需要拷贝头文件
  2. 把一些 add_custom_target(总是运行)改为 add_custom_command(在 depends 改变时才运行)

效果:
-DTHIRD_PARTY=OFF 时,在没有文件被修改的情况下运行 ninja oneflow_py 的时间从 36s 降低到了 1s,修改了单个 cpp 文件时的编译时间从 72s 降低到 46s

Signed-off-by: daquexian <daquexian566@gmail.com>
@oneflow-ci-bot oneflow-ci-bot self-requested a review August 21, 2021 03:14
@oneflow-ci-bot oneflow-ci-bot requested review from oneflow-ci-bot and removed request for oneflow-ci-bot August 21, 2021 04:14
@daquexian
Copy link
Contributor Author

先不合并,还有进一步的优化

@github-actions
Copy link
Contributor

Speed stats:
GPU Name: GeForce GTX 1080 

PyTorch resnet50 time: 140.7ms (= 7036.8ms / 50, input_shape=[16, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 128.1ms (= 6403.4ms / 50, input_shape=[16, 3, 224, 224], backward is enabled)
Relative speed: 1.10 (= 140.7ms / 128.1ms)

PyTorch resnet50 time: 83.1ms (= 4154.8ms / 50, input_shape=[8, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 74.3ms (= 3714.8ms / 50, input_shape=[8, 3, 224, 224], backward is enabled)
Relative speed: 1.12 (= 83.1ms / 74.3ms)

PyTorch resnet50 time: 54.1ms (= 2706.6ms / 50, input_shape=[4, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 47.4ms (= 2372.3ms / 50, input_shape=[4, 3, 224, 224], backward is enabled)
Relative speed: 1.14 (= 54.1ms / 47.4ms)

PyTorch resnet50 time: 48.7ms (= 2435.0ms / 50, input_shape=[2, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 38.8ms (= 1938.5ms / 50, input_shape=[2, 3, 224, 224], backward is enabled)
Relative speed: 1.26 (= 48.7ms / 38.8ms)

PyTorch resnet50 time: 42.6ms (= 2129.5ms / 50, input_shape=[1, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 36.5ms (= 1823.7ms / 50, input_shape=[1, 3, 224, 224], backward is enabled)
Relative speed: 1.17 (= 42.6ms / 36.5ms)

@oneflow-ci-bot oneflow-ci-bot removed their request for review August 21, 2021 06:53
…_custom_target to add_custom_command so it will not always run

Signed-off-by: daquexian <daquexian566@gmail.com>
Signed-off-by: daquexian <daquexian566@gmail.com>
@@ -133,15 +115,23 @@ function(GENERATE_CFG_AND_PYBIND11_CPP SRCS HDRS PYBIND_SRCS ROOT_DIR)
list(APPEND PY_CFG_ARGS "--proto_file_path=${FIL}")
endforeach()

add_custom_target(
generate_py_cfg
add_custom_command(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

add_custom_target 总是 会运行,add_custom_command 只会在 DEPENDS 改变的时候运行

@@ -133,15 +115,23 @@ function(GENERATE_CFG_AND_PYBIND11_CPP SRCS HDRS PYBIND_SRCS ROOT_DIR)
list(APPEND PY_CFG_ARGS "--proto_file_path=${FIL}")
endforeach()

add_custom_target(
generate_py_cfg
Copy link
Contributor Author

Choose a reason for hiding this comment

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

不需要通过 target dependency 来触发命令,因为它的 OUTPUT(${${HDRS}} ${${SRCS}} ${${PYBIND_SRCS}})会被某个 target 所包含,编译那个 target 的时候会自动执行命令

Signed-off-by: daquexian <daquexian566@gmail.com>
@oneflow-ci-bot oneflow-ci-bot removed their request for review August 23, 2021 09:22
Signed-off-by: daquexian <daquexian566@gmail.com>
Signed-off-by: daquexian <daquexian566@gmail.com>
@github-actions
Copy link
Contributor

CI failed, removing label automerge

@daquexian daquexian removed the request for review from oneflow-ci-bot August 23, 2021 10:33
@oneflow-ci-bot oneflow-ci-bot self-requested a review August 23, 2021 10:36
@oneflow-ci-bot oneflow-ci-bot requested review from oneflow-ci-bot and removed request for oneflow-ci-bot August 23, 2021 10:50
Signed-off-by: daquexian <daquexian566@gmail.com>
@oneflow-ci-bot oneflow-ci-bot removed their request for review August 23, 2021 12:46
@oneflow-ci-bot oneflow-ci-bot requested review from oneflow-ci-bot and removed request for oneflow-ci-bot August 23, 2021 12:56
Signed-off-by: daquexian <daquexian566@gmail.com>
Signed-off-by: daquexian <daquexian566@gmail.com>
@oneflow-ci-bot oneflow-ci-bot removed their request for review August 23, 2021 14:05
@oneflow-ci-bot oneflow-ci-bot requested review from oneflow-ci-bot and removed request for oneflow-ci-bot August 23, 2021 14:06
…rd party

Signed-off-by: daquexian <daquexian566@gmail.com>
@github-actions
Copy link
Contributor

Speed stats:
GPU Name: GeForce GTX 1080 

PyTorch resnet50 time: 140.2ms (= 7009.5ms / 50, input_shape=[16, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 128.6ms (= 6428.5ms / 50, input_shape=[16, 3, 224, 224], backward is enabled)
Relative speed: 1.09 (= 140.2ms / 128.6ms)

PyTorch resnet50 time: 84.3ms (= 4214.2ms / 50, input_shape=[8, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 74.7ms (= 3736.0ms / 50, input_shape=[8, 3, 224, 224], backward is enabled)
Relative speed: 1.13 (= 84.3ms / 74.7ms)

PyTorch resnet50 time: 59.1ms (= 2956.0ms / 50, input_shape=[4, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 47.8ms (= 2392.5ms / 50, input_shape=[4, 3, 224, 224], backward is enabled)
Relative speed: 1.24 (= 59.1ms / 47.8ms)

PyTorch resnet50 time: 48.9ms (= 2446.5ms / 50, input_shape=[2, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 41.3ms (= 2067.4ms / 50, input_shape=[2, 3, 224, 224], backward is enabled)
Relative speed: 1.18 (= 48.9ms / 41.3ms)

PyTorch resnet50 time: 42.7ms (= 2133.6ms / 50, input_shape=[1, 3, 224, 224], backward is enabled)
OneFlow resnet50 time: 37.3ms (= 1862.7ms / 50, input_shape=[1, 3, 224, 224], backward is enabled)
Relative speed: 1.15 (= 42.7ms / 37.3ms)

@oneflow-ci-bot oneflow-ci-bot merged commit bf61140 into master Aug 23, 2021
@oneflow-ci-bot oneflow-ci-bot deleted the optimize_of_include_copy branch August 23, 2021 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants