| 543 | |
| 544 | |
| 545 | class GUfuncLeafExpr(ArrayExpr): |
| 546 | _parameters = [ |
| 547 | "array", |
| 548 | "i", |
| 549 | "name_prefix", |
| 550 | "loop_output_chunks", |
| 551 | "core_shapes", |
| 552 | "ocd", |
| 553 | "nout", |
| 554 | "input_meta", |
| 555 | "loop_output_shape", |
| 556 | ] |
| 557 | |
| 558 | @functools.cached_property |
| 559 | def _meta(self): |
| 560 | return meta_from_array(self.input_meta, len(self._shape)) |
| 561 | |
| 562 | @functools.cached_property |
| 563 | def _name(self): |
| 564 | return "%s_%d-%s" % (self.name_prefix, self.i, self.array._name.split("-")[-1]) |
| 565 | |
| 566 | @functools.cached_property |
| 567 | def _shape(self): |
| 568 | core_output_shape = tuple(self.core_shapes[d] for d in self.ocd) |
| 569 | return self.loop_output_shape + core_output_shape |
| 570 | |
| 571 | @functools.cached_property |
| 572 | def chunks(self): |
| 573 | output_chunks = self.loop_output_chunks + tuple( |
| 574 | self.core_shapes[d] for d in self.ocd |
| 575 | ) |
| 576 | return normalize_chunks(output_chunks, self._shape, dtype=self._meta.dtype) |
| 577 | |
| 578 | def _layer(self): |
| 579 | core_chunkinds = len(self.ocd) * (0,) |
| 580 | leaf_dsk = { |
| 581 | (self._name,) |
| 582 | + key[1:] |
| 583 | + core_chunkinds: ((getitem, key, self.i) if self.nout else key) |
| 584 | for key in list(flatten(self.array.__dask_keys__())) |
| 585 | } |
| 586 | return leaf_dsk |
| 587 | |
| 588 | |
| 589 | class gufunc: |