A base implementation of the NDArray that does nothing. This can be used for overriding the NDArray with only part of the interface implemented. This interface should only be used for the NDArray implementations that do not plan to implement a large portion of the interface. For the ones
| 34 | * {@link NDArray} so that the unsupported operations are better highlighted in the code. |
| 35 | */ |
| 36 | public abstract class NDArrayAdapter implements NDArray { |
| 37 | |
| 38 | private static final String UNSUPPORTED_MSG = |
| 39 | "This NDArray implementation does not currently support this operation"; |
| 40 | |
| 41 | protected NDManager manager; |
| 42 | protected NDManager alternativeManager; |
| 43 | protected NDArray alternativeArray; |
| 44 | |
| 45 | protected Shape shape; |
| 46 | protected DataType dataType; |
| 47 | protected String name; |
| 48 | protected boolean isClosed; |
| 49 | protected String uid; |
| 50 | |
| 51 | protected NDArrayAdapter( |
| 52 | NDManager manager, |
| 53 | NDManager alternativeManager, |
| 54 | Shape shape, |
| 55 | DataType dataType, |
| 56 | String uid) { |
| 57 | this.manager = manager; |
| 58 | this.alternativeManager = alternativeManager; |
| 59 | this.shape = shape; |
| 60 | this.dataType = dataType; |
| 61 | this.uid = uid; |
| 62 | } |
| 63 | |
| 64 | /** {@inheritDoc} */ |
| 65 | @Override |
| 66 | public NDManager getManager() { |
| 67 | return manager; |
| 68 | } |
| 69 | |
| 70 | /** {@inheritDoc} */ |
| 71 | @Override |
| 72 | public void attach(NDManager manager) { |
| 73 | detach(); |
| 74 | this.manager = manager; |
| 75 | manager.attachInternal(getUid(), this); |
| 76 | alternativeManager = ((BaseNDManager) manager).getAlternativeManager(); |
| 77 | if (alternativeManager == null) { |
| 78 | // to prevent hybrid engine memory leak |
| 79 | alternativeManager = manager; |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | /** {@inheritDoc} */ |
| 84 | @Override |
| 85 | public void tempAttach(NDManager manager) { |
| 86 | NDManager original = this.manager; |
| 87 | detach(); |
| 88 | this.manager = manager; |
| 89 | manager.tempAttachInternal(original, getUid(), this); |
| 90 | } |
| 91 | |
| 92 | /** {@inheritDoc} */ |
| 93 | @Override |
nothing calls this directly
no outgoing calls
no test coverage detected