1- import { ActionContext , FunctionDomain , NasStorageClassEnum , ServerlessIac } from '../../types' ;
1+ import {
2+ ActionContext ,
3+ FunctionDomain ,
4+ FunctionGpuEnum ,
5+ NasStorageClassEnum ,
6+ ServerlessIac ,
7+ } from '../../types' ;
28import {
39 CODE_ZIP_SIZE_LIMIT ,
410 encodeBase64ForRosId ,
@@ -25,13 +31,25 @@ const storageClassMap = {
2531 [ NasStorageClassEnum . EXTREME_STANDARD ] : { fileSystemType : 'extreme' , storageType : 'standard' } ,
2632 [ NasStorageClassEnum . EXTREME_ADVANCE ] : { fileSystemType : 'extreme' , storageType : 'advance' } ,
2733} ;
34+
2835const securityGroupRangeMap : { [ key : string ] : string } = {
2936 TCP : '1/65535' ,
3037 UDP : '1/65535' ,
3138 ICMP : '-1/-1' ,
3239 GRE : '-1/-1' ,
3340 ALL : '-1/-1' ,
3441} ;
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+
3553const transformSecurityRules = ( rules : Array < string > , ruleType : 'INGRESS' | 'EGRESS' ) => {
3654 return rules . map ( ( rule ) => {
3755 const [ protocol , cidrIp , portRange ] = rule . split ( ':' ) ;
@@ -49,6 +67,13 @@ const transformSecurityRules = (rules: Array<string>, ruleType: 'INGRESS' | 'EGR
4967 } ) ;
5068} ;
5169
70+ const transformGpuConfig = ( gpu : FunctionDomain [ 'gpu' ] ) => {
71+ if ( ! gpu ) {
72+ return undefined ;
73+ }
74+
75+ return gpuConfigMap [ gpu ] ;
76+ } ;
5277export const resolveFunctions = (
5378 scope : ros . Construct ,
5479 functions : Array < FunctionDomain > | undefined ,
@@ -248,8 +273,9 @@ export const resolveFunctions = (
248273 {
249274 functionName : replaceReference ( fnc . name , context ) ,
250275 memorySize : replaceReference ( fnc . memory , context ) ,
251- timeout : replaceReference ( fnc . timeout , context ) ,
252276 diskSize : fnc . storage ?. disk ,
277+ gpuConfig : transformGpuConfig ( fnc . gpu ) ,
278+ timeout : replaceReference ( fnc . timeout , context ) ,
253279 environmentVariables : replaceReference ( fnc . environment , context ) ,
254280 logConfig,
255281 vpcConfig,
0 commit comments