-
Notifications
You must be signed in to change notification settings - Fork 23.2k
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
Enable Conv fusion optimizations in optimizeForIdeep #9255
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for splitting it. Looks good overall. I have 2 minor comments regarding the interface.
caffe2/opt/converter.cc
Outdated
@@ -101,6 +101,14 @@ std::vector<int> getKernelShape(std::map<std::string, caffe2::Argument> argMap) | |||
return kernelShape; | |||
} | |||
|
|||
int getGroup(std::map<std::string, caffe2::Argument> argMap) { |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
caffe2/opt/optimize_ideep.cc
Outdated
} | ||
|
||
void OptimizeForIdeep(repr::NNModule* nn, caffe2::Workspace* ws, bool training_mode) { | ||
if (training_mode) { |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@yinghai any other concerns? |
There was a problem hiding this 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please clang-format your code.
caffe2/opt/optimize_ideep.cc
Outdated
return nullptr; | ||
} | ||
|
||
return dyn_cast<Caffe2Annotation>(annotation)->getOperatorDef(); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
caffe2/opt/optimize_ideep.cc
Outdated
return false; | ||
auto convOutput = repr::nn::getOutputs(convNode).front(); | ||
auto consumers = repr::nn::getConsumers(convOutput); | ||
// convOutput is NOT referenced by sequencial ops after BN. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
caffe2/opt/optimize_ideep.cc
Outdated
break; | ||
} | ||
} | ||
// Sum inputs should not be referenced by sequencial ops. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
caffe2/opt/converter.cc
Outdated
@@ -101,6 +101,14 @@ std::vector<int> getKernelShape(std::map<std::string, caffe2::Argument> argMap) | |||
return kernelShape; | |||
} | |||
|
|||
int getGroup(std::map<std::string, caffe2::Argument> argMap) { | |||
if (argMap.count("group")) { | |||
assert(argMap["group"].has_i() && "Invalid group argument"); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
caffe2/opt/converter.cc
Outdated
@@ -101,6 +101,14 @@ std::vector<int> getKernelShape(std::map<std::string, caffe2::Argument> argMap) | |||
return kernelShape; | |||
} | |||
|
|||
int getGroup(std::map<std::string, caffe2::Argument> argMap) { |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Signed-off-by: Gu, Jinghui <jinghui.gu@intel.com>
Signed-off-by: Gu, Jinghui <jinghui.gu@intel.com>
@yinghai |
Signed-off-by: Gu, Jinghui <jinghui.gu@intel.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's have a separate pass to fix the pass-by-value issue.
There was a problem hiding this 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.
@yinghai |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, Let's use CAFFE_ENFORCE
@@ -42,6 +42,14 @@ std::vector<int> getDilations(std::map<std::string, caffe2::Argument> argMap) { | |||
return dilations; | |||
} | |||
|
|||
int getGroup(std::map<std::string, caffe2::Argument>& argMap) { | |||
if (argMap.count("group")) { | |||
CAFFE_ENFORCE(argMap["group"].has_i() && "Invalid group argument"); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
caffe2/opt/optimize_ideep.cc
Outdated
|
||
Blob *getBlob(repr::NNGraph::NodeRef node, caffe2::Workspace *ws) { | ||
auto tensor = repr::nn::get<repr::Tensor>(node); | ||
assert(ws->HasBlob(tensor->getName()) && "Blob not in workspace"); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Signed-off-by: Gu, Jinghui <jinghui.gu@intel.com>
@yinghai |
There was a problem hiding this 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.
Summary: Enable fusion for IDEEP in optimizeForIdeep including Conv+ReLU, Conv+Sum, Conv+Sum+ReLU, Conv+BN Pull Request resolved: pytorch#9255 Reviewed By: bddppq Differential Revision: D8809030 Pulled By: yinghai fbshipit-source-id: af30bad3b96cb965bd26a4dfa810370faec4bb88
Summary: Enable fusion for IDEEP in optimizeForIdeep including Conv+ReLU, Conv+Sum, Conv+Sum+ReLU, Conv+BN Pull Request resolved: pytorch#9255 Reviewed By: bddppq Differential Revision: D8809030 Pulled By: yinghai fbshipit-source-id: af30bad3b96cb965bd26a4dfa810370faec4bb88
Summary: Enable fusion for IDEEP in optimizeForIdeep including Conv+ReLU, Conv+Sum, Conv+Sum+ReLU, Conv+BN Pull Request resolved: pytorch#9255 Reviewed By: bddppq Differential Revision: D8809030 Pulled By: yinghai fbshipit-source-id: af30bad3b96cb965bd26a4dfa810370faec4bb88
Enable fusion for IDEEP in optimizeForIdeep
including Conv+ReLU, Conv+Sum, Conv+Sum+ReLU, Conv+BN