8000 Update on "switch aten_headers to use strip_include_prefix instead of… · pytorch/pytorch@f9701e8 · GitHub
[go: up one dir, main page]

Skip to content

Commit f9701e8

Browse files
author
Michael Andreas Dagitses
committed
Update on "switch aten_headers to use strip_include_prefix instead of includes"
This is Bazel best practices and easier to maintain. Differential Revision: [D36521515](https://our.internmc.facebook.com/intern/diff/D36521515/) [ghstack-poisoned]
2 parents 0859106 + 29ddcd1 commit f9701e8

File tree

274 files changed

+34781
-3456
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

274 files changed

+34781
-3456
lines changed

.circleci/docker/build_docker.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ tag="${DOCKER_TAG}"
1818

1919
registry="308535385114.dkr.ecr.us-east-1.amazonaws.com"
2020
image="${registry}/pytorch/${IMAGE_NAME}"
21+
ghcr_image="ghcr.io/pytorch/ci-image"
2122

2223
login() {
2324
aws ecr get-authorization-token --region us-east-1 --output text --query 'authorizationData[].authorizationToken' |
@@ -54,6 +55,13 @@ if [ "${DOCKER_SKIP_PUSH:-true}" = "false" ]; then
5455
if ! docker manifest inspect "${image}:${tag}" >/dev/null 2>/dev/null; then
5556
docker push "${image}:${tag}"
5657
fi
58+
59+
if [ "${PUSH_GHCR_IMAGE:-}" = "true" ]; then
60+
# Push docker image to the ghcr.io
61+
echo $GHCR_PAT | docker login ghcr.io -u pytorch --password-stdin
62+
docker tag "${image}:${tag}" "${ghcr_image}:${IMAGE_NAME}-${tag}"
63+
docker push "${ghcr_image}:${IMAGE_NAME}-${tag}"
64+
fi
5765
fi
5866

5967
if [ -z "${DOCKER_SKIP_S3_UPLOAD:-}" ]; then

.circleci/docker/common/install_base.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ install_ubuntu() {
6666
software-properties-common \
6767
wget \
6868
sudo \
69-
vim
69+
vim \
70+
jq
7071

7172
# Should resolve issues related to various apt package repository cert issues
7273
# see: https://github.com/pytorch/pytorch/issues/65931

.github/actions/calculate-docker-image/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ inputs:
2323
force_push:
2424
description: If set to any value, always run the push
2525
required: false
26+
push-ghcr-image:
27+
description: If set to any value, push docker image to the ghcr.io.
28+
required: false
2629

2730
outputs:
2831
docker-image:
@@ -102,6 +105,8 @@ runs:
102105
# Skip push if we don't need it, or if specified in the inputs
103106
DOCKER_SKIP_PUSH: ${{ steps.check.outputs.skip_push || inputs.skip_push }}
104107
DOCKER_TAG: ${{ steps.calculate-tag.outputs.docker-tag }}
108+
PUSH_GHCR_IMAGE: ${{ inputs.push-ghcr-image }}
109+
GHCR_PAT: ${{ env.GHCR_PAT }}
105110
working-directory: .circleci/docker
106111
shell: bash
107112
run: |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ad21e440dc9e5cdd77785fe1ea9979a53262114e
1+
5f2f374d9bbc6374fe725a17182e7d4c270c6833

.github/scripts/trymerge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ def fetch_check_run_conclusions(repo: GitRepo, commit: str) -> Dict[str, Tuple[s
990990
[owner, name] = repo.gh_owner_and_name()
991991
checks = fetch_json_dict(f'https://api.github.com/repos/{owner}/{name}/commits/{commit}/check-runs')
992992
check_run_conclusions = {}
993-
if len(checks) == 0:
993+
if len(checks['check_runs']) == 0:
994994
raise MandatoryChecksMissingError("Refusing to merge as land check(s) are not yet run")
995995
for check_run in checks['check_runs']:
996996
check_run_conclusions[check_run['name']] = (check_run['conclusion'],

.github/workflows/_android-build-test.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@ jobs:
7373
# 1) Not shareable: it's custom selective build, which is different from default libtorch mobile build;
7474
# 2) Not parallelizable by architecture: it only builds libtorch for one architecture;
7575
76-
echo "DOCKER_IMAGE: ${ 97AE DOCKER_IMAGE}"
77-
time docker pull "${DOCKER_IMAGE}" >/dev/null
78-
7976
export BUILD_LITE_INTERPRETER
8077
BUILD_LITE_INTERPRETER="1"
8178
if [[ "${BUILD_ENVIRONMENT}" == *"full-jit" ]]; then

.github/workflows/docker-builds.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,14 @@ jobs:
6262
- name: Build docker image
6363
id: build-docker-image
6464
uses: ./.github/actions/calculate-docker-image
65+
env:
66+
GHCR_PAT: ${{ secrets.GHCR_PAT }}
6567
with:
6668
docker-image-name: ${{ matrix.docker-image-name }}
6769
always-rebuild: true
6870
skip_push: false
6971
force_push: true
72+
push-ghcr-image: ${{ github.event_name == 'push' }}
7073

7174
- name: Pull docker image
7275
uses: ./.github/actions/pull-docker-image

.github/workflows/trunk.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ jobs:
223223
]}
224224
225225
linux-bionic-rocm5_1-py3_7-build:
226-
if: false
227226
name: linux-bionic-rocm5.1-py3.7
228227
uses: ./.github/workflows/_linux-build.yml
229228
with:

.jenkins/pytorch/common_utils.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ function print_sccache_stats() {
144144
sccache --show-stats
145145

146146
if [[ -n "${OUR_GITHUB_JOB_ID}" ]]; then
147-
sccache --show-stats \
148-
| python -m tools.stats.scc F438 ache_stats_to_json \
147+
sccache --show-stats --stats-format json | jq .stats \
149148
> "sccache-stats-${BUILD_ENVIRONMENT}-${OUR_GITHUB_JOB_ID}.json"
150149
else
151150
echo "env var OUR_GITHUB_JOB_ID not set, will not write sccache stats to json"

.jenkins/pytorch/test.sh

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,33 @@ test_python() {
178178
assert_git_not_dirty
179179
}
180180

181+
182+
test_dynamo_shard() {
183+
if [[ -z "$NUM_TEST_SHARDS" ]]; then
184+
echo "NUM_TEST_SHARDS must be defined to run a Python test shard"
185+
exit 1
186+
fi
187+
time python test/run_test.py \
188+
--exclude-jit-executor \
189+
--exclude-distributed-tests \
190+
--exclude \
191+
test_autograd \
192+
test_proxy_tensor \
193+
test_quantization \
194+
test_public_bindings \
195+
test_dataloader \
196+
test_reductions \
197+
test_namedtensor \
198+
test_namedtuple_return_api \
199+
test_profiler \
200+
test_profiler_tree \
201+
test_overrides \
202+
test_python_dispatch \
203+
--shard "$1" "$NUM_TEST_SHARDS" \
204+
--verbose
205+
assert_git_not_dirty
206+
}
207+
181208
test_python_gloo_with_tls() {
182209
source "$(dirname "${BASH_SOURCE[0]}")/run_glootls_test.sh"
183210
assert_git_not_dirty
@@ -599,6 +626,17 @@ elif [[ "$TEST_CONFIG" == distributed ]]; then
599626
if [[ "${SHARD_NUMBER}" == 1 ]]; then
600627
test_rpc
601628
fi
629+
elif [[ "${TEST_CONFIG}" == *dynamo* && "${SHARD_NUMBER}" == 1 && $NUM_TEST_SHARDS -gt 1 ]]; then
630+
test_without_numpy
631+
install_torchvision
632+
install_torchdynamo
633+
test_dynamo_shard 1
634+
test_aten
635+
elif [[ "${TEST_CONFIG}" == *dynamo* && "${SHARD_NUMBER}" == 2 && $NUM_TEST_SHARDS -gt 1 ]]; then
636+
install_torchvision
637+
checkout_install_torchdynamo
638+
test_dynamo_shard 2
639+
test_dynamo
602640
elif [[ "${SHARD_NUMBER}" == 1 && $NUM_TEST_SHARDS -gt 1 ]]; then
603641
test_without_numpy
604642
install_torchvision
@@ -614,7 +652,6 @@ elif [[ "${SHARD_NUMBER}" == 2 && $NUM_TEST_SHARDS -gt 1 ]]; then
614652
test_custom_script_ops
615653
test_custom_backend
616654
test_torch_function_benchmark
617-
test_dynamo
618655
elif [[ "${SHARD_NUMBER}" -gt 2 ]]; then
619656
# Handle arbitrary number of shards
620657
install_torchdynamo

.jenkins/pytorch/win-test-helpers/build_pytorch.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,5 +154,5 @@ python setup.py install --cmake && sccache --show-stats && (
154154
)
155155
)
156156

157-
sccache --show-stats | python tools/stats/sccache_stats_to_json.py > sccache-stats-%BUILD_ENVIRONMENT%-%OUR_GITHUB_JOB_ID%.json
157+
sccache --show-stats --stats-format json | jq .stats > sccache-stats-%BUILD_ENVIRONMENT%-%OUR_GITHUB_JOB_ID%.json
158158
sccache --stop-server

aten/src/ATen/Context.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,14 @@ void Context::setBenchmarkCuDNN(bool b) {
144144
benchmark_cudnn = b;
145145
}
146146

147+
int Context::benchmarkLimitCuDNN() const {
148+
return benchmark_limit_cudnn;
149+
}
150+
151+
void Context::setBenchmarkLimitCuDNN(int b) {
152+
benchmark_limit_cudnn = b;
153+
}
154+
147155
bool Context::allowTF32CuBLAS() const {
148156
static bool allow_tf32_cublas_override = c10::utils::check_env("TORCH_ALLOW_TF32_CUBLAS_OVERRIDE") == true;
149157
return allow_tf32_cublas_override || float32_matmul_precision != at::Float32MatmulPrecision::HIGHEST;

aten/src/ATen/Context.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ class TORCH_API Context {
121121
void setUserEnabledMkldnn(bool e);
122122
bool benchmarkCuDNN() const;
123123
void setBenchmarkCuDNN(bool);
124+
int benchmarkLimitCuDNN() const;
125+
void setBenchmarkLimitCuDNN(int);
124126
bool deterministicCuDNN() const;
125127
void setDeterministicCuDNN(bool);
126128

@@ -254,6 +256,7 @@ class TORCH_API Context {
254256
bool benchmark_cudnn = false;
255257
Float32MatmulPrecision float32_matmul_precision =
256258
at::Float32MatmulPrecision::HIGHEST;
259+
int benchmark_limit_cudnn = 10;
257260
bool allow_tf32_cudnn = true;
258261
bool allow_fp16_reduction_cublas = true;
259262
bool enabled_mkldnn = true;

aten/src/ATen/FunctionalizeFallbackKernel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ const at::Tensor & resize__functionalization(c10::DispatchKeySet dispatchKeySet,
131131
at::Tensor tmp_output;
132132
{
133133
at::AutoDispatchSkipFunctionalize guard;
134-
tmp_output = at::resize_functional(self_, size, memory_format);
134+
tmp_output = at::resize(self_, size, memory_format);
135135
}
136136

137137
auto itemsize = self.dtype().itemsize();

aten/src/ATen/NestedTensorImpl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ struct TORCH_API NestedTensorImpl : public c10::TensorImpl {
6868
int64_t size_custom(int64_t d) const override {
6969
return this->size(d);
7070
}
71+
c10::SymInt sym_size_custom(int64_t d) const override {
72+
return c10::SymInt{this->size(d)};
73+
}
7174
IntArrayRef sizes_custom() const override;
7275
c10::SymIntArrayRef sym_sizes_custom() const override;
7376
c10::SymIntArrayRef sym_sizes() const override;

aten/src/ATen/TensorIterator.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,8 @@ void TensorIteratorBase::build_ternary_op(
946946
const TensorBase& out, const TensorBase& a,
947947
const TensorBase& b, const TensorBase& c) {
948948
build(TensorIteratorConfig()
949+
.promote_inputs_to_common_dtype(true)
950+
.enforce_safe_casting_to_output(true)
949951
.add_owned_output(out)
950952
.add_owned_input(a)
951953
.add_owned_input(b)

aten/src/ATen/core/PythonFallbackKernel.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void pythonFallback(const c10::OperatorHandle& op, torch::jit::Stack* stack) {
5353
// If Torch Dispatch Mode is active, use its PyInterpreter for dispatch
5454
const auto& maybe_torch_dispatch_mode_state = at::impl::TorchDispatchModeTLS::get_state();
5555
if (maybe_torch_dispatch_mode_state) {
56-
maybe_torch_dispatch_mode_state->pyinterpreter()->dispatch(op, stack, maybe_torch_dispatch_mode_state);
56+
maybe_torch_dispatch_mode_state->pyinterpreter()->dispatch(op, stack);
5757
return;
5858
}
5959

@@ -69,7 +69,7 @@ void pythonFallback(const c10::OperatorHandle& op, torch::jit::Stack* stack) {
< 57AE code>6969
if (ivalue.isTensor()) {
7070
auto* interpreter = ivalue.unsafeToTensorImpl()->pyobj_interpreter();
7171
if (interpreter) {
72-
interpreter->dispatch(op, stack, nullptr);
72+
interpreter->dispatch(op, stack);
7373
return;
7474
}
7575
} else if (ivalue.isTensorList()) {
@@ -78,7 +78,7 @@ void pythonFallback(const c10::OperatorHandle& op, torch::jit::Stack* stack) {
7878
for (const auto& nv : ivalue.toListRef()) {
7979
auto* interpreter = nv.unsafeToTensorImpl()->pyobj_interpreter();
8080
if (interpreter) {
81-
interpreter->dispatch(op, stack, nullptr);
81+
interpreter->dispatch(op, stack);
8282
return;
8383
}
8484
}

aten/src/ATen/core/TensorBase.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,7 @@ class TORCH_API TensorBase {
157157
}
158158

159159
c10::SymInt sym_size(int64_t dim) const {
160-
const auto sizes = this->sym_sizes();
161-
const auto ndim = static_cast<int64_t>(sizes.size());
162-
// false is passed to maybe_wrap_dim so behavior is identical to array access (but with wrapping)
163-
return sizes[c10::maybe_wrap_dim(dim, ndim, /*wrap_scalar=*/false)];
164-
160+
return impl_->sym_size(dim);
165161
}
166162

167163
int64_t size(int64_t dim) const {
@@ -349,7 +345,7 @@ class TORCH_API TensorBase {
349345
}
350346

351347
/// Returns a `Tensor`'s layout.
352-
Layout layout() const noexcept {
348+
Layout layout() const {
353349
return impl_->layout();
354350
}
355351

aten/src/ATen/mps/MPSAllocator.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,18 @@ struct HeapBlock;
6363
struct BufferBlock
6464
{
6565
id<MTLBuffer> buffer;
66-
size_t size;
66+
size_t size; // size after alignment
67+
size_t requested_size; // requested size (before alignment)
68+
// buffer shape is used for retrieving base of views in cached graphs
69+
std::vector<int64_t> shape;
6770
bool in_use;
6871
HeapBlock* heap;
6972
id_t buf_id;
7073

71-
BufferBlock(size_t Size, const id<MTLBuffer> Buffer = nullptr, HeapBlock* Heap = nullptr, id_t BufID = 0) :
72-
buffer(Buffer), size(Size), in_use(false), heap(Heap), buf_id(BufID) { }
74+
BufferBlock(size_t Size, size_t RequestedSize = 0, const id<MTLBuffer> Buffer = nullptr,
75+
HeapBlock* Heap = nullptr, id_t BufID = 0) :
76+
buffer(Buffer), size(Size), requested_size(RequestedSize),
77+
in_use(false), heap(Heap), buf_id(BufID) { }
7378

7479
static bool Comparator(const BufferBlock* a, const BufferBlock* b) {
7580
return (a->size != b->size) ? a->size < b->size : (uintptr_t)a->buffer < (uintptr_t)b->buffer;
@@ -193,6 +198,9 @@ class MPSHeapAllocatorImpl
193198
void Free(void* ptr);
194199
void EmptyCache();
195200
bool isSharedBuffer(void* ptr);
201+
ssize_t getRequestedBufferSize(void* ptr);
202+
void setBufferShape(void* ptr, const IntArrayRef& shape);
203+
IntArrayRef getBufferShape(void* ptr);
196204

197205
inline id<MTLDevice> Device() const { return m_device; }
198206
void enable_debug_info() { m_enable_debug_info = true; }

0 commit comments

Comments
 (0)
0