1
- import { ActionContext , FunctionDomain , NasStorageClassEnum , ServerlessIac } from '../../types' ;
1
+ import {
2
+ ActionContext ,
3
+ FunctionDomain ,
4
+ FunctionGpuEnum ,
5
+ NasStorageClassEnum ,
6
+ ServerlessIac ,
7
+ } from '../../types' ;
2
8
import {
3
9
CODE_ZIP_SIZE_LIMIT ,
4
10
encodeBase64ForRosId ,
@@ -25,13 +31,25 @@ const storageClassMap = {
25
31
[ NasStorageClassEnum . EXTREME_STANDARD ] : { fileSystemType : 'extreme' , storageType : 'standard' } ,
26
32
[ NasStorageClassEnum . EXTREME_ADVANCE ] : { fileSystemType : 'extreme' , storageType : 'advance' } ,
27
33
} ;
34
+
28
35
const securityGroupRangeMap : { [ key : string ] : string } = {
29
36
TCP : '1/65535' ,
30
37
UDP : '1/65535' ,
31
38
ICMP : '-1/-1' ,
32
39
GRE : '-1/-1' ,
33
40
ALL : '-1/-1' ,
34
41
} ;
42
+ const gpuConfigMap = {
43
+ [ FunctionGpuEnum . TESLA_8 ] : { gpuMemorySize : 8192 , gpuType : 'fc.gpu.tesla.1' } ,
44
+ [ FunctionGpuEnum . TESLA_12 ] : { gpuMemorySize : 12288 , gpuType : 'fc.gpu.tesla.1' } ,
45
+ [ FunctionGpuEnum . TESLA_16 ] : { gpuMemorySize : 16384 , gpuType : 'fc.gpu.tesla.1' } ,
46
+ [ FunctionGpuEnum . AMPERE_8 ] : { gpuMemorySize : 8192 , gpuType : 'fc.gpu.ampere.1' } ,
47
+ [ FunctionGpuEnum . AMPERE_12 ] : { gpuMemorySize : 12288 , gpuType : 'fc.gpu.ampere.1' } ,
48
+ [ FunctionGpuEnum . AMPERE_16 ] : { gpuMemorySize : 16384 , gpuType : 'fc.gpu.ampere.1' } ,
49
+ [ FunctionGpuEnum . AMPERE_24 ] : { gpuMemorySize : 24576 , gpuType : 'fc.gpu.ampere.1' } ,
50
+ [ FunctionGpuEnum . ADA_48 ] : { gpuMemorySize : 49152 , gpuType : 'fc.gpu.ada.1' } ,
51
+ } ;
52
+
35
53
const transformSecurityRules = ( rules : Array < string > , ruleType : 'INGRESS' | 'EGRESS' ) => {
36
54
return rules . map ( ( rule ) => {
37
55
const [ protocol , cidrIp , portRange ] = rule . split ( ':' ) ;
@@ -49,6 +67,13 @@ const transformSecurityRules = (rules: Array<string>, ruleType: 'INGRESS' | 'EGR
49
67
} ) ;
50
68
} ;
51
69
70
+ const transformGpuConfig = ( gpu : FunctionDomain [ 'gpu' ] ) => {
71
+ if ( ! gpu ) {
72
+ return undefined ;
73
+ }
74
+
75
+ return gpuConfigMap [ gpu ] ;
76
+ } ;
52
77
export const resolveFunctions = (
53
78
scope : ros . Construct ,
54
79
functions : Array < FunctionDomain > | undefined ,
@@ -248,8 +273,9 @@ export const resolveFunctions = (
248
273
{
249
274
functionName : replaceReference ( fnc . name , context ) ,
250
275
memorySize : replaceReference ( fnc . memory , context ) ,
251
- timeout : replaceReference ( fnc . timeout , context ) ,
252
276
diskSize : fnc . storage ?. disk ,
277
+ gpuConfig : transformGpuConfig ( fnc . gpu ) ,
278
+ timeout : replaceReference ( fnc . timeout , context ) ,
253
279
environmentVariables : replaceReference ( fnc . environment , context ) ,
254
280
logConfig,
255
281
vpcConfig,
0 commit comments