/** Returns {@code create(pointer, sizes, strides, true)} */ public static ShortIndexer create(ShortPointer pointer, long[] sizes, long[] strides) { return create(pointer, sizes, strides, true); } /**
@Override public double getDouble(long... indices) { return get(indices); } @Override public ShortIndexer putDouble(long[] indices, double s) { return put(indices, (short)s); }
/** Returns {@code this} where {@code array/buffer[i * strides[0] + j] = s[offset:offset + length]} */ public abstract ShortIndexer put(long i, long j, short[] s, int offset, int length); /** Returns {@code this} where {@code array/buffer[i * strides[0] + j * strides[1] + k] = s} */
: (I)UShortIndexer.create(new ShortPointer((ShortBuffer)buffer), sizes, strides, false).indexable(this); case DEPTH_SHORT: return array != null ? (I)ShortIndexer.create((short[])array, sizes, strides).indexable(this) : direct ? (I)ShortIndexer.create((ShortBuffer)buffer, sizes, strides).indexable(this) : (I)ShortIndexer.create(new ShortPointer((ShortBuffer)buffer), sizes, strides, false).indexable(this); case DEPTH_INT: return array != null ? (I)IntIndexer.create((int[])array, sizes, strides).indexable(this)
: (I)UShortIndexer.create(new ShortPointer((ShortBuffer)buffer), sizes, strides, false).indexable(this); case DEPTH_SHORT: return array != null ? (I)ShortIndexer.create((short[])array, sizes, strides).indexable(this) : direct ? (I)ShortIndexer.create((ShortBuffer)buffer, sizes, strides).indexable(this) : (I)ShortIndexer.create(new ShortPointer((ShortBuffer)buffer), sizes, strides, false).indexable(this); case DEPTH_INT: return array != null ? (I)IntIndexer.create((int[])array, sizes, strides).indexable(this)
case DT_INT8: return (I)ByteIndexer.create(ptr.capacity(size), sizes, strides, direct).indexable(this); case DT_BFLOAT16: return (I)UShortIndexer.create(new ShortPointer(ptr).capacity(size/2), sizes, strides, direct).indexable(this); case DT_INT16: return (I)ShortIndexer.create(new ShortPointer(ptr).capacity(size/2), sizes, strides, direct).indexable(this); case DT_INT64: return (I)LongIndexer.create(new LongPointer(ptr).capacity(size/8), sizes, strides, direct).indexable(this); case DT_STRING:
/** Returns {@code create(pointer, { pointer.limit() - pointer.position() }, { 1 }, true)} */ public static ShortIndexer create(ShortPointer pointer) { return create(pointer, new long[] { pointer.limit() - pointer.position() }, ONE_STRIDE); }
/** Returns {@code this} where {@code array/buffer[i] = s[offset:offset + length]} */ public abstract ShortIndexer put(long i, short[] s, int offset, int length); /** Returns {@code this} where {@code array/buffer[i * strides[0] + j] = s} */
/** Returns {@code this} where {@code s[offset:offset + length] = array/buffer[i * strides[0] + j]} */ public abstract ShortIndexer get(long i, long j, short[] s, int offset, int length); /** Returns {@code array/buffer[i * strides[0] + j * strides[1] + k]} */
case HALF: this.pointer = new CudaPointer(allocationPoint.getPointers().getHostPointer(), length, 0).asShortPointer(); indexer = ShortIndexer.create((ShortPointer) pointer); break; case INT:
@Override public ShortIndexer putDouble(long[] indices, double s) { return put(indices, (short)s); } }
/** Returns {@code this} where {@code s[offset:offset + length] = array/buffer[i]} */ public abstract ShortIndexer get(long i, short[] s, int offset, int length); /** Returns {@code array/buffer[i * strides[0] + j]} */
setIndexer(ShortIndexer.create(((CudaPointer) this.pointer).asShortPointer()));
/** Returns {@code this} where {@code array/buffer[index(indices)] = s[offset:offset + length]} */ public abstract ShortIndexer put(long[] indices, short[] s, int offset, int length);
/** Returns {@code this} where {@code s[offset:offset + length] = array/buffer[index(indices)]} */ public abstract ShortIndexer get(long[] indices, short[] s, int offset, int length);
case HALF: this.pointer = new CudaPointer(allocationPoint.getPointers().getHostPointer(), length, 0).asShortPointer(); indexer = ShortIndexer.create((ShortPointer) pointer); break; case INT:
setIndexer(ShortIndexer.create(((CudaPointer) this.pointer).asShortPointer()));