Skip to content

Commit e2296f5

Browse files
authored
Add libtorch to selector (pytorch#95)
I made libtorch and C++ selection mutually inclusive. You select one, the other is selected. You deselect one, the other is deselected.
1 parent a1d1e0c commit e2296f5

File tree

4 files changed

+158
-24
lines changed

4 files changed

+158
-24
lines changed

_includes/quick_start_local.html

+21-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<p>Select your preferences and run the install command. Please ensure that you are on the latest pip and numpy
22
packages. Anaconda is our recommended package manager. You can also
3-
<a href="{{ site.baseurl }}/get-started/previous-versions">install previous versions of PyTorch.</a>
3+
<a href="{{ site.baseurl }}/get-started/previous-versions">install previous versions of PyTorch</a>. Note that LibTorch is only available for C++.
44
</p>
55

66
<div class="row">
@@ -15,7 +15,7 @@
1515
<div class="option-text">Package</div>
1616
</div>
1717
<div class="col-md-12 title-block">
18-
<div class="option-text">Python</div>
18+
<div class="option-text">Language</div>
1919
</div>
2020
<div class="col-md-12 title-block">
2121
<div class="option-text">CUDA</div>
@@ -55,31 +55,37 @@
5555
<div class="col-md-12 title-block mobile-heading">
5656
<div class="option-text">Package</div>
5757
</div>
58-
<div class="col-md-4 option block selected" id="conda">
58+
<div class="col-md-3 option block selected" id="conda">
5959
<div class="option-text">Conda</div>
6060
</div>
61-
<div class="col-md-4 option block" id="pip">
61+
<div class="col-md-3 option block" id="pip">
6262
<div class="option-text">Pip</div>
6363
</div>
64-
<div class="col-md-4 option block" id="source">
64+
<div class="col-md-3 option block" id="libtorch">
65+
<div class="option-text">LibTorch</div>
66+
</div>
67+
<div class="col-md-3 option block" id="source">
6568
<div class="option-text">Source</div>
6669
</div>
6770
</div>
68-
<div class="row python">
71+
<div class="row language">
6972
<div class="col-md-12 title-block mobile-heading">
70-
<div class="option-text">Python</div>
73+
<div class="option-text">Language</div>
74+
</div>
75+
<div class="col-md-2-4 option block version" id="python2.7">
76+
<div class="option-text">Python 2.7</div>
7177
</div>
72-
<div class="col-md-3 option block version" id="python2.7">
73-
<div class="option-text">2.7</div>
78+
<div class="col-md-2-4 option block version" id="python3.5">
79+
<div class="option-text">Python 3.5</div>
7480
</div>
75-
<div class="col-md-3 option block version" id="python3.5">
76-
<div class="option-text">3.5</div>
81+
<div class="col-md-2-4 option block version selected" id="python3.6">
82+
<div class="option-text">Python 3.6</div>
7783
</div>
78-
<div class="col-md-3 option block version selected" id="python3.6">
79-
<div class="option-text">3.6</div>
84+
<div class="col-md-2-4 option block" id="python3.7">
85+
<div class="option-text">Python 3.7</div>
8086
</div>
81-
<div class="col-md-3 option block" id="python3.7">
82-
<div class="option-text">3.7</div>
87+
<div class="col-md-2-4 option block" id="cplusplus">
88+
<div class="option-text">C++</div>
8389
</div>
8490
</div>
8591
<div class="row cuda">

_sass/get-started.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@
167167
.row.ptbuild,
168168
.row.os,
169169
.row.package,
170-
.row.python,
170+
.row.language,
171171
.row.cuda {
172172
margin-bottom: rem(20px);
173173
@include desktop {

_sass/quick-start-module.scss

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,29 @@
11
.quick-starts {
22
background: $light_grey;
33

4+
.col-md-2-4 {
5+
position: relative;
6+
width: 100%;
7+
min-height: 1px;
8+
padding-right: 15px;
9+
padding-left: 15px;
10+
}
11+
12+
@media (min-width: 768px) {
13+
.col-md-2-4 {
14+
-webkit-box-flex: 0;
15+
-ms-flex: 0 0 20%;
16+
flex: 0 0 20%;
17+
max-width: 20%;
18+
}
19+
}
20+
421
.start-locally-col {
522
margin-bottom: rem(20px);
623
.row.ptbuild,
724
.row.os,
825
.row.package,
9-
.row.python,
26+
.row.language,
1027
.row.cuda {
1128
margin-bottom: rem(20px);
1229
@include desktop {

assets/quick-start-module.js

+118-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var opts = {
99
cuda: 'cuda9.0',
1010
os: getAnchorSelectedOS() || getDefaultSelectedOS(),
1111
pm: 'conda',
12-
python: 'python3.6',
12+
language: 'python3.6',
1313
ptbuild: 'stable',
1414
};
1515

@@ -21,7 +21,7 @@ var supportedCloudPlatforms = [
2121

2222
var os = $(".os > .option");
2323
var package = $(".package > .option");
24-
var python = $(".python > .option");
24+
var language = $(".language > .option");
2525
var cuda = $(".cuda > .option");
2626
var ptbuild = $(".ptbuild > .option");
2727

@@ -31,8 +31,8 @@ os.on("click", function() {
3131
package.on("click", function() {
3232
selectedOption(package, this, "pm");
3333
});
34-
python.on("click", function() {
35-
selectedOption(python, this, "python");
34+
language.on("click", function() {
35+
selectedOption(language, this, "language");
3636
});
3737
cuda.on("click", function() {
3838
selectedOption(cuda, this, "cuda");
@@ -43,7 +43,7 @@ ptbuild.on("click", function() {
4343

4444
// Force a selection onclick to get the right operating system selected from
4545
// the start
46-
$( document ).ready(function() {
46+
$(document).ready(function() {
4747
document.getElementById(opts.os).click();
4848
});
4949

@@ -82,6 +82,45 @@ function selectedOption(option, selection, category) {
8282
$(option).removeClass("selected");
8383
$(selection).addClass("selected");
8484
opts[category] = selection.id;
85+
if (category === "pm") {
86+
var elements = document.getElementsByClassName("language")[0].children;
87+
if (selection.id !== "libtorch" && elements["cplusplus"].classList.contains("selected")) {
88+
$(elements["cplusplus"]).removeClass("selected");
89+
$(elements["python3.7"]).addClass("selected");
90+
opts["language"] = "python3.7";
91+
} else if (selection.id == "libtorch") {
92+
for (var i = 0; i < elements.length; i++) {
93+
if (elements[i].id === "cplusplus") {
94+
$(elements[i]).addClass("selected");
95+
opts["language"] = "cplusplus";
96+
} else {
97+
$(elements[i]).removeClass("selected");
98+
}
99+
$(document.getElementsByClassName("ptbuild")[0].children["stable"]).removeClass("selected");
100+
$(document.getElementsByClassName("ptbuild")[0].children["preview"]).addClass("selected");
101+
opts["ptbuild"] = "preview";
102+
}
103+
}
104+
} else if (category === "language") {
105+
var elements = document.getElementsByClassName("package")[0].children;
106+
if (selection.id !== "cplusplus" && elements["libtorch"].classList.contains("selected")) {
107+
$(elements["libtorch"]).removeClass("selected");
108+
$(elements["pip"]).addClass("selected");
109+
opts["pm"] = "pip";
110+
} else if (selection.id == "cplusplus") {
111+
for (var i = 0; i < elements.length; i++) {
112+
if (elements[i].id === "libtorch") {
113+
$(elements[i]).addClass("selected");
114+
opts["pm"] = "libtorch";
115+
} else {
116+
$(elements[i]).removeClass("selected");
117+
}
118+
$(document.getElementsByClassName("ptbuild")[0].children["stable"]).removeClass("selected");
119+
$(document.getElementsByClassName("ptbuild")[0].children["preview"]).addClass("selected");
120+
opts["ptbuild"] = "preview";
121+
}
122+
}
123+
}
85124
commandMessage(buildMatcher());
86125
if (category === "os") {
87126
display(opts.os, 'installation', 'os');
@@ -114,7 +153,7 @@ function buildMatcher() {
114153
"," +
115154
opts.cuda.toLowerCase() +
116155
"," +
117-
opts.python.toLowerCase()
156+
opts.language.toLowerCase()
118157
);
119158
}
120159

@@ -418,6 +457,42 @@ function commandMessage(key) {
418457
"stable,pip,windows,cuda9.2,python3.7":
419458
"pip3 install http://download.pytorch.org/whl/cu92/torch-0.4.1-cp37-cp37m-win_amd64.whl<br/>pip3 install torchvision",
420459

460+
"stable,libtorch,linux,cudanone,cplusplus":
461+
"# Currently only available as a Preview.",
462+
463+
"stable,libtorch,linux,cuda8,cplusplus":
464+
"# Currently only available as a Preview.",
465+
466+
"stable,libtorch,linux,cuda9.0,cplusplus":
467+
"# Currently only available as a Preview.",
468+
469+
"stable,libtorch,linux,cuda9.2,cplusplus":
470+
"# Currently only available as a Preview.",
471+
472+
"stable,libtorch,macos,cudanone,cplusplus":
473+
"# Currently only available as a Preview.",
474+
475+
"stable,libtorch,macos,cuda8,cplusplus":
476+
"# Currently only available as a Preview.",
477+
478+
"stable,libtorch,macos,cuda9.0,cplusplus":
479+
"# Currently only available as a Preview.",
480+
481+
"stable,libtorch,macos,cuda9.2,cplusplus":
482+
"# Currently only available as a Preview.",
483+
484+
"stable,libtorch,windows,cudanone,cplusplus":
485+
"# Currently only available as a Preview.",
486+
487+
"stable,libtorch,windows,cuda8,cplusplus":
488+
"# Currently only available as a Preview.",
489+
490+
"stable,libtorch,windows,cuda9.0,cplusplus":
491+
"# Currently only available as a Preview.",
492+
493+
"stable,libtorch,windows,cuda9.2,cplusplus":
494+
"# Currently only available as a Preview.",
495+
421496
"preview,conda,linux,cuda8,python2.7":
422497
"conda install pytorch-nightly -c pytorch",
423498

@@ -704,7 +779,43 @@ function commandMessage(key) {
704779
"# Preview Build Not Yet Available on Windows.",
705780

706781
"preview,pip,windows,cuda9.2,python3.7":
707-
"# Preview Build Not Yet Available on Windows."
782+
"# Preview Build Not Yet Available on Windows.",
783+
784+
"preview,libtorch,linux,cudanone,cplusplus":
785+
"Download here: <a href='https://download.pytorch.org/libtorch/nightly/cpu/libtorch-shared-with-deps-latest.zip'>https://download.pytorch.org/libtorch/nightly/cpu/libtorch-shared-with-deps-latest.zip</a>",
786+
787+
"preview,libtorch,linux,cuda8,cplusplus":
788+
"Download here: <a href='https://download.pytorch.org/libtorch/nightly/cu80/libtorch-shared-with-deps-latest.zip'>https://download.pytorch.org/libtorch/nightly/cu80/libtorch-shared-with-deps-latest.zip</a>",
789+
790+
"preview,libtorch,linux,cuda9.0,cplusplus":
791+
"Download here: <a href='https://download.pytorch.org/libtorch/nightly/cu90/libtorch-shared-with-deps-latest.zip'>https://download.pytorch.org/libtorch/nightly/cu90/libtorch-shared-with-deps-latest.zip</a>",
792+
793+
"preview,libtorch,linux,cuda9.2,cplusplus":
794+
"Download here: <a href='https://download.pytorch.org/libtorch/nightly/cu9.2/libtorch-shared-with-deps-latest.zip'>https://download.pytorch.org/libtorch/nightly/cu9.2/libtorch-shared-with-deps-latest.zip</a>",
795+
796+
"preview,libtorch,macos,cudanone,cplusplus":
797+
"Download here: <a href='https://download.pytorch.org/libtorch/nightly/cpu/libtorch-macos-latest.zip'>https://download.pytorch.org/libtorch/nightly/cpu/libtorch-macos-latest.zip</a>",
798+
799+
"preview,libtorch,macos,cuda8,cplusplus":
800+
"# Currently only available CPU-only / no CUDA.",
801+
802+
"preview,libtorch,macos,cuda9.0,cplusplus":
803+
"# Currently only available CPU-only / no CUDA.",
804+
805+
"preview,libtorch,macos,cuda9.2,cplusplus":
806+
"# Currently only available CPU-only / no CUDA.",
807+
808+
"preview,libtorch,windows,cudanone,cplusplus":
809+
"# Not currently available on Windows.",
810+
811+
"preview,libtorch,windows,cuda8,cplusplus":
812+
"# Not currently available on Windows.",
813+
814+
"preview,libtorch,windows,cuda9.0,cplusplus":
815+
"# Not currently available on Windows.",
816+
817+
"preview,libtorch,windows,cuda9.2,cplusplus":
818+
"# Not currently available on Windows.",
708819
};
709820

710821
if (!object.hasOwnProperty(key)) {

0 commit comments

Comments
 (0)