MCPcopy Create free account
hub / github.com/akash-network/provider / parseGPU

Function parseGPU

bidengine/shellscript.go:63–108  ·  view source on GitHub ↗
(resource *rtypes.GPU)

Source from the content-addressed store, hash-verified

61}
62
63func parseGPU(resource *rtypes.GPU) gpuElement {
64 res := gpuElement{
65 Units: resource.Units.Value(),
66 Attributes: gpuAttributes{
67 Vendor: make(map[string]gpuVendorAttributes),
68 },
69 }
70
71 for _, attr := range resource.Attributes {
72 tokens := strings.Split(attr.Key, "/")
73
74 // vendor/nvidia/model/a100
75 switch tokens[0] {
76 case "vendor":
77 vendor := tokens[1]
78 model := tokens[3]
79
80 tokens = tokens[4:]
81
82 attrs := gpuVendorAttributes{
83 Model: model,
84 }
85
86 for i := 0; i < len(tokens); i += 2 {
87 key := tokens[i]
88 val := tokens[i+1]
89
90 switch key {
91 case "ram":
92 attrs.RAM = new(string)
93 *attrs.RAM = val
94 case "interface":
95 attrs.Interface = new(string)
96 *attrs.Interface = val
97 default:
98 continue
99 }
100 }
101
102 res.Attributes.Vendor[vendor] = attrs
103 default:
104 }
105 }
106
107 return res
108}
109
110func parseStorage(resource rtypes.Volumes) []storageElement {
111 res := make([]storageElement, 0, len(resource))

Callers 2

newDataForScriptFunction · 0.85

Calls

no outgoing calls

Tested by 1