8000 Update · pytorch/pytorch@c5787b8 · GitHub
[go: up one dir, main page]

Skip to content

Commit c5787b8

Browse files
committed
Update
[ghstack-poisoned]
2 parents 0dea326 + b946c10 commit c5787b8

File tree

71 files changed

+1126
-1305
lines changed

Some content is hidden

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

71 files changed

+1126
-1305
lines changed

.ci/docker/requirements-docs.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
sphinx==5.3.0
22
#Description: This is used to generate PyTorch docs
33
#Pinned versions: 5.3.0
4-
-e git+https://github.com/pytorch/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme
4+
-e git+https://github.com/pytorch/pytorch_sphinx_theme.git@c49afc2aff734d40813b0ca182bb49b611d7a30c#egg=pytorch_sphinx_theme2
55

66
# TODO: sphinxcontrib.katex 0.9.0 adds a local KaTeX server to speed up pre-rendering
77
# but it doesn't seem to work and hangs around idly. The initial thought is probably
88
# something related to Docker setup. We can investigate this later
9+
910
sphinxcontrib.katex==0.8.6
1011
#Description: This is used to generate PyTorch docs
1112
#Pinned versions: 0.8.6
1213

14+
sphinxext-opengraph==0.9.1
15+
#Description: This is used to generate PyTorch docs
16+
#Pinned versions: 0.9.1
17+
1318
matplotlib==3.5.3
1419
#Description: This is used to generate PyTorch docs
1520
#Pinned versions: 3.5.3
@@ -46,5 +51,6 @@ myst-nb==0.17.2
4651
# The following are required to build torch.distributed.elastic.rendezvous.etcd* docs
4752
python-etcd==0.4.5
4853
sphinx-copybutton==0.5.0
49-
sphinx-panels==0.4.1
54+
sphinx-design==0.4.0
55+
sphinxcontrib-mermaid==1.0.0
5056
myst-parser==0.18.1

.ci/pytorch/python_doc_push_script.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,6 @@ popd
119119
git rm -rf "$install_path" || true
120120
mv "$pt_checkout/docs/build/html" "$install_path"
121121

122-
# Prevent Google from indexing $install_path/_modules. This folder contains
123-
# generated source files.
124-
# NB: the following only works on gnu sed. The sed shipped with mac os is different.
125-
# One can `brew install gnu-sed` on a mac and then use "gsed" instead of "sed".
126-
find "$install_path/_modules" -name "*.html" -print0 | xargs -0 sed -i '/<head>/a \ \ <meta name="robots" content="noindex">'
127-
128122
git add "$install_path" || true
129123
git status
130124
git config user.email "soumith+bot@pytorch.org"

aten/src/ATen/native/mps/kernels/UnaryKernel.metal

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,29 @@ struct sqrt_functor {
6767
}
6868
};
6969

70+
struct bitwise_not_functor {
71+
template <typename T>
72+
inline enable_if_t<!is_same_v<T, bool> && is_scalar_integral_v<T>, T>
73+
operator()(const T x) {
74+
return ~x;
75+
}
76+
77+
template <typename T>
78+
inline enable_if_t<is_same_v<T, bool>, T> operator()(const T x) {
79+
return !x;
80+
}
81+
};
82+
7083
DEFINE_UNARY_FLOATING_FUNCTOR(erfinv);
7184
DEFINE_UNARY_FLOATING_FUNCTOR(sinc);
7285

86+
REGISTER_UNARY_OP(bitwise_not, int, int);
87+
REGISTER_UNARY_OP(bitwise_not, long, long);
88+
REGISTER_UNARY_OP(bitwise_not, short, short);
89+
REGISTER_UNARY_OP(bitwise_not, char, char);
90+
REGISTER_UNARY_OP(bitwise_not, uchar, uchar);
91+
REGISTER_UNARY_OP(bitwise_not, bool, bool);
92+
7393
#define INSTANTIATE_UNARY_KERNELS2(DTYPE0, DTYPE1) \
7494
REGISTER_UNARY_OP(erfinv, DTYPE1, DTYPE0); \
7595
REGISTER_UNARY_OP(exp, DTYPE1, DTYPE0); \

aten/src/ATen/native/mps/operations/BitwiseOps.mm

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include <ATen/native/Resize.h>
66
#include <ATen/native/mps/OperationUtils.h>
77
#include <ATen/ops/bitwise_and_native.h>
8-
#include <ATen/ops/bitwise_not_native.h>
98
#include <ATen/ops/bitwise_or_native.h>
109
#include <ATen/ops/bitwise_xor_native.h>
1110
#include <ATen/ops/logical_not_native.h>
@@ -100,11 +99,6 @@ kernel void bitwise_rshift_scalar_tensor(device {0} *out [[buffer(0)]],
10099
out[offset] = static_cast<{0}>(a) >> b[offset];
101100
}}
102101
103-
kernel void bitwise_not(device {0} *out [[buffer(0)]],
104-
constant {1} *a [[buffer(1)]],
105-
uint offset [[thread_position_in_grid]]) {{
106-
out[offset] = ~a[offset];
107-
}}
108102
)METAL",
109103
3);
110104

@@ -200,54 +194,6 @@ static void _bitwise_op_out_mps(const Tensor& self,
200194
return;
201195
}
202196

203-
static void _bitwise_not_out_mps(const Tensor& self, const Tensor& output_) {
204-
// Handle boolean tensor using logical not
205-
if (self.scalar_type() == c10::ScalarType::Bool) {
206-
logical_not_out_mps(self, const_cast<Tensor&>(output_));
207-
return;
208-
}
209-
210-
Tensor output = output_;
211-
bool needs_output_copy = false;
212-
213-
resize_output(output, self.sizes());
214-
if (needsGather(output)) {
215-
output = output.contiguous();
216-
needs_output_copy = true;
217-
}
218-
if (self.dim() == 0) {
219-
if (self.scalar_type() == c10::ScalarType::Byte) {
220-
// Unsigned types need a special handling to keep result of operation in 0..255 output
221-
output.fill_(c10::Scalar(static_cast<uint8_t>(~self.item<uint8_t>())));
222-
} else {
223-
output.fill_(c10::Scalar(~self.item<int64_t>()));
224-
}
225-
return;
226-
}
227-
uint32_t length = output.numel();
228-
if (length == 0) {
229-
return;
230-
}
231-
using namespace at::mps;
232-
MPSStream* stream = getCurrentMPSStream();
233-
auto cplState = getCPLState(output, self, self, "bitwise_not");
234-
dispatch_sync(stream->queue(), ^() {
235-
getMPSProfiler().beginProfileKernel(cplState, "bitwise_not", {self});
236-
237-
id<MTLComputeCommandEncoder> commandEncoder = stream->commandEncoder();
238-
239-
[commandEncoder pushDebugGroup:@"Dispatch bitwise_not kernel"];
240-
[commandEncoder setComputePipelineState:cplState];
241-
mtl_setArgs(commandEncoder, output, self);
242-
mtl_dispatch1DJob(commandEncoder, cplState, length);
243-
244-
getMPSProfiler().endProfileKernel(cplState);
245-
});
246-
if (needs_output_copy) {
247-
output_.copy_(output);
248-
}
249-
}
250-
251197
} // namespace mps
252198
namespace {
253199
void lshift_kernel_mps(TensorIteratorBase& iter) {
@@ -272,10 +218,6 @@ void rshift_kernel_mps(TensorIteratorBase& iter) {
272218
mps::_bitwise_op_out_mps(self, other, output, "xor");
273219
}
274220

275-
TORCH_IMPL_FUNC(bitwise_not_out_mps)(const Tensor& self, const Tensor& output) {
276-
mps::_bitwise_not_out_mps(self, output);
277-
}
278-
279221
REGISTER_MPS_DISPATCH(lshift_stub, &lshift_kernel_mps)
280222
REGISTER_MPS_DISPATCH(rshift_stub, &rshift_kernel_mps)
281223

aten/src/ATen/native/mps/operations/UnaryKernel.mm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,15 @@ static void sqrt_kernel_mps(TensorIteratorBase& iter) {
3838
lib.exec_unary_kernel(iter, "sqrt");
3939
}
4040

41+
static void bitwise_not_kernel_mps(TensorIteratorBase& iter) {
42+
lib.exec_unary_kernel(iter, "bitwise_not");
43+
}
44+
4145
REGISTER_DISPATCH(exp_stub, exp_kernel);
4246
REGISTER_DISPATCH(erfinv_stub, erfinv_kernel);
4347
REGISTER_DISPATCH(sinc_stub, sinc_kernel);
4448
REGISTER_DISPATCH(tanh_stub, tanh_kernel);
4549
REGISTER_DISPATCH(round_decimals_stub, round_decimals_kernel);
4650
REGISTER_DISPATCH(sqrt_stub, sqrt_kernel_mps);
51+
REGISTER_DISPATCH(bitwise_not_stub, bitwise_not_kernel_mps);
4752
} // namespace at::native

aten/src/ATen/native/native_functions.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,8 +1211,7 @@
12111211
structured: True
12121212
structured_inherits: TensorIteratorBase
12131213
dispatch:
1214-
CPU, CUDA: bitwise_not_out
1215-
MPS: bitwise_not_out_mps
1214+
CPU, CUDA, MPS: bitwise_not_out
12161215
tags: pointwise
12171216

12181217
- func: copysign.out(Tensor self, Tensor other, *, Tensor(a!) out) -> Tensor(a!)

docs/cpp/source/_static/cpp_theme.css

Lines changed: 0 additions & 32 deletions
This file was deleted.

docs/cpp/source/conf.py

Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
import os
2323
import textwrap
2424

25-
2625
# sys.path.insert(0, os.path.abspath('.'))
26+
import pytorch_sphinx_theme2
2727

2828

2929
# -- General configuration ------------------------------------------------
@@ -112,6 +112,12 @@
112112
# Add any paths that contain templates here, relative to this directory.
113113
# templates_path = ['_templates']
114114

115+
theme_variables = pytorch_sphinx_theme2.get_theme_variables()
116+
117+
templates_path = [
118+
"_templates",
119+
os.path.join(os.path.dirname(pytorch_sphinx_theme2.__file__), "templates"),
120+
]
115121
# The suffix(es) of source filenames.
116122
# You can specify multiple suffix as a list of string:
117123
#
@@ -142,7 +148,7 @@
142148
#
143149
# This is also used if you do content translation via gettext catalogs.
144150
# Usually you set "language" from the command line for these cases.
145-
language = None
151+
language = "en"
146152

147153
# List of patterns, relative to source directory, that match files and
148154
# directories to ignore when looking for source files.
@@ -160,45 +166,65 @@
160166
# The theme to use for HTML and HTML Help pages. See the documentation for
161167
# a list of builtin themes.
162168
#
163-
html_theme = "pytorch_sphinx_theme"
169+
html_theme = "pytorch_sphinx_theme2"
164170

165171
# Theme options are theme-specific and customize the look and feel of a theme
166172
# further. For a list of options available for each theme, see the
167173
# documentation.
168174
#
169175
html_theme_options = {
170176
"canonical_url": "https://pytorch.org/docs/stable/",
171-
"pytorch_project": "docs",
172177
"collapse_navigation": False,
178+
"logo": {"text": "Home"},
179+
"icon_links": [
180+
{
181+
"name": "X",
182+
"url": "https://x.com/PyTorch",
183+
"icon": "fa-brands fa-x-twitter",
184+
},
185+
{
186+
"name": "GitHub",
187+
"url": "https://github.com/pytorch/pytorch",
188+
"icon": "fa-brands fa-github",
189+
},
190+
{
191+
"name": "PyTorch Forum",
192+
"url": "https://discuss.pytorch.org/",
193+
"icon": "fa-brands fa-discourse",
194+
},
195+
{
196+
"name": "PyPi",
197+
"url": "https://pypi.org/project/torch/",
198+
"icon": "fa-brands fa-python",
199+
},
200+
],
201+
"navbar_start": ["pytorch_version"],
173202
"display_version": True,
174-
"logo_only": True,
203+
}
204+
205+
html_context = {
206+
"theme_variables": theme_variables,
207+
"github_url": "https://github.com",
208+
"github_user": "pytorch",
209+
"github_repo": "pytorch",
210+
"feedback_url": "https://github.com/pytorch/pytorch",
211+
"github_version": "main",
212+
"doc_path": "docs/cpp/source",
213+
"library_links": theme_variables.get("library_links", []),
214+
"community_links": theme_variables.get("community_links", []),
215+
"language_bindings_links": theme_variables.get("language_bindings_links", []),
175216
}
176217

177218
# NOTE: sharing python docs resources
178-
html_logo = os.path.join(
179-
repo_root, "docs", "source", "_static", "img", "pytorch-logo-dark-unstable.png"
180-
)
181219

182220
# Add any paths that contain custom static files (such as style sheets) here,
183221
# relative to this directory. They are copied after the builtin static files,
184222
# so a file named "default.css" will overwrite the builtin "default.css".
185223
# NOTE: sharing python docs resources
186224
html_static_path = [os.path.join(repo_root, "docs", "cpp", "source", "_static")]
187-
225+
html_css_files = ["cpp_theme.css"]
188226

189227
# Called automatically by Sphinx, making this `conf.py` an "extension".
190-
def setup(app):
191-
# NOTE: in Sphinx 1.8+ `html_css_files` is an official configuration value
192-
# and can be moved outside of this function (and the setup(app) function
193-
# can be deleted).
194-
html_css_files = ["cpp_theme.css"]
195-
196-
# In Sphinx 1.8 it was renamed to `add_css_file`, 1.7 and prior it is
197-
# `add_stylesheet` (deprecated in 1.8).
198-
add_css = getattr(app, "add_css_file", app.add_stylesheet)
199-
for css_file in html_css_files:
200-
add_css(css_file)
201-
202228

203229
# -- Options for HTMLHelp output ------------------------------------------
204230

docs/requirements.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
sphinx==5.0.0
2-
-e git+https://github.com/pytorch/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme
1+
sphinx==5.3.0
2+
-e git+https://github.com/pytorch/pytorch_sphinx_theme.git@pytorch_sphinx_theme2#egg=pytorch_sphinx_theme2
33
# TODO: sphinxcontrib.katex 0.9.0 adds a local KaTeX server to speed up pre-rendering
44
# but it doesn't seem to work and hangs around idly. The initial thought is probably
55
# something related to Docker setup. We can investigate this later
@@ -9,5 +9,6 @@ tensorboard==2.10.0
99
# required to build torch.distributed.elastic.rendezvous.etcd* docs
1010
python-etcd==0.4.5
1111
sphinx-copybutton==0.5.0
12-
sphinx-panels==0.4.1
13-
myst-parser==0.18.1
12+
myst-parser==4.0.1
13+
sphinx-design==0.6.1
14+
sphinxcontrib-mermaid==1.0.0

0 commit comments

Comments
 (0)
0