Skip to content

Commit a3793f3

Browse files
committed
Bump pinned PT commit to 20250617 and mirror torch/standalone to ExecuTorch
PyTorch added torch/standalone as a c10 dependency, so we need to mirror it to do a pin bump. Differential Revision: [D76909683](https://our.internmc.facebook.com/intern/diff/D76909683/) ghstack-source-id: 291279549 Pull Request resolved: #11791
1 parent 44d2643 commit a3793f3

File tree

9 files changed

+121
-89
lines changed

9 files changed

+121
-89
lines changed

.ci/docker/ci_commit_pins/pytorch.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5616fa4a68718ead203314a3467f7dd9547153ae
1+
6e2992a9984f2c3f6469564008c7e45869b84678

.ci/scripts/check_c10_sync.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ pushd pytorch
1212
git checkout "$pytorch_pin"
1313
popd
1414
"$(dirname "${BASH_SOURCE[0]}")"/compare_dirs.sh runtime/core/portable_type/c10/c10 pytorch/c10
15+
"$(dirname "${BASH_SOURCE[0]}")"/compare_dirs.sh runtime/core/portable_type/c10/torch/standalone pytorch/torch/standalone

install_requirements.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def python_is_compatible():
7171
#
7272
# NOTE: If you're changing, make the corresponding change in .ci/docker/ci_commit_pins/pytorch.txt
7373
# by picking the hash from the same date in https://hud.pytorch.org/hud/pytorch/pytorch/nightly/
74-
NIGHTLY_VERSION = "dev20250601"
74+
NIGHTLY_VERSION = "dev20250617"
7575

7676

7777
def install_requirements(use_pytorch_nightly):

runtime/core/portable_type/c10/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,10 @@ would cause all headers in that directory to be includeable with
1111
`#include <foo.h>`. In particular, that includes
1212
`runtime/core/portable_type/complex.h`, which would shadow the C99
1313
`complex.h` standard header.
14+
15+
`torch/standalone` has been added as an extra "even more bottom of
16+
stack" directory in PyTorch, so we have to add it to our sync
17+
here. The extra "stutter" c10 directory causing `c10/torch/standlone`
18+
is unfortunately awkward; perhaps we can rename the top-level
19+
directory to `pytorch_embedded_mirror` when we have extra time to work
20+
through CI failures.
Lines changed: 2 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,11 @@
11
#ifndef C10_MACROS_EXPORT_H_
22
#define C10_MACROS_EXPORT_H_
33

4-
/* Header file to define the common scaffolding for exported symbols.
5-
*
6-
* Export is by itself a quite tricky situation to deal with, and if you are
7-
* hitting this file, make sure you start with the background here:
8-
* - Linux: https://gcc.gnu.org/wiki/Visibility
9-
* - Windows:
10-
* https://docs.microsoft.com/en-us/cpp/cpp/dllexport-dllimport?view=vs-2017
11-
*
12-
* Do NOT include this file directly. Instead, use c10/macros/Macros.h
13-
*/
14-
15-
// You do not need to edit this part of file unless you are changing the core
16-
// pytorch export abstractions.
17-
//
18-
// This part defines the C10 core export and import macros. This is controlled
19-
// by whether we are building shared libraries or not, which is determined
20-
// during build time and codified in c10/core/cmake_macros.h.
21-
// When the library is built as a shared lib, EXPORT and IMPORT will contain
22-
// visibility attributes. If it is being built as a static lib, then EXPORT
23-
// and IMPORT basically have no effect.
24-
25-
// As a rule of thumb, you should almost NEVER mix static and shared builds for
26-
// libraries that depend on c10. AKA, if c10 is built as a static library, we
27-
// recommend everything dependent on c10 to be built statically. If c10 is built
28-
// as a shared library, everything dependent on it should be built as shared. In
29-
// the PyTorch project, all native libraries shall use the macro
30-
// C10_BUILD_SHARED_LIB to check whether pytorch is building shared or static
31-
// libraries.
32-
33-
// For build systems that do not directly depend on CMake and directly build
34-
// from the source directory (such as Buck), one may not have a cmake_macros.h
35-
// file at all. In this case, the build system is responsible for providing
36-
// correct macro definitions corresponding to the cmake_macros.h.in file.
37-
//
38-
// In such scenarios, one should define the macro
39-
// C10_USING_CUSTOM_GENERATED_MACROS
40-
// to inform this header that it does not need to include the cmake_macros.h
41-
// file.
42-
434
#ifndef C10_USING_CUSTOM_GENERATED_MACROS
445
#include <c10/macros/cmake_macros.h>
456
#endif // C10_USING_CUSTOM_GENERATED_MACROS
467

47-
#ifdef _WIN32
48-
#define C10_HIDDEN
49-
#if defined(C10_BUILD_SHARED_LIBS)
50-
#define C10_EXPORT __declspec(dllexport)
51-
#define C10_IMPORT __declspec(dllimport)
52-
#else
53-
#define C10_EXPORT
54-
#define C10_IMPORT
55-
#endif
56-
#else // _WIN32
57-
#if defined(__GNUC__)
58-
#define C10_EXPORT __attribute__((__visibility__("default")))
59-
#define C10_HIDDEN __attribute__((__visibility__("hidden")))
60-
#else // defined(__GNUC__)
61-
#define C10_EXPORT
62-
#define C10_HIDDEN
63-
#endif // defined(__GNUC__)
64-
#define C10_IMPORT C10_EXPORT
65-
#endif // _WIN32
66-
67-
#ifdef NO_EXPORT
68-
#undef C10_EXPORT
69-
#define C10_EXPORT
70-
#endif
71-
72-
// Definition of an adaptive XX_API macro, that depends on whether you are
73-
// building the library itself or not, routes to XX_EXPORT and XX_IMPORT.
74-
// Basically, you will need to do this for each shared library that you are
75-
// building, and the instruction is as follows: assuming that you are building
76-
// a library called libawesome.so. You should:
77-
// (1) for your cmake target (usually done by "add_library(awesome, ...)"),
78-
// define a macro called AWESOME_BUILD_MAIN_LIB using
79-
// target_compile_options.
80-
// (2) define the AWESOME_API macro similar to the one below.
81-
// And in the source file of your awesome library, use AWESOME_API to
82-
// annotate public symbols.
83-
84-
// Here, for the C10 library, we will define the macro C10_API for both import
85-
// and export.
86-
87-
// This one is being used by libc10.so
88-
#ifdef C10_BUILD_MAIN_LIB
89-
#define C10_API C10_EXPORT
90-
#else
91-
#define C10_API C10_IMPORT
92-
#endif
8+
#include <torch/standalone/macros/Export.h>
939

9410
// This one is being used by libtorch.so
9511
#ifdef CAFFE2_BUILD_MAIN_LIB
@@ -159,4 +75,4 @@
15975
#define C10_API_ENUM
16076
#endif
16177

162-
#endif // C10_MACROS_MACROS_H_
78+
#endif // C10_MACROS_EXPORT_H_

runtime/core/portable_type/c10/c10/targets.bzl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ def define_common_targets():
7878
"//executorch/...",
7979
"@EXECUTORCH_CLIENTS",
8080
],
81-
deps = select({
81+
exported_deps = [
82+
"//executorch/runtime/core/portable_type/c10/torch/standalone:torch_standalone_headers",
83+
] + select({
8284
"DEFAULT": [],
8385
# Half-inl.h depends on vec_half.h from ATen, but only when building for x86.
8486
"ovr_config//cpu:x86_64": [
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
load(":targets.bzl", "define_common_targets")
2+
3+
oncall("executorch")
4+
5+
define_common_targets()
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#pragma once
2+
3+
/* Header file to define the common scaffolding for exported symbols.
4+
*
5+
* Export is by itself a quite tricky situation to deal with, and if you are
6+
* hitting this file, make sure you start with the background here:
7+
* - Linux: https://gcc.gnu.org/wiki/Visibility
8+
* - Windows:
9+
* https://docs.microsoft.com/en-us/cpp/cpp/dllexport-dllimport?view=vs-2017
10+
*
11+
* Do NOT include this file directly. Instead, use c10/macros/Macros.h
12+
*/
13+
14+
// You do not need to edit this part of file unless you are changing the core
15+
// pytorch export abstractions.
16+
//
17+
// This part defines the C10 core export and import macros. This is controlled
18+
// by whether we are building shared libraries or not, which is determined
19+
// during build time and codified in c10/core/cmake_macros.h.
20+
// When the library is built as a shared lib, EXPORT and IMPORT will contain
21+
// visibility attributes. If it is being built as a static lib, then EXPORT
22+
// and IMPORT basically have no effect.
23+
24+
// As a rule of thumb, you should almost NEVER mix static and shared builds for
25+
// libraries that depend on c10. AKA, if c10 is built as a static library, we
26+
// recommend everything dependent on c10 to be built statically. If c10 is built
27+
// as a shared library, everything dependent on it should be built as shared. In
28+
// the PyTorch project, all native libraries shall use the macro
29+
// C10_BUILD_SHARED_LIB to check whether pytorch is building shared or static
30+
// libraries.
31+
32+
// For build systems that do not directly depend on CMake and directly build
33+
// from the source directory (such as Buck), one may not have a cmake_macros.h
34+
// file at all. In this case, the build system is responsible for providing
35+
// correct macro definitions corresponding to the cmake_macros.h.in file.
36+
//
37+
// In such scenarios, one should define the macro
38+
// C10_USING_CUSTOM_GENERATED_MACROS
39+
// to inform this header that it does not need to include the cmake_macros.h
40+
// file.
41+
42+
#ifdef _WIN32
43+
#define C10_HIDDEN
44+
#if defined(C10_BUILD_SHARED_LIBS)
45+
#define C10_EXPORT __declspec(dllexport)
46+
#define C10_IMPORT __declspec(dllimport)
47+
#else
48+
#define C10_EXPORT
49+
#define C10_IMPORT
50+
#endif
51+
#else // _WIN32
52+
#if defined(__GNUC__)
53+
#define C10_EXPORT __attribute__((__visibility__("default")))
54+
#define C10_HIDDEN __attribute__((__visibility__("hidden")))
55+
#else // defined(__GNUC__)
56+
#define C10_EXPORT
57+
#define C10_HIDDEN
58+
#endif // defined(__GNUC__)
59+
#define C10_IMPORT C10_EXPORT
60+
#endif // _WIN32
61+
62+
#ifdef NO_EXPORT
63+
#undef C10_EXPORT
64+
#define C10_EXPORT
65+
#endif
66+
67+
// Definition of an adaptive XX_API macro, that depends on whether you are
68+
// building the library itself or not, routes to XX_EXPORT and XX_IMPORT.
69+
// Basically, you will need to do this for each shared library that you are
70+
// building, and the instruction is as follows: assuming that you are building
71+
// a library called libawesome.so. You should:
72+
// (1) for your cmake target (usually done by "add_library(awesome, ...)"),
73+
// define a macro called AWESOME_BUILD_MAIN_LIB using
74+
// target_compile_options.
75+
// (2) define the AWESOME_API macro similar to the one below.
76+
// And in the source file of your awesome library, use AWESOME_API to
77+
// annotate public symbols.
78+
79+
// Here, for the C10 library, we will define the macro C10_API for both import
80+
// and export.
81+
82+
// This one is being used by libc10.so
83+
#ifdef C10_BUILD_MAIN_LIB
84+
#define C10_API C10_EXPORT
85+
#else
86+
#define C10_API C10_IMPORT
87+
#endif
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
2+
3+
def define_common_targets():
4+
"""Defines targets that should be shared between fbcode and xplat.
5+
6+
The directory containing this targets.bzl file should also contain both
7+
TARGETS and BUCK files that call this function.
8+
"""
9+
10+
runtime.cxx_library(
11+
name = "torch_standalone_headers",
12+
exported_headers = glob(["**/*.h"]),
13+
header_namespace = "torch/standalone",
14+
)

0 commit comments

Comments
 (0)