Commit 46ece5e
committed
Added
The function takes an object with `__sycl_usm_array_interface__`
and creates approproate MemoryUSM* object depending the the type of
USM alocation the argument represents.
Example:
```
In [1]: import dpctl, dpctl.memory as dpm, dpctl.memory._memory as dpm_m
In [2]: import dpctl.tensor as dpt
In [3]: X = dpt.usm_ndarray((4, 5))
In [4]: dpm_m.create_MemoryUSM(X)
Out[4]: <SYCL(TM) USM-device allocated memory block of 160 bytes at 0xffffd556aa5f0000>
In [5]: X.usm_data
Out[5]: <SYCL(TM) USM-device allocated memory block of 160 bytes at 0xffffd556aa5f0000>
In [6]: class Duck_USMAllocation:
...: def __init__(self, buf, syclobj):
...: self.buf_ = buf
...: self.syclobj_ = syclobj
...:
In [7]: class Duck_USMAllocation:
...: def __init__(self, buf, syclobj):
...: self.buf_ = buf
...: self.syclobj_ = syclobj
...: @Property
...: def __sycl_usm_array_interface__(self):
...: iface = self.buf_.__sycl_usm_array_interface__
...: iface['syclobj'] = self.syclobj_
...: return iface
...:
In [8]: d = Duck_USMAllocation(X, X.sycl_device.filter_string)
In [9]: dpm_m.create_MemoryUSM(d)
Out[9]: <SYCL(TM) USM-device allocated memory block of 160 bytes at 0xffffd556aa5f0000>
```dpctl.memory.create_MemoryUSM
1 parent 3e2ea1c commit 46ece5e
2 files changed
+69
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
34 | 39 | | |
35 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
596 | 596 | | |
597 | 597 | | |
598 | 598 | | |
599 | | - | |
600 | | - | |
601 | | - | |
602 | | - | |
603 | | - | |
604 | | - | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
605 | 607 | | |
606 | 608 | | |
607 | 609 | | |
| |||
635 | 637 | | |
636 | 638 | | |
637 | 639 | | |
638 | | - | |
| 640 | + | |
| 641 | + | |
639 | 642 | | |
640 | 643 | | |
641 | | - | |
642 | | - | |
643 | | - | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
644 | 648 | | |
645 | 649 | | |
646 | 650 | | |
| |||
675 | 679 | | |
676 | 680 | | |
677 | 681 | | |
678 | | - | |
| 682 | + | |
| 683 | + | |
679 | 684 | | |
680 | 685 | | |
681 | 686 | | |
682 | | - | |
683 | | - | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
684 | 690 | | |
685 | 691 | | |
686 | 692 | | |
| |||
704 | 710 | | |
705 | 711 | | |
706 | 712 | | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
0 commit comments