|
40 | 40 |
|
41 | 41 | applicableBuildSets = build.applicableBuildSets { inherit path buildSets; }; |
42 | 42 |
|
| 43 | + buildConfigBackend = |
| 44 | + buildConfig: |
| 45 | + if buildConfig.cpu or false then |
| 46 | + "cpu" |
| 47 | + else if buildConfig ? cudaVersion then |
| 48 | + "cuda" |
| 49 | + else if buildConfig ? rocmVersion then |
| 50 | + "rocm" |
| 51 | + else if buildConfig ? xpuVersion then |
| 52 | + "xpu" |
| 53 | + else if buildConfig.metal or false then |
| 54 | + "metal" |
| 55 | + else |
| 56 | + throw "Cannot determine framework for build set"; |
| 57 | + |
43 | 58 | # For picking a default shell, etc. we want to use the following logic: |
44 | 59 | # |
45 | 60 | # - Prefer bundle builds over non-bundle builds. |
|
60 | 75 |
|
61 | 76 | buildConfig // { |
62 | 77 | bundleBuild = buildConfig.bundleBuild or false; |
63 | | - framework = |
64 | | - if buildConfig.cpu or false then |
65 | | - "cpu" |
66 | | - else if buildConfig ? cudaVersion then |
67 | | - "cuda" |
68 | | - else if buildConfig ? rocmVersion then |
69 | | - "rocm" |
70 | | - else if buildConfig ? xpuVersion then |
71 | | - "xpu" |
72 | | - else if buildConfig.metal or false then |
73 | | - "metal" |
74 | | - else |
75 | | - throw "Cannot determine framework for build set"; |
| 78 | + framework = buildConfigBackend buildConfig; |
76 | 79 | frameworkOrder = if buildConfig ? cudaVersion then 0 else 1; |
77 | 80 | frameworkVersion = |
78 | 81 | buildConfig.cudaVersion or buildConfig.rocmVersion or buildConfig.xpuVersion or "0.0"; |
|
138 | 141 | { |
139 | 142 | inherit bundle; |
140 | 143 |
|
| 144 | + # Bundles by backend. |
| 145 | + backendBundle = |
| 146 | + let |
| 147 | + backends = lib.unique (map (set: buildConfigBackend set.buildConfig) applicableBuildSets); |
| 148 | + in |
| 149 | + builtins.listToAttrs ( |
| 150 | + builtins.map (backend: { |
| 151 | + name = backend; |
| 152 | + value = build.mkTorchExtensionBundle { |
| 153 | + inherit path doGetKernelCheck; |
| 154 | + buildSets = builtins.filter ( |
| 155 | + set: buildConfigBackend set.buildConfig == backend |
| 156 | + ) applicableBuildSets; |
| 157 | + rev = revUnderscored; |
| 158 | + }; |
| 159 | + }) backends |
| 160 | + ); |
| 161 | + |
141 | 162 | default = bundle; |
142 | 163 |
|
143 | 164 | build-and-copy = writeScriptBin "build-and-copy" '' |
|
0 commit comments