-
Notifications
You must be signed in to change notification settings - Fork 3.7k
/
accelerator-type.ts
64 lines (54 loc) · 1.71 KB
/
accelerator-type.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import * as cdk from '@aws-cdk/core';
/**
* Supported Elastic Inference (EI) instance types for SageMaker instance-based production variants.
* EI instances provide on-demand GPU computing for inference.
*/
export class AcceleratorType {
/**
* ml.eia1.large
*/
public static readonly EIA1_LARGE = AcceleratorType.of('ml.eia1.large');
/**
* ml.eia1.medium
*/
public static readonly EIA1_MEDIUM = AcceleratorType.of('ml.eia1.medium');
/**
* ml.eia1.xlarge
*/
public static readonly EIA1_XLARGE = AcceleratorType.of('ml.eia1.xlarge');
/**
* ml.eia2.large
*/
public static readonly EIA2_LARGE = AcceleratorType.of('ml.eia2.large');
/**
* ml.eia2.medium
*/
public static readonly EIA2_MEDIUM = AcceleratorType.of('ml.eia2.medium');
/**
* ml.eia2.xlarge
*/
public static readonly EIA2_XLARGE = AcceleratorType.of('ml.eia2.xlarge');
/**
* Builds an AcceleratorType from a given string or token (such as a CfnParameter).
* @param acceleratorType An accelerator type as string
* @returns A strongly typed AcceleratorType
*/
public static of(acceleratorType: string): AcceleratorType {
return new AcceleratorType(acceleratorType);
}
private readonly acceleratorTypeIdentifier: string;
constructor(acceleratorType: string) {
if (cdk.Token.isUnresolved(acceleratorType) || acceleratorType.startsWith('ml.')) {
this.acceleratorTypeIdentifier = acceleratorType;
} else {
throw new Error(`instance type must start with 'ml.'; (got ${acceleratorType})`);
}
}
/**
* Return the accelerator type as a string
* @returns The accelerator type as a string
*/
public toString(): string {
return this.acceleratorTypeIdentifier;
}
}