Skip to content

Speedup DenseOps compilation #25

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

Merged
merged 5 commits into from
May 26, 2020
Merged

Speedup DenseOps compilation #25

merged 5 commits into from
May 26, 2020

Conversation

pinzhenx
Copy link
Contributor

@pinzhenx pinzhenx commented May 25, 2020

This PR follows the same approach as what pytorch has done for VariableType.cpp, to split the all-in-one DenseOps.cpp into 8 shards, called DenseOps_0.cpp ... DenseOps_7.cpp.

We've removed RegisterIpexDenseOPs() and all occurrences of _initialize_aten_bindings(), since we could register ops in global space while keep its internal linkage. This way, we don't have to worry about multiple calls to the RegisterIpexDenseOPs.

Before:

void RegisterIpexDenseOPs() {
  static auto dispatch = torch::RegisterOperators()
    .op(torch::RegisterOperators::options().schema("aten::__and__.Scalar(Tensor self, Scalar other) -> Tensor")
      .impl_unboxedOnlyKernel<at::Tensor(const at::Tensor &, at::Scalar), &AtenIpexCPUDefault::__and__>(at::DispatchKey::DPCPPTensorId)
      .aliasAnalysis(c10::AliasAnalysisKind::FROM_SCHEMA));
}

After:

namespace {
  static auto dispatch = torch::RegisterOperators()
    .op(torch::RegisterOperators::options().schema("aten::__and__.Tensor(Tensor self, Tensor other) -> Tensor")
      .impl_unboxedOnlyKernel<at::Tensor(const at::Tensor &, const at::Tensor &), &AtenIpexCPUDefault::__and__>(at::DispatchKey::DPCPPTensorId)
      .aliasAnalysis(c10::AliasAnalysisKind::FROM_SCHEMA));
}

After checkout this branch, you have to run python setup.py clean first.

@pinzhenx
Copy link
Contributor Author

@EikanWang

@pinzhenx pinzhenx marked this pull request as draft May 25, 2020 07:26
@pinzhenx pinzhenx marked this pull request as ready for review May 25, 2020 07:47
@pinzhenx pinzhenx force-pushed the speedup branch 3 times, most recently from e560e6b to 7a37427 Compare May 26, 2020 01:58
@EikanWang EikanWang merged commit 101fb32 into intel:master May 26, 2020
import _torch_ipex as core

core._initialize_aten_bindings()
import _torch_ipex as core
Copy link
Contributor

Choose a reason for hiding this comment

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

better integrate these two packages into one, so that end user only needs to import one package.

JianpingChen066 pushed a commit to JianpingChen066/intel-extension-for-pytorch that referenced this pull request May 26, 2020
* rm usages of _initialize_aten_bindings

* allow user to build with ninja

* skip writing unchanged file

* move gen_code out of cleaning procedure

* split denseops translation unit
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.

3 participants