Skip to content

Conversation

@ljk53
Copy link
Contributor

@ljk53 ljk53 commented Sep 5, 2019

Stack from ghstack:

Summary:
This is the first of a series of changes to reduce build size by cutting
autograd functions from mobile build.

When INTERN_DISABLE_AUTOGRAD is set:

  • On CMake side we exclude Functions.h/cpp, VariableType*.h/cpp,
    VariableTypeManual.cpp from the build process. Still keep variable_factories.h
    as we rely on it to create variables instead of tensors.
  • In source code we gate a couple autograd references (in autograd/variable.cpp)
    with C10_MOBILE (technically we should use a dedicated c macro but its
    maintenance cost is higher than cmake macro as we have several build systems
    to change).
  • Pass --disable-autograd flag to codegen script, which will stop generating
    Functions/VariableType code. And for variable_factories.h it will stop
    generating tracing code.

Edit: in this diff we will keep Functions.h/cpp to avoid changing source code.

Why we need this change if it's already not calling VariableType and autograd
stuff with USE_STATIC_DISPATCH=ON for mobile?
It's trying to reduce static library size for iOS build, for which it's
relatively harder to strip size with linker approach.

Why we need make involved change into codegen script?
There isn't a global config system in codegen - autograd/env.py provides similar
functionality but it says not adding anything there.

Test Plan:

  • will check CI;
  • test mobile build in sample app;

Pull Request resolved: #25697

Differential Revision: D17202733

…only library for mobile

Summary:
This is the first of a series of changes to reduce build size by cutting
autograd functions from mobile build.

Test Plan:
- will check CI;
- test mobile build in sample app;
@ljk53 ljk53 requested a review from apaszke as a code owner September 5, 2019 09:17
@pytorchbot pytorchbot added caffe2 module: autograd Related to torch.autograd, and the autograd engine in general module: build Build system issues module: internals Related to internal abstractions in c10 and ATen labels Sep 5, 2019
… inference only library for mobile"

Summary:
This is the first of a series of changes to reduce build size by cutting
autograd functions from mobile build.

Test Plan:
- will check CI;
- test mobile build in sample app;

Differential Revision: [D17202733](https://our.internmc.facebook.com/intern/diff/D17202733)
ljk53 added a commit that referenced this pull request Sep 5, 2019
…only library for mobile

Summary:
This is the first of a series of changes to reduce build size by cutting
autograd functions from mobile build.

Test Plan:
- will check CI;
- test mobile build in sample app;

ghstack-source-id: c8cb154
Pull Request resolved: #25697
… inference only library for mobile"


Summary:
This is the first of a series of changes to reduce build size by cutting
autograd functions from mobile build.

When INTERN_DISABLE_AUTOGRAD is set:
* On CMake side we exclude Functions.h/cpp, VariableType*.h/cpp, VariableTypeManual.cpp from the build process. Still keep variable_factories.h as we rely on it to create variables instead of tensors.
* In source code we gate a couple autograd references (in autograd/variable.cpp) with C10_MOBILE (technically we should use a dedicated c macro but its maintenance cost is higher than cmake macro as we have several build systems to change).
* Pass --disable-autograd flag to codegen script, which will stop generating Functions/VariableType code. And for variable_factories.h it will stop generating tracing code.

Why we need this change if it's already not calling VariableType and autograd stuff with USE_STATIC_DISPATCH=ON for mobile?
It's trying to reduce static library size for iOS build, for which it's relatively harder to strip size with linker approach.

Why we need make involved change into codegen script?
There isn't a global config system in codegen - autograd/env.py provides similar functionality but it says not adding anything there.

Test Plan:
- will check CI;
- test mobile build in sample app;

Differential Revision: [D17202733](https://our.internmc.facebook.com/intern/diff/D17202733)
ljk53 added a commit that referenced this pull request Sep 5, 2019
…only library for mobile

Summary:
This is the first of a series of changes to reduce build size by cutting
autograd functions from mobile build.

When INTERN_DISABLE_AUTOGRAD is set:
* On CMake side we exclude Functions.h/cpp, VariableType*.h/cpp, VariableTypeManual.cpp from the build process. Still keep variable_factories.h as we rely on it to create variables instead of tensors.
* In source code we gate a couple autograd references (in autograd/variable.cpp) with C10_MOBILE (technically we should use a dedicated c macro but its maintenance cost is higher than cmake macro as we have several build systems to change).
* Pass --disable-autograd flag to codegen script, which will stop generating Functions/VariableType code. And for variable_factories.h it will stop generating tracing code.

Why we need this change if it's already not calling VariableType and autograd stuff with USE_STATIC_DISPATCH=ON for mobile?
It's trying to reduce static library size for iOS build, for which it's relatively harder to strip size with linker approach.

Why we need make involved change into codegen script?
There isn't a global config system in codegen - autograd/env.py provides similar functionality but it says not adding anything there.

Test Plan:
- will check CI;
- test mobile build in sample app;

ghstack-source-id: 31317fc
Pull Request resolved: #25697
if (!diff_view_meta->grad_fn_ && !diff_view_meta->base_.requires_grad()) {
return diff_view_meta->grad_fn_;
}
#ifndef C10_MOBILE
Copy link
Contributor

Choose a reason for hiding this comment

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

as mentioned over chat, this part seems difficult to maintain.

The rest doesn't seem to be adding that much complexity, because we already expose AutoNonVariableType as part of the pseudo-public interface and you are just slicing along that border.

Copy link
Contributor

Choose a reason for hiding this comment

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

The reason this is commented out is, I assume, because of the direct reference to generated::AsStridedBackward? That doesn't seem too bad to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, generated::AsStridedBackward is the main blocker.
Ok, I updated the PR to keep the Functions.h/cpp for now to keep generated::AsStridedBackward and remove #if/#endif here.
In next PR I can update the codegen script to only generate this single function for mobile build - Does it sound better than the gating? @gchanan

@ezyang
Copy link
Contributor

ezyang commented Sep 5, 2019

It's trying to reduce static library size for iOS build, for which it's relatively harder to strip size with linker approach.

I wanted to claim that it should (morally) be possible to reduce the size of a static library by specifying what symbols you want to keep, and then doing a DCE with those symbols as roots. But I spent a while googling and it doesn't seem like this is a thing people actually do.

I want to confirm that the static library size for iOS is a cosmetic issue: in the end, you'll still end up with an executable of the same size--it's just that it looks bad if your static library looks big, is that right?

… inference only library for mobile"


Summary:
This is the first of a series of changes to reduce build size by cutting
autograd functions from mobile build.

When INTERN_DISABLE_AUTOGRAD is set:
* On CMake side we exclude Functions.h/cpp, VariableType*.h/cpp, VariableTypeManual.cpp from the build process. Still keep variable_factories.h as we rely on it to create variables instead of tensors.
* In source code we gate a couple autograd references (in autograd/variable.cpp) with C10_MOBILE (technically we should use a dedicated c macro but its maintenance cost is higher than cmake macro as we have several build systems to change).
* Pass --disable-autograd flag to codegen script, which will stop generating Functions/VariableType code. And for variable_factories.h it will stop generating tracing code.

Why we need this change if it's already not calling VariableType and autograd stuff with USE_STATIC_DISPATCH=ON for mobile?
It's trying to reduce static library size for iOS build, for which it's relatively harder to strip size with linker approach.

Why we need make involved change into codegen script?
There isn't a global config system in codegen - autograd/env.py provides similar functionality but it says not adding anything there.

Test Plan:
- will check CI;
- test mobile build in sample app;

Differential Revision: [D17202733](https://our.internmc.facebook.com/intern/diff/D17202733)
@ljk53
Copy link
Contributor Author

ljk53 commented Sep 6, 2019

I want to confirm that the static library size for iOS is a cosmetic issue: in the end, you'll still end up with an executable of the same size--it's just that it looks bad if your static library looks big, is that right?

Correct

… inference only library for mobile"


Summary:
This is the first of a series of changes to reduce build size by cutting
autograd functions from mobile build.

When INTERN_DISABLE_AUTOGRAD is set:
* On CMake side we exclude Functions.h/cpp, VariableType*.h/cpp, VariableTypeManual.cpp from the build process. Still keep variable_factories.h as we rely on it to create variables instead of tensors.
* In source code we gate a couple autograd references (in autograd/variable.cpp) with C10_MOBILE (technically we should use a dedicated c macro but its maintenance cost is higher than cmake macro as we have several build systems to change).
* Pass --disable-autograd flag to codegen script, which will stop generating Functions/VariableType code. And for variable_factories.h it will stop generating tracing code.

Why we need this change if it's already not calling VariableType and autograd stuff with USE_STATIC_DISPATCH=ON for mobile?
It's trying to reduce static library size for iOS build, for which it's relatively harder to strip size with linker approach.

Why we need make involved change into codegen script?
There isn't a global config system in codegen - autograd/env.py provides similar functionality but it says not adding anything there.

Test Plan:
- will check CI;
- test mobile build in sample app;

Differential Revision: [D17202733](https://our.internmc.facebook.com/intern/diff/D17202733)
@ljk53 ljk53 requested a review from gchanan September 6, 2019 07:15
… inference only library for mobile"

Summary:
This is the first of a series of changes to reduce build size by cutting
autograd functions from mobile build.

When INTERN_DISABLE_AUTOGRAD is set:
* On CMake side we exclude Functions.h/cpp, VariableType*.h/cpp,
  VariableTypeManual.cpp from the build process. Still keep variable_factories.h
  as we rely on it to create variables instead of tensors.
* In source code we gate a couple autograd references (in autograd/variable.cpp)
  with C10_MOBILE (technically we should use a dedicated c macro but its
  maintenance cost is higher than cmake macro as we have several build systems
  to change).
* Pass --disable-autograd flag to codegen script, which will stop generating
  Functions/VariableType code. And for variable_factories.h it will stop
  generating tracing code.

Edit: in this diff we will keep Functions.h/cpp to avoid changing source code.

Why we need this change if it's already not calling VariableType and autograd
stuff with USE_STATIC_DISPATCH=ON for mobile?
It's trying to reduce static library size for iOS build, for which it's
relatively harder to strip size with linker approach.

Why we need make involved change into codegen script?
There isn't a global config system in codegen - autograd/env.py provides similar
functionality but it says not adding anything there.

Test Plan:
- will check CI;
- test mobile build in sample app;

Pull Request resolved: #25697

Differential Revision: [D17202733](https://our.internmc.facebook.com/intern/diff/D17202733)
ljk53 added a commit that referenced this pull request Sep 6, 2019
…D flag to create inference only library for mobile"

Summary:
This is the first of a series of changes to reduce build size by cutting
autograd functions from mobile build.

When INTERN_DISABLE_AUTOGRAD is set:
* On CMake side we exclude Functions.h/cpp, VariableType*.h/cpp,
  VariableTypeManual.cpp from the build process. Still keep variable_factories.h
  as we rely on it to create variables instead of tensors.
* In source code we gate a couple autograd references (in autograd/variable.cpp)
  with C10_MOBILE (technically we should use a dedicated c macro but its
  maintenance cost is higher than cmake macro as we have several build systems
  to change).
* Pass --disable-autograd flag to codegen script, which will stop generating
  Functions/VariableType code. And for variable_factories.h it will stop
  generating tracing code.

Edit: in this diff we will keep Functions.h/cpp to avoid changing source code.

Why we need this change if it's already not calling VariableType and autograd
stuff with USE_STATIC_DISPATCH=ON for mobile?
It's trying to reduce static library size for iOS build, for which it's
relatively harder to strip size with linker approach.

Why we need make involved change into codegen script?
There isn't a global config system in codegen - autograd/env.py provides similar
functionality but it says not adding anything there.

Test Plan:
- will check CI;
- test mobile build in sample app;

Pull Request resolved: #25697

Differential Revision: [D17202733](https://our.internmc.facebook.com/intern/diff/D17202733)
ljk53 added a commit that referenced this pull request Sep 6, 2019
…only library for mobile

Summary:
This is the first of a series of changes to reduce build size by cutting
autograd functions from mobile build.

When INTERN_DISABLE_AUTOGRAD is set:
* On CMake side we exclude Functions.h/cpp, VariableType*.h/cpp,
  VariableTypeManual.cpp from the build process. Still keep variable_factories.h
  as we rely on it to create variables instead of tensors.
* In source code we gate a couple autograd references (in autograd/variable.cpp)
  with C10_MOBILE (technically we should use a dedicated c macro but its
  maintenance cost is higher than cmake macro as we have several build systems
  to change).
* Pass --disable-autograd flag to codegen script, which will stop generating
  Functions/VariableType code. And for variable_factories.h it will stop
  generating tracing code.

Edit: in this diff we will keep Functions.h/cpp to avoid changing source code.

Why we need this change if it's already not calling VariableType and autograd
stuff with USE_STATIC_DISPATCH=ON for mobile?
It's trying to reduce static library size for iOS build, for which it's
relatively harder to strip size with linker approach.

Why we need make involved change into codegen script?
There isn't a global config system in codegen - autograd/env.py provides similar
functionality but it says not adding anything there.

Test Plan:
- will check CI;
- test mobile build in sample app;

ghstack-source-id: 8f45c06
Pull Request resolved: #25697
ljk53 added a commit that referenced this pull request Sep 7, 2019
…D flag to create inference only library for mobile"

Summary:
This is the first of a series of changes to reduce build size by cutting
autograd functions from mobile build.

When INTERN_DISABLE_AUTOGRAD is set:
* On CMake side we exclude Functions.h/cpp, VariableType*.h/cpp,
  VariableTypeManual.cpp from the build process. Still keep variable_factories.h
  as we rely on it to create variables instead of tensors.
* In source code we gate a couple autograd references (in autograd/variable.cpp)
  with C10_MOBILE (technically we should use a dedicated c macro but its
  maintenance cost is higher than cmake macro as we have several build systems
  to change).
* Pass --disable-autograd flag to codegen script, which will stop generating
  Functions/VariableType code. And for variable_factories.h it will stop
  generating tracing code.

Edit: in this diff we will keep Functions.h/cpp to avoid changing source code.

Why we need this change if it's already not calling VariableType and autograd
stuff with USE_STATIC_DISPATCH=ON for mobile?
It's trying to reduce static library size for iOS build, for which it's
relatively harder to strip size with linker approach.

Why we need make involved change into codegen script?
There isn't a global config system in codegen - autograd/env.py provides similar
functionality but it says not adding anything there.

Test Plan:
- will check CI;
- test mobile build in sample app;

Pull Request resolved: #25697

Differential Revision: [D17202733](https://our.internmc.facebook.com/intern/diff/D17202733)
ljk53 added a commit that referenced this pull request Sep 7, 2019
…ad is set

Summary:
As discussed on PR #25697 - to remove autograd/functions.* without using
intrusive #if/#else we need whitelist "AsStridedBackward" used by variable.cpp.

Test Plan:
- builds and runs with stacked diffs

ghstack-source-id: 521f45d
Pull Request resolved: #25817

# Load deprecated signatures
deprecated = load_deprecated_signatures(
aten_decls, os.path.join(autograd_dir, 'deprecated.yaml'))
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh? Is this dead? Joyous day!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's still used by gen_autograd_python code path :)
load_deprecated_signatures() doesn't seem to have side-effect so I assume it's safe to delete since the result is not used here.

… inference only library for mobile"

Summary:
This is the first of a series of changes to reduce build size by cutting
autograd functions from mobile build.

When INTERN_DISABLE_AUTOGRAD is set:
* On CMake side we exclude Functions.h/cpp, VariableType*.h/cpp,
  VariableTypeManual.cpp from the build process. Still keep variable_factories.h
  as we rely on it to create variables instead of tensors.
* In source code we gate a couple autograd references (in autograd/variable.cpp)
  with C10_MOBILE (technically we should use a dedicated c macro but its
  maintenance cost is higher than cmake macro as we have several build systems
  to change).
* Pass --disable-autograd flag to codegen script, which will stop generating
  Functions/VariableType code. And for variable_factories.h it will stop
  generating tracing code.

Edit: in this diff we will keep Functions.h/cpp to avoid changing source code.

Why we need this change if it's already not calling VariableType and autograd
stuff with USE_STATIC_DISPATCH=ON for mobile?
It's trying to reduce static library size for iOS build, for which it's
relatively harder to strip size with linker approach.

Why we need make involved change into codegen script?
There isn't a global config system in codegen - autograd/env.py provides similar
functionality but it says not adding anything there.

Test Plan:
- will check CI;
- test mobile build in sample app;

Pull Request resolved: #25697

Differential Revision: [D17202733](https://our.internmc.facebook.com/intern/diff/D17202733)
ljk53 added a commit that referenced this pull request Sep 10, 2019
…D flag to create inference only library for mobile"

Summary:
This is the first of a series of changes to reduce build size by cutting
autograd functions from mobile build.

When INTERN_DISABLE_AUTOGRAD is set:
* On CMake side we exclude Functions.h/cpp, VariableType*.h/cpp,
  VariableTypeManual.cpp from the build process. Still keep variable_factories.h
  as we rely on it to create variables instead of tensors.
* In source code we gate a couple autograd references (in autograd/variable.cpp)
  with C10_MOBILE (technically we should use a dedicated c macro but its
  maintenance cost is higher than cmake macro as we have several build systems
  to change).
* Pass --disable-autograd flag to codegen script, which will stop generating
  Functions/VariableType code. And for variable_factories.h it will stop
  generating tracing code.

Edit: in this diff we will keep Functions.h/cpp to avoid changing source code.

Why we need this change if it's already not calling VariableType and autograd
stuff with USE_STATIC_DISPATCH=ON for mobile?
It's trying to reduce static library size for iOS build, for which it's
relatively harder to strip size with linker approach.

Why we need make involved change into codegen script?
There isn't a global config system in codegen - autograd/env.py provides similar
functionality but it says not adding anything there.

Test Plan:
- will check CI;
- test mobile build in sample app;

Pull Request resolved: #25697

Differential Revision: [D17202733](https://our.internmc.facebook.com/intern/diff/D17202733)
ljk53 added a commit that referenced this pull request Sep 10, 2019
…able_autograd is set"

Summary:
As discussed on PR #25697 - to remove autograd/functions.* without using
intrusive #if/#else we need whitelist "AsStridedBackward" used by variable.cpp.

Test Plan:
- builds and runs with stacked diffs

Pull Request resolved: #25817

Differential Revision: [D17247235](https://our.internmc.facebook.com/intern/diff/D17247235)
ljk53 added a commit that referenced this pull request Sep 10, 2019
…able_autograd is set"

Summary:
As discussed on PR #25697 - to remove autograd/functions.* without using
intrusive #if/#else we need whitelist "AsStridedBackward" used by variable.cpp.

Test Plan:
- builds and runs with stacked diffs

Pull Request resolved: #25817

Differential Revision: [D17247235](https://our.internmc.facebook.com/intern/diff/D17247235)
… inference only library for mobile"

Summary:
This is the first of a series of changes to reduce build size by cutting
autograd functions from mobile build.

When INTERN_DISABLE_AUTOGRAD is set:
* On CMake side we exclude Functions.h/cpp, VariableType*.h/cpp,
  VariableTypeManual.cpp from the build process. Still keep variable_factories.h
  as we rely on it to create variables instead of tensors.
* In source code we gate a couple autograd references (in autograd/variable.cpp)
  with C10_MOBILE (technically we should use a dedicated c macro but its
  maintenance cost is higher than cmake macro as we have several build systems
  to change).
* Pass --disable-autograd flag to codegen script, which will stop generating
  Functions/VariableType code. And for variable_factories.h it will stop
  generating tracing code.

Edit: in this diff we will keep Functions.h/cpp to avoid changing source code.

Why we need this change if it's already not calling VariableType and autograd
stuff with USE_STATIC_DISPATCH=ON for mobile?
It's trying to reduce static library size for iOS build, for which it's
relatively harder to strip size with linker approach.

Why we need make involved change into codegen script?
There isn't a global config system in codegen - autograd/env.py provides similar
functionality but it says not adding anything there.

Test Plan:
- will check CI;
- test mobile build in sample app;

Pull Request resolved: #25697

Differential Revision: [D17202733](https://our.internmc.facebook.com/intern/diff/D17202733)
ljk53 added a commit that referenced this pull request Sep 10, 2019
…D flag to create inference only library for mobile"

Summary:
This is the first of a series of changes to reduce build size by cutting
autograd functions from mobile build.

When INTERN_DISABLE_AUTOGRAD is set:
* On CMake side we exclude Functions.h/cpp, VariableType*.h/cpp,
  VariableTypeManual.cpp from the build process. Still keep variable_factories.h
  as we rely on it to create variables instead of tensors.
* In source code we gate a couple autograd references (in autograd/variable.cpp)
  with C10_MOBILE (technically we should use a dedicated c macro but its
  maintenance cost is higher than cmake macro as we have several build systems
  to change).
* Pass --disable-autograd flag to codegen script, which will stop generating
  Functions/VariableType code. And for variable_factories.h it will stop
  generating tracing code.

Edit: in this diff we will keep Functions.h/cpp to avoid changing source code.

Why we need this change if it's already not calling VariableType and autograd
stuff with USE_STATIC_DISPATCH=ON for mobile?
It's trying to reduce static library size for iOS build, for which it's
relatively harder to strip size with linker approach.

Why we need make involved change into codegen script?
There isn't a global config system in codegen - autograd/env.py provides similar
functionality but it says not adding anything there.

Test Plan:
- will check CI;
- test mobile build in sample app;

Pull Request resolved: #25697

Differential Revision: [D17202733](https://our.internmc.facebook.com/intern/diff/D17202733)
ljk53 added a commit that referenced this pull request Sep 10, 2019
…able_autograd is set"

Summary:
As discussed on PR #25697 - to remove autograd/functions.* without using
intrusive #if/#else we need whitelist "AsStridedBackward" used by variable.cpp.

Test Plan:
- builds and runs with stacked diffs

Pull Request resolved: #25817

Differential Revision: [D17247235](https://our.internmc.facebook.com/intern/diff/D17247235)
ljk53 added a commit that referenced this pull request Sep 10, 2019
…ad is set

Summary:
As discussed on PR #25697 - to remove autograd/functions.* without using
intrusive #if/#else we need whitelist "AsStridedBackward" used by variable.cpp.

Test Plan:
- builds and runs with stacked diffs

ghstack-source-id: 6d125bb
Pull Request resolved: #25817
… inference only library for mobile"

Summary:
This is the first of a series of changes to reduce build size by cutting
autograd functions from mobile build.

When INTERN_DISABLE_AUTOGRAD is set:
* On CMake side we exclude Functions.h/cpp, VariableType*.h/cpp,
  VariableTypeManual.cpp from the build process. Still keep variable_factories.h
  as we rely on it to create variables instead of tensors.
* In source code we gate a couple autograd references (in autograd/variable.cpp)
  with C10_MOBILE (technically we should use a dedicated c macro but its
  maintenance cost is higher than cmake macro as we have several build systems
  to change).
* Pass --disable-autograd flag to codegen script, which will stop generating
  Functions/VariableType code. And for variable_factories.h it will stop
  generating tracing code.

Edit: in this diff we will keep Functions.h/cpp to avoid changing source code.

Why we need this change if it's already not calling VariableType and autograd
stuff with USE_STATIC_DISPATCH=ON for mobile?
It's trying to reduce static library size for iOS build, for which it's
relatively harder to strip size with linker approach.

Why we need make involved change into codegen script?
There isn't a global config system in codegen - autograd/env.py provides similar
functionality but it says not adding anything there.

Test Plan:
- will check CI;
- test mobile build in sample app;

Pull Request resolved: #25697

Differential Revision: [D17202733](https://our.internmc.facebook.com/intern/diff/D17202733)
ljk53 added a commit that referenced this pull request Sep 10, 2019
…D flag to create inference only library for mobile"

Summary:
This is the first of a series of changes to reduce build size by cutting
autograd functions from mobile build.

When INTERN_DISABLE_AUTOGRAD is set:
* On CMake side we exclude Functions.h/cpp, VariableType*.h/cpp,
  VariableTypeManual.cpp from the build process. Still keep variable_factories.h
  as we rely on it to create variables instead of tensors.
* In source code we gate a couple autograd references (in autograd/variable.cpp)
  with C10_MOBILE (technically we should use a dedicated c macro but its
  maintenance cost is higher than cmake macro as we have several build systems
  to change).
* Pass --disable-autograd flag to codegen script, which will stop generating
  Functions/VariableType code. And for variable_factories.h it will stop
  generating tracing code.

Edit: in this diff we will keep Functions.h/cpp to avoid changing source code.

Why we need this change if it's already not calling VariableType and autograd
stuff with USE_STATIC_DISPATCH=ON for mobile?
It's trying to reduce static library size for iOS build, for which it's
relatively harder to strip size with linker approach.

Why we need make involved change into codegen script?
There isn't a global config system in codegen - autograd/env.py provides similar
functionality but it says not adding anything there.

Test Plan:
- will check CI;
- test mobile build in sample app;

Pull Request resolved: #25697

Differential Revision: [D17202733](https://our.internmc.facebook.com/intern/diff/D17202733)
ljk53 added a commit that referenced this pull request Sep 10, 2019
…able_autograd is set"

Summary:
As discussed on PR #25697 - to remove autograd/functions.* without using
intrusive #if/#else we need whitelist "AsStridedBackward" used by variable.cpp.

Test Plan:
- builds and runs with stacked diffs

Pull Request resolved: #25817

Differential Revision: [D17247235](https://our.internmc.facebook.com/intern/diff/D17247235)
ljk53 added a commit that referenced this pull request Sep 10, 2019
…n codegen if disable_autograd is set"

Summary:
As discussed on PR #25697 - to remove autograd/functions.* without using
intrusive #if/#else we need whitelist "AsStridedBackward" used by variable.cpp.

Test Plan:
- builds and runs with stacked diffs

Pull Request resolved: #25817

Differential Revision: [D17247235](https://our.internmc.facebook.com/intern/diff/D17247235)
ljk53 added a commit that referenced this pull request Sep 10, 2019
…able_autograd is set"

Summary:
As discussed on PR #25697 - to remove autograd/functions.* without using
intrusive #if/#else we need whitelist "AsStridedBackward" used by variable.cpp.

Test Plan:
- builds and runs with stacked diffs

Pull Request resolved: #25817

Differential Revision: [D17247235](https://our.internmc.facebook.com/intern/diff/D17247235)
ljk53 added a commit that referenced this pull request Sep 11, 2019
…n codegen if disable_autograd is set"

Summary:
As discussed on PR #25697 - to remove autograd/functions.* without using
intrusive #if/#else we need whitelist "AsStridedBackward" used by variable.cpp.

Test Plan:
- builds and runs with stacked diffs

Pull Request resolved: #25817

Differential Revision: [D17247235](https://our.internmc.facebook.com/intern/diff/D17247235)
ljk53 added a commit that referenced this pull request Sep 11, 2019
…able_autograd is set"

Summary:
As discussed on PR #25697 - to remove autograd/functions.* without using
intrusive #if/#else we need whitelist "AsStridedBackward" used by variable.cpp.

Test Plan:
- builds and runs with stacked diffs

Pull Request resolved: #25817

Differential Revision: [D17247235](https://our.internmc.facebook.com/intern/diff/D17247235)
ljk53 added a commit that referenced this pull request Sep 11, 2019
…n codegen if disable_autograd is set"

Summary:
As discussed on PR #25697 - to remove autograd/functions.* without using
intrusive #if/#else we need whitelist "AsStridedBackward" used by variable.cpp.

Test Plan:
- builds and runs with stacked diffs

Pull Request resolved: #25817

Differential Revision: [D17247235](https://our.internmc.facebook.com/intern/diff/D17247235)
ljk53 added a commit that referenced this pull request Sep 11, 2019
…able_autograd is set"

Summary:
As discussed on PR #25697 - to remove autograd/functions.* without using
intrusive #if/#else we need whitelist "AsStridedBackward" used by variable.cpp.

Test Plan:
- builds and runs with stacked diffs

Pull Request resolved: #25817

Differential Revision: [D17247235](https://our.internmc.facebook.com/intern/diff/D17247235)
ljk53 added a commit that referenced this pull request Sep 11, 2019
…n codegen if disable_autograd is set"

Summary:
As discussed on PR #25697 - to remove autograd/functions.* without using
intrusive #if/#else we need whitelist "AsStridedBackward" used by variable.cpp.

Test Plan:
- builds and runs with stacked diffs

Pull Request resolved: #25817

Differential Revision: [D17247235](https://our.internmc.facebook.com/intern/diff/D17247235)
ljk53 added a commit that referenced this pull request Sep 11, 2019
…able_autograd is set"

Summary:
As discussed on PR #25697 - to remove autograd/functions.* without using
intrusive #if/#else we need whitelist "AsStridedBackward" used by variable.cpp.

Test Plan:
- builds and runs with stacked diffs

Pull Request resolved: #25817

Differential Revision: [D17247235](https://our.internmc.facebook.com/intern/diff/D17247235)
@ljk53
Copy link
Contributor Author

ljk53 commented Sep 12, 2019

This is already landed: 8485710

Don't know why it's not closed automatically...

@ljk53 ljk53 closed this Sep 12, 2019
@facebook-github-bot facebook-github-bot deleted the gh/ljk53/33/head branch October 28, 2019 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

caffe2 module: autograd Related to torch.autograd, and the autograd engine in general module: build Build system issues module: internals Related to internal abstractions in c10 and ATen

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants