Skip to content

Commit 8b3b72c

Browse files
committed
Added C/C++ install instructions.
1 parent 135fee6 commit 8b3b72c

File tree

1 file changed

+119
-95
lines changed

1 file changed

+119
-95
lines changed
Lines changed: 119 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<script>
2-
import FaRegClipboard from 'svelte-icons/fa/FaRegClipboard.svelte';
3-
import FaClipboardCheck from 'svelte-icons/fa/FaClipboardCheck.svelte'
2+
import FaRegClipboard from 'svelte-icons/fa/FaRegClipboard.svelte';
3+
import FaClipboardCheck from 'svelte-icons/fa/FaClipboardCheck.svelte';
44
let platforms = ['Windows', 'Linux', 'MacOS'];
5-
let languages = ['Python', 'C#'];
6-
let hardwareAccelerations = ['CPU', 'DirectML', 'CUDA'];
5+
let languages = ['Python', 'C', 'C++', 'C#'];
6+
let hardwareAccelerations = ['CPU', 'CUDA'];
77
// let builds = ['Stable', 'Preview (Nightly)'];
88
99
/**
@@ -18,7 +18,7 @@
1818
* @type {string | null}
1919
*/
2020
let selectedHardwareAcceleration = null;
21-
// For eventual nightly builds
21+
// For eventual nightly builds
2222
/**
2323
* @type {string | null}
2424
*/
@@ -36,52 +36,46 @@
3636
updateInstallationInstructions();
3737
};
3838
39-
// Function to dynamically copy text
40-
let copied = false;
41-
const copyCodeToClipboard = () => {
42-
const codeElement = document.querySelector('#installation-code');
43-
if (codeElement && codeElement.textContent) {
44-
const textToCopy = codeElement.textContent;
45-
// textToCopy && navigator.clipboard.writeText(textToCopy).then(() => {
46-
// alert('Copied to clipboard!');
47-
// }).catch(err => {
48-
// console.error('Failed to copy text: ', err);
49-
// });
50-
try {
51-
copied = true;
52-
setTimeout(() => {
53-
copied = false;
54-
}, 3000);
55-
navigator.clipboard.writeText(textToCopy);
56-
} catch (err) {
57-
console.error('Failed to copy:', err);
39+
// Function to dynamically copy text
40+
let copied = false;
41+
const copyCodeToClipboard = () => {
42+
const codeElement = document.querySelector('#installation-code');
43+
if (codeElement && codeElement.textContent) {
44+
const textToCopy = codeElement.textContent;
45+
// textToCopy && navigator.clipboard.writeText(textToCopy).then(() => {
46+
// alert('Copied to clipboard!');
47+
// }).catch(err => {
48+
// console.error('Failed to copy text: ', err);
49+
// });
50+
try {
51+
copied = true;
52+
setTimeout(() => {
53+
copied = false;
54+
}, 3000);
55+
navigator.clipboard.writeText(textToCopy);
56+
} catch (err) {
57+
console.error('Failed to copy:', err);
58+
}
5859
}
59-
}
60-
};
60+
};
6161
6262
const updateInstallationInstructions = () => {
63-
if (!selectedPlatform || !selectedLanguage || !selectedHardwareAcceleration) {
64-
installationInstructions = `<p>Please select a combination of resources.</p>`;
65-
return;
66-
}
67-
68-
switch (selectedLanguage) {
69-
case 'Python':
70-
switch (selectedHardwareAcceleration) {
71-
case 'CPU':
72-
installationInstructions = `
73-
<pre><code id="installation-code">pip install onnxruntime-genai</code></pre>
74-
`;
75-
break;
63+
if (!selectedPlatform || !selectedLanguage || !selectedHardwareAcceleration) {
64+
installationInstructions = `<p>Please select a combination of resources.</p>`;
65+
return;
66+
}
7667
77-
case 'DirectML':
78-
installationInstructions = `
79-
<pre><code id="installation-code">pip install onnxruntime-genai-directml</code></pre>
68+
switch (selectedLanguage) {
69+
case 'Python':
70+
switch (selectedHardwareAcceleration) {
71+
case 'CPU':
72+
installationInstructions = `
73+
<pre><code id="installation-code">pip install onnxruntime-genai</code></pre>
8074
`;
81-
break;
75+
break;
8276
83-
case 'CUDA':
84-
installationInstructions = `
77+
case 'CUDA':
78+
installationInstructions = `
8579
<ul class="list-decimal pl-4">
8680
<li>Ensure that the CUDA toolkit is installed.</li>
8781
<li>Download the CUDA toolkit from the <a href="https://developer.nvidia.com/cuda-toolkit-archive" target="_blank">CUDA Toolkit Archive</a>.</li>
@@ -101,44 +95,74 @@
10195
</li>
10296
</ul>
10397
`;
104-
break;
98+
break;
10599
106-
default:
107-
installationInstructions = `<p>Unsupported hardware acceleration option for Python.</p>`;
108-
}
109-
break;
100+
default:
101+
installationInstructions = `<p>Unsupported hardware acceleration option for Python.</p>`;
102+
}
103+
break;
110104
111-
case 'C#':
112-
switch (selectedHardwareAcceleration) {
113-
case 'CPU':
114-
installationInstructions = `
115-
<pre><code id="installation-code">dotnet add package Microsoft.ML.OnnxRuntimeGenAI</code></pre>
116-
`;
117-
break;
105+
case 'C':
106+
switch (selectedHardwareAcceleration) {
107+
case 'CPU':
108+
installationInstructions = `
109+
<p>Install Nuget package <a class="underline text-blue-700" href="https://www.nuget.org/packages/Microsoft.ML.OnnxRuntimeGenAI/">Microsoft.ML.OnnxRuntimeGenAI</a></code></a>
110+
`;
111+
break;
118112
119-
case 'DirectML':
120-
installationInstructions = `
121-
<pre><code id="installation-code">dotnet add package Microsoft.ML.OnnxRuntimeGenAI.DirectML</code></pre>
122-
`;
123-
break;
113+
case 'CUDA':
114+
installationInstructions = `
115+
<p>Install Nuget package <a class="underline text-blue-700" href="https://www.nuget.org/packages/Microsoft.ML.OnnxRuntimeGenAI.Cuda/">Microsoft.ML.OnnxRuntimeGenAI.Cuda</a></code></a>
116+
`;
117+
break;
118+
119+
default:
120+
installationInstructions = `<p>Unsupported hardware acceleration option for C.</p>`;
121+
}
122+
break;
123+
124+
case 'C++':
125+
switch (selectedHardwareAcceleration) {
126+
case 'CPU':
127+
installationInstructions = `
128+
<p>Install Nuget package <a href="https://www.nuget.org/packages/Microsoft.ML.OnnxRuntimeGenAI/">Microsoft.ML.OnnxRuntimeGenAI</a></code></a>
129+
`;
130+
break;
131+
132+
case 'CUDA':
133+
installationInstructions = `
134+
<p>Install Nuget package <a href="https://www.nuget.org/packages/Microsoft.ML.OnnxRuntimeGenAI.Cuda/">Microsoft.ML.OnnxRuntimeGenAI.Cuda</a></code></a>
135+
`;
136+
break;
124137
125-
case 'CUDA':
126-
installationInstructions = `
138+
default:
139+
installationInstructions = `<p>Unsupported hardware acceleration option for C.</p>`;
140+
}
141+
break;
142+
case 'C#':
143+
switch (selectedHardwareAcceleration) {
144+
case 'CPU':
145+
installationInstructions = `
146+
<pre><code id="installation-code">dotnet add package Microsoft.ML.OnnxRuntimeGenAI</code></pre>
147+
`;
148+
break;
149+
case 'CUDA':
150+
installationInstructions = `
127151
<p>Note: Only CUDA 11 is supported for versions 0.3.0 and earlier, and only CUDA 12 is supported for versions 0.4.0 and later.</p>
128152
<br/>
129153
<pre><code id="installation-code">dotnet add package Microsoft.ML.OnnxRuntimeGenAI.Cuda</code></pre>
130154
`;
131-
break;
155+
break;
132156
133-
default:
134-
installationInstructions = `<p>Unsupported hardware acceleration option for C#.</p>`;
135-
}
136-
break;
157+
default:
158+
installationInstructions = `<p>Unsupported hardware acceleration option for C#.</p>`;
159+
}
160+
break;
137161
138-
default:
139-
installationInstructions = `<p>Unsupported language selection.</p>`;
140-
}
141-
};
162+
default:
163+
installationInstructions = `<p>Unsupported language selection.</p>`;
164+
}
165+
};
142166
143167
// If required, can use this method to enable disabling.
144168
// const isDisabled = (/** @type {string} */ type, /** @type {string} */ value) => {
@@ -155,16 +179,16 @@
155179
role="tabpanel"
156180
aria-labelledby="tab2"
157181
>
158-
{#if copied}
159-
<div class="toast toast-top top-14 z-50" role="alert">
160-
<div class="alert alert-info">
161-
<div class="icon" style="width: 16px; height: 16px;">
162-
<FaClipboardCheck />
182+
{#if copied}
183+
<div class="toast toast-top top-14 z-50" role="alert">
184+
<div class="alert alert-info">
185+
<div class="icon" style="width: 16px; height: 16px;">
186+
<FaClipboardCheck />
187+
</div>
188+
<span>Code successfully copied!</span>
163189
</div>
164-
<span>Code successfully copied!</span>
165190
</div>
166-
</div>
167-
{/if}
191+
{/if}
168192
<div class="col-span-1 bg-success r-heading rounded p-2 text-xl">
169193
<h3>Platform</h3>
170194
</div>
@@ -185,7 +209,7 @@
185209
<h3>API</h3>
186210
</div>
187211
<div class="col-span-4">
188-
<div class="grid grid-cols-2 gap-4">
212+
<div class="grid grid-cols-4 gap-4">
189213
{#each languages as language}
190214
<button
191215
class="btn rounded {selectedLanguage === language ? 'btn-active btn-primary' : ''}"
@@ -201,7 +225,7 @@
201225
<h3>Hardware Acceleration</h3>
202226
</div>
203227
<div class="col-span-4">
204-
<div class="grid grid-cols-3 gap-4">
228+
<div class="grid grid-cols-2 gap-4">
205229
{#each hardwareAccelerations as hardwareAcceleration}
206230
<button
207231
class="btn h-20 rounded {selectedHardwareAcceleration === hardwareAcceleration
@@ -215,7 +239,7 @@
215239
</div>
216240
</div>
217241

218-
<!-- For eventual nightly use -->
242+
<!-- For eventual nightly use -->
219243
<!-- <div class="col-span-1 bg-success r-heading rounded p-2 text-xl">
220244
<h3>Build</h3>
221245
</div>
@@ -237,15 +261,15 @@
237261
</div>
238262
<div class="col-span-4 bg-base-300 rounded">
239263
<div class="p-4">
240-
<div id="installation-instructions">
241-
{@html installationInstructions}
242-
</div>
243-
{#if installationInstructions.includes('<pre><code')}
244-
<button class="btn btn-primary btn-sm mt-4" on:click={copyCodeToClipboard}>
245-
{" "}Copy code
246-
<span class="copy-btn-icon w-4"><FaRegClipboard/></span>
247-
</button>
248-
{/if}
249-
</div>
264+
<div id="installation-instructions">
265+
{@html installationInstructions}
266+
</div>
267+
{#if installationInstructions.includes('<pre><code')}
268+
<button class="btn btn-primary btn-sm mt-4" on:click={copyCodeToClipboard}>
269+
{' '}Copy code
270+
<span class="copy-btn-icon w-4"><FaRegClipboard /></span>
271+
</button>
272+
{/if}
273+
</div>
250274
</div>
251-
</div>
275+
</div>

0 commit comments

Comments
 (0)