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

[Caffe2]Enable fusion for IDEEP in optimizeForIdeep #8105

Closed
wants to merge 7 commits into from

Conversation

gujinghui
Copy link
Collaborator

Enable fusion for IDEEP in optimizeForIdeep, including Conv+ReLU, Conv+Sum, Conv+Sum+ReLU, Conv+BN, and pre-convert filter format

@onnxbot onnxbot added the caffe2 label Jun 4, 2018
@gujinghui
Copy link
Collaborator Author

@yinghai
pls review

@@ -75,25 +73,10 @@ class IDEEPConvFusionOp final : public IDEEPConvPoolOpBase {
"*",
group_);

bool weights_changed =

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

@@ -36,21 +34,6 @@ class IDEEPConvOp final : public IDEEPConvPoolOpBase {
"*",
group_);

bool weights_changed =

This comment was marked as off-topic.

This comment was marked as off-topic.

// We only want to fuse for IDEEP convs
if (op->device_option().device_type() != DeviceType::IDEEP) {
return false;
bool fuseConvBNHelperForIdeep(repr::NNModule* nn, caffe2::Workspace* ws) {

This comment was marked as off-topic.

This comment was marked as off-topic.

}
}

void fuseConvSumForIdeep(repr::NNModule* nn, caffe2::Workspace* ws) {

This comment was marked as off-topic.

This comment was marked as off-topic.

}
}

void preConvertFiltersFormat(repr::NNModule* nn, caffe2::Workspace* ws) {

This comment was marked as off-topic.

This comment was marked as off-topic.

@gujinghui
Copy link
Collaborator Author

Add @jgong5

@@ -75,25 +73,10 @@ class IDEEPConvFusionOp final : public IDEEPConvPoolOpBase {
"*",
group_);

bool weights_changed =

This comment was marked as off-topic.

@@ -189,6 +190,34 @@ def test_convolution_sum_fusion(self, stride, pad, kernel, size,
print(S0.flatten())
print(np.max(np.abs(S1 - S0)))
self.assertTrue(False)

# Auto fusion for Conv + Sum
workspace.ResetWorkspace()

This comment was marked as off-topic.

This comment was marked as off-topic.

@gujinghui
Copy link
Collaborator Author

gujinghui commented Jun 8, 2018

hi @yinghai
Did you get our mail on this PR?
Could you give more suggestions?
Thanks.

@gujinghui
Copy link
Collaborator Author

gujinghui commented Jun 13, 2018

@yinghai new patch uploaded. pls help review.

@jgong5

@yinghai
Copy link
Contributor

yinghai commented Jun 13, 2018

@gujinghui Sorry for the late reply. I'm working on verifying the fix for group convolution and next item is to check the memory increase issue. I'll get back to this one once the above outstanding issues are resolved as this one is not a blocker to anything. Makes sense?

@jgong5
Copy link
Collaborator

jgong5 commented Jun 14, 2018

@yinghai Please let us know anything we can help to troubleshoot the memory footprint issue. I guess we can reproduce the problem with any model like ResNet-50, right?

@gujinghui
Copy link
Collaborator Author

@yinghai As @jgong5 said, perhaps we can work together to figure out what happen on memory consumption issue?

@yinghai
Copy link
Contributor

yinghai commented Jun 14, 2018

@jgong5 @gujinghui yeah, to start, just try resnet50 with ideep and mkl and check the difference.

@yinghai
Copy link
Contributor

yinghai commented Jun 15, 2018

@gujinghui Actually do you have mask RCNN case to run? That might repo the memory issue better.

gujinghui added 5 commits July 2, 2018 11:05
Signed-off-by: Gu, Jinghui <jinghui.gu@intel.com>
Signed-off-by: Gu, Jinghui <jinghui.gu@intel.com>
Signed-off-by: Gu, Jinghui <jinghui.gu@intel.com>
Use optimizeForIdeep to convert filter format, instead.

Signed-off-by: Gu, Jinghui <jinghui.gu@intel.com>
Signed-off-by: Gu, Jinghui <jinghui.gu@intel.com>
@gujinghui
Copy link
Collaborator Author

@yinghai
rebased. pls review

@@ -304,7 +304,7 @@ if (USE_MKL AND USE_IDEEP)

if (MKLDNN_INCLUDE_DIR)
list(APPEND IDEEP_INCLUDE_DIR ${MKLDNN_INCLUDE_DIR})
list(APPEND __ideep_looked_for ${MKLDNN_INCLUDE_DIR})
list(APPEND __ideep_looked_for MKLDNN_INCLUDE_DIR)

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

Copy link
Contributor

@yinghai yinghai left a comment

Choose a reason for hiding this comment

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

Thanks for pushing this. I have some comments that needs to be addressed. In addition, I think this PR is losing focus, as it is supposed to be transformation. However, I saw

  • Transformation
  • Fixes in group size and FC
  • Fixes in CMakefile

I suggest we split this PR into 3. Actually, let me take the CMakefile fix. And you can work on to split this into 2. Sounds good?

@@ -75,25 +73,10 @@ class IDEEPConvFusionOp final : public IDEEPConvPoolOpBase {
"*",
group_);

bool weights_changed =

This comment was marked as off-topic.

@@ -21,41 +19,23 @@ class IDEEPConvOp final : public IDEEPConvPoolOpBase {
const auto& X = Input(INPUT);
const auto& filter = Input(FILTER);
auto* Y = Output(OUTPUT);
auto Y_dims = CalcOutputDims(X, filter.get_dim(0));
auto grouped = filter.is_grouped() ? 1 : 0;
auto Y_dims = CalcOutputDims(

This comment was marked as off-topic.

This comment was marked as off-topic.

@@ -18,16 +20,39 @@ class IDEEPFullyConnectedOp final : public IDEEPOperator {
const auto& filter = Input(FILTER);
auto* Y = Output(OUTPUT);

auto newDims = [&](itensor::dims adims, size_t axis) {

This comment was marked as off-topic.

@@ -304,7 +304,7 @@ if (USE_MKL AND USE_IDEEP)

if (MKLDNN_INCLUDE_DIR)
list(APPEND IDEEP_INCLUDE_DIR ${MKLDNN_INCLUDE_DIR})
list(APPEND __ideep_looked_for ${MKLDNN_INCLUDE_DIR})
list(APPEND __ideep_looked_for MKLDNN_INCLUDE_DIR)

This comment was marked as off-topic.

@yinghai yinghai mentioned this pull request Jul 6, 2018
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@yinghai has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

facebook-github-bot pushed a commit that referenced this pull request Jul 6, 2018
Summary:
The reason is that we are referencing `__ideep_looked_for` here: https://github.com/pytorch/pytorch/blob/77484d91db052dfcfa22a38408349853b6246f8a/cmake/Modules/FindMKL.cmake#L350

This was first flushed out in #8105 and probably can help with #9024
Pull Request resolved: #9217

Reviewed By: houseroad

Differential Revision: D8754491

Pulled By: yinghai

fbshipit-source-id: 70aecc2d60684b9ea522403dc98a0a1a2c3db7e6
zdevito pushed a commit to zdevito/ATen that referenced this pull request Jul 6, 2018
Summary:
The reason is that we are referencing `__ideep_looked_for` here: https://github.com/pytorch/pytorch/blob/77484d91db052dfcfa22a38408349853b6246f8a/cmake/Modules/FindMKL.cmake#L350

This was first flushed out in pytorch/pytorch#8105 and probably can help with pytorch/pytorch#9024
Pull Request resolved: pytorch/pytorch#9217

Reviewed By: houseroad

Differential Revision: D8754491

Pulled By: yinghai

fbshipit-source-id: 70aecc2d60684b9ea522403dc98a0a1a2c3db7e6
@gujinghui
Copy link
Collaborator Author

gujinghui commented Jul 9, 2018

This PR is being split to 2.
Pls refer to #9255 on op fusion part.
Pls refer to #9488 on pre-convert filters part.

zdevito pushed a commit to zdevito/ATen that referenced this pull request Jul 13, 2018
Summary:
The reason is that we are referencing `__ideep_looked_for` here: https://github.com/pytorch/pytorch/blob/77484d91db052dfcfa22a38408349853b6246f8a/cmake/Modules/FindMKL.cmake#L350

This was first flushed out in pytorch/pytorch#8105 and probably can help with pytorch/pytorch#9024
Pull Request resolved: pytorch/pytorch#9217

Reviewed By: houseroad

Differential Revision: D8754491

Pulled By: yinghai

fbshipit-source-id: 70aecc2d60684b9ea522403dc98a0a1a2c3db7e6
@yinghai
Copy link
Contributor

yinghai commented Jul 17, 2018

@gujinghui Is this PR still relevant? If yes, could you rebase on master?

@gujinghui
Copy link
Collaborator Author

@yinghai This PR is not needed now. Will close it.

@gujinghui gujinghui closed this Jul 17, 2018
goodlux pushed a commit to goodlux/pytorch that referenced this pull request Aug 15, 2018
Summary:
The reason is that we are referencing `__ideep_looked_for` here: https://github.com/pytorch/pytorch/blob/77484d91db052dfcfa22a38408349853b6246f8a/cmake/Modules/FindMKL.cmake#L350

This was first flushed out in pytorch#8105 and probably can help with pytorch#9024
Pull Request resolved: pytorch#9217

Reviewed By: houseroad

Differential Revision: D8754491

Pulled By: yinghai

fbshipit-source-id: 70aecc2d60684b9ea522403dc98a0a1a2c3db7e6
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.

6 participants