MCPcopy Create free account
hub / github.com/devcontainers/cli / mergeGpuRequirements

Function mergeGpuRequirements

src/spec-node/imageMetadata.ts:225–243  ·  view source on GitHub ↗
(a: undefined | boolean | 'optional' | HostGPURequirements, b: undefined | boolean | 'optional' | HostGPURequirements)

Source from the content-addressed store, hash-verified

223}
224
225function mergeGpuRequirements(a: undefined | boolean | 'optional' | HostGPURequirements, b: undefined | boolean | 'optional' | HostGPURequirements): undefined | boolean | 'optional' | HostGPURequirements {
226 // simple cases if either are undefined/false we use the other one
227 if (a === undefined || a === false) {
228 return b;
229 } else if (b === undefined || b === false) {
230 return a;
231 } else if (a === 'optional' && b === 'optional') {
232 return 'optional';
233 } else {
234 const aObject = asHostGPURequirements(a);
235 const bObject = asHostGPURequirements(b);
236 const cores = Math.max(aObject.cores || 0, bObject.cores || 0);
237 const memory = Math.max(parseBytes(aObject.memory || '0'), parseBytes(bObject.memory || '0'));
238 return {
239 cores: cores ? cores : undefined,
240 memory: memory ? `${memory}` : undefined,
241 };
242 }
243}
244
245function asHostGPURequirements(a: undefined | boolean | 'optional' | HostGPURequirements): HostGPURequirements {
246 if (typeof a !== 'object') {

Callers

nothing calls this directly

Calls 2

asHostGPURequirementsFunction · 0.85
parseBytesFunction · 0.85

Tested by

no test coverage detected