| 230 | |
| 231 | |
| 232 | class Concatenate(ArrayExpr): |
| 233 | _parameters = ["array", "axis", "meta"] |
| 234 | |
| 235 | @functools.cached_property |
| 236 | def args(self): |
| 237 | return [self.array] + self.operands[len(self._parameters) :] |
| 238 | |
| 239 | @functools.cached_property |
| 240 | def _meta(self): |
| 241 | return self.operand("meta") |
| 242 | |
| 243 | @functools.cached_property |
| 244 | def chunks(self): |
| 245 | bds = [a.chunks for a in self.args] |
| 246 | chunks = ( |
| 247 | bds[0][: self.axis] |
| 248 | + (sum((bd[self.axis] for bd in bds), ()),) |
| 249 | + bds[0][self.axis + 1 :] |
| 250 | ) |
| 251 | return chunks |
| 252 | |
| 253 | @functools.cached_property |
| 254 | def _name(self): |
| 255 | return f"stack-{self.deterministic_token}" |
| 256 | |
| 257 | def _layer(self) -> dict: |
| 258 | axis = self.axis |
| 259 | cum_dims = [0] + list(accumulate(add, [len(a.chunks[axis]) for a in self.args])) |
| 260 | keys = list(product([self._name], *[range(len(bd)) for bd in self.chunks])) |
| 261 | names = [a.name for a in self.args] |
| 262 | |
| 263 | values = [ |
| 264 | (names[bisect(cum_dims, key[axis + 1]) - 1],) |
| 265 | + key[1 : axis + 1] |
| 266 | + (key[axis + 1] - cum_dims[bisect(cum_dims, key[axis + 1]) - 1],) |
| 267 | + key[axis + 2 :] |
| 268 | for key in keys |
| 269 | ] |
| 270 | |
| 271 | return dict(zip(keys, values)) |
| 272 | |
| 273 | |
| 274 | class FinalizeComputeArray(FinalizeCompute, ArrayExpr): |
no outgoing calls
no test coverage detected
searching dependent graphs…