parent
53d3bd1269
commit
451d9d57fd
|
@ -1734,6 +1734,7 @@ typedef nd4j::graph::RandomGenerator OpaqueRandomGenerator;
|
||||||
ND4J_EXPORT OpaqueContext* createGraphContext(int nodeId);
|
ND4J_EXPORT OpaqueContext* createGraphContext(int nodeId);
|
||||||
ND4J_EXPORT OpaqueRandomGenerator* getGraphContextRandomGenerator(OpaqueContext* ptr);
|
ND4J_EXPORT OpaqueRandomGenerator* getGraphContextRandomGenerator(OpaqueContext* ptr);
|
||||||
ND4J_EXPORT void ctxAllowHelpers(OpaqueContext* ptr, bool reallyAllow);
|
ND4J_EXPORT void ctxAllowHelpers(OpaqueContext* ptr, bool reallyAllow);
|
||||||
|
ND4J_EXPORT void ctxShapeFunctionOverride(OpaqueContext* ptr, bool reallyOverride);
|
||||||
ND4J_EXPORT void markGraphContextInplace(OpaqueContext* ptr, bool reallyInplace);
|
ND4J_EXPORT void markGraphContextInplace(OpaqueContext* ptr, bool reallyInplace);
|
||||||
ND4J_EXPORT void setGraphContextCudaContext(OpaqueContext* ptr, void *stream, void *reductionPointer, void *allocationPointer);
|
ND4J_EXPORT void setGraphContextCudaContext(OpaqueContext* ptr, void *stream, void *reductionPointer, void *allocationPointer);
|
||||||
ND4J_EXPORT void setGraphContextInputArray(OpaqueContext* ptr, int index, void *buffer, void *shapeInfo, void *specialBuffer, void *specialShapeInfo);
|
ND4J_EXPORT void setGraphContextInputArray(OpaqueContext* ptr, int index, void *buffer, void *shapeInfo, void *specialBuffer, void *specialShapeInfo);
|
||||||
|
|
|
@ -3104,6 +3104,10 @@ const char* lastErrorMessage() {
|
||||||
return nd4j::LaunchContext::defaultContext()->errorReference()->errorMessage();
|
return nd4j::LaunchContext::defaultContext()->errorReference()->errorMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ctxShapeFunctionOverride(OpaqueContext* ptr, bool reallyOverride) {
|
||||||
|
ptr->setShapeFunctionOverride(reallyOverride);
|
||||||
|
}
|
||||||
|
|
||||||
int binaryLevel() {
|
int binaryLevel() {
|
||||||
#ifdef CPU_FEATURES
|
#ifdef CPU_FEATURES
|
||||||
|
|
||||||
|
|
|
@ -3559,6 +3559,10 @@ const char* lastErrorMessage() {
|
||||||
return nd4j::LaunchContext::defaultContext()->errorReference()->errorMessage();
|
return nd4j::LaunchContext::defaultContext()->errorReference()->errorMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ctxShapeFunctionOverride(OpaqueContext* ptr, bool reallyOverride) {
|
||||||
|
ptr->setShapeFunctionOverride(reallyOverride);
|
||||||
|
}
|
||||||
|
|
||||||
int binaryLevel() {
|
int binaryLevel() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,9 @@ namespace nd4j {
|
||||||
std::vector<NDArray*> _handles;
|
std::vector<NDArray*> _handles;
|
||||||
|
|
||||||
bool _helpersAllowed = true;
|
bool _helpersAllowed = true;
|
||||||
|
|
||||||
|
// in some cases we might be able to skip shape function for validation purposes
|
||||||
|
bool _shapeFunctionOverride = false;
|
||||||
public:
|
public:
|
||||||
Context(ContextPrototype* prototype, VariableSpace* variableSpace);
|
Context(ContextPrototype* prototype, VariableSpace* variableSpace);
|
||||||
|
|
||||||
|
@ -196,9 +199,11 @@ namespace nd4j {
|
||||||
|
|
||||||
void setCudaContext(Nd4jPointer cudaStream, Nd4jPointer reductionPointer, Nd4jPointer allocationPointer);
|
void setCudaContext(Nd4jPointer cudaStream, Nd4jPointer reductionPointer, Nd4jPointer allocationPointer);
|
||||||
|
|
||||||
|
|
||||||
void allowHelpers(bool reallyAllow);
|
void allowHelpers(bool reallyAllow);
|
||||||
bool helpersAllowed();
|
bool helpersAllowed();
|
||||||
|
|
||||||
|
void setShapeFunctionOverride(bool reallyOverride);
|
||||||
|
bool shapeFunctionOverride();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -484,6 +484,14 @@ namespace nd4j {
|
||||||
for (auto b:bArgs)
|
for (auto b:bArgs)
|
||||||
_bArgs.push_back(b);
|
_bArgs.push_back(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Context::setShapeFunctionOverride(bool reallyOverride) {
|
||||||
|
_shapeFunctionOverride = reallyOverride;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Context::shapeFunctionOverride() {
|
||||||
|
return _shapeFunctionOverride;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -189,6 +189,11 @@ namespace nd4j {
|
||||||
shapeStart = std::chrono::system_clock::now();
|
shapeStart = std::chrono::system_clock::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if we override shape function, we'll return size of fastPath
|
||||||
|
if (ctx.isFastPath() && ctx.shapeFunctionOverride()) {
|
||||||
|
return (int) ctx.fastpath_out().size();
|
||||||
|
}
|
||||||
|
|
||||||
auto outSha = this->calculateOutputShape(&inSha, ctx);
|
auto outSha = this->calculateOutputShape(&inSha, ctx);
|
||||||
results = outSha->size();
|
results = outSha->size();
|
||||||
|
|
||||||
|
|
|
@ -136,4 +136,10 @@ public interface OpContext extends AutoCloseable {
|
||||||
* @param reallyAllow
|
* @param reallyAllow
|
||||||
*/
|
*/
|
||||||
void allowHelpers(boolean reallyAllow);
|
void allowHelpers(boolean reallyAllow);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This methos allows to disape outputs validation via shape function
|
||||||
|
* @param reallyOverride
|
||||||
|
*/
|
||||||
|
void shapeFunctionOverride(boolean reallyOverride);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1125,6 +1125,7 @@ public interface NativeOps {
|
||||||
void setGraphContextIArguments(OpaqueContext ptr, LongPointer arguments, int numberOfArguments);
|
void setGraphContextIArguments(OpaqueContext ptr, LongPointer arguments, int numberOfArguments);
|
||||||
void setGraphContextBArguments(OpaqueContext ptr, BooleanPointer arguments, int numberOfArguments);
|
void setGraphContextBArguments(OpaqueContext ptr, BooleanPointer arguments, int numberOfArguments);
|
||||||
void ctxAllowHelpers(OpaqueContext ptr, boolean reallyAllow);
|
void ctxAllowHelpers(OpaqueContext ptr, boolean reallyAllow);
|
||||||
|
void ctxShapeFunctionOverride(OpaqueContext ptr, boolean reallyOverride);
|
||||||
void deleteGraphContext(OpaqueContext ptr);
|
void deleteGraphContext(OpaqueContext ptr);
|
||||||
|
|
||||||
OpaqueRandomGenerator createRandomGenerator(long rootSeed, long nodeSeed);
|
OpaqueRandomGenerator createRandomGenerator(long rootSeed, long nodeSeed);
|
||||||
|
|
|
@ -2282,7 +2282,7 @@ public class CudaExecutioner extends DefaultOpExecutioner {
|
||||||
|
|
||||||
Nd4j.getExecutioner().commit();
|
Nd4j.getExecutioner().commit();
|
||||||
|
|
||||||
//
|
boolean shapeOverride = false;
|
||||||
if (op.numOutputArguments() == 0 && !op.isInplaceCall()) {
|
if (op.numOutputArguments() == 0 && !op.isInplaceCall()) {
|
||||||
try {
|
try {
|
||||||
val list = this.calculateOutputShape(op);
|
val list = this.calculateOutputShape(op);
|
||||||
|
@ -2292,6 +2292,7 @@ public class CudaExecutioner extends DefaultOpExecutioner {
|
||||||
for (val shape: list)
|
for (val shape: list)
|
||||||
op.addOutputArgument(Nd4j.create(shape));
|
op.addOutputArgument(Nd4j.create(shape));
|
||||||
|
|
||||||
|
shapeOverride = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ND4JIllegalStateException("Op name " + op.opName() + " - no output arrays were provided and calculateOutputShape failed to execute", e);
|
throw new ND4JIllegalStateException("Op name " + op.opName() + " - no output arrays were provided and calculateOutputShape failed to execute", e);
|
||||||
}
|
}
|
||||||
|
@ -2302,6 +2303,10 @@ public class CudaExecutioner extends DefaultOpExecutioner {
|
||||||
val name = op.opName();
|
val name = op.opName();
|
||||||
try (val context = (CudaOpContext) buildContext()) {
|
try (val context = (CudaOpContext) buildContext()) {
|
||||||
|
|
||||||
|
// optionally skip shape validation on op execution
|
||||||
|
if (shapeOverride)
|
||||||
|
context.shapeFunctionOverride(true);
|
||||||
|
|
||||||
context.markInplace(op.isInplaceCall());
|
context.markInplace(op.isInplaceCall());
|
||||||
|
|
||||||
// transferring rng state
|
// transferring rng state
|
||||||
|
|
|
@ -141,4 +141,9 @@ public class CudaOpContext extends BaseOpContext implements OpContext {
|
||||||
public void allowHelpers(boolean reallyAllow) {
|
public void allowHelpers(boolean reallyAllow) {
|
||||||
nativeOps.ctxAllowHelpers(context, reallyAllow);
|
nativeOps.ctxAllowHelpers(context, reallyAllow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void shapeFunctionOverride(boolean reallyOverride) {
|
||||||
|
nativeOps.ctxShapeFunctionOverride(context, reallyOverride);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3100,6 +3100,7 @@ public native void deleteShapeBuffer(OpaqueConstantDataBuffer ptr);
|
||||||
public native OpaqueContext createGraphContext(int nodeId);
|
public native OpaqueContext createGraphContext(int nodeId);
|
||||||
public native OpaqueRandomGenerator getGraphContextRandomGenerator(OpaqueContext ptr);
|
public native OpaqueRandomGenerator getGraphContextRandomGenerator(OpaqueContext ptr);
|
||||||
public native void ctxAllowHelpers(OpaqueContext ptr, @Cast("bool") boolean reallyAllow);
|
public native void ctxAllowHelpers(OpaqueContext ptr, @Cast("bool") boolean reallyAllow);
|
||||||
|
public native void ctxShapeFunctionOverride(OpaqueContext ptr, @Cast("bool") boolean reallyOverride);
|
||||||
public native void markGraphContextInplace(OpaqueContext ptr, @Cast("bool") boolean reallyInplace);
|
public native void markGraphContextInplace(OpaqueContext ptr, @Cast("bool") boolean reallyInplace);
|
||||||
public native void setGraphContextCudaContext(OpaqueContext ptr, Pointer stream, Pointer reductionPointer, Pointer allocationPointer);
|
public native void setGraphContextCudaContext(OpaqueContext ptr, Pointer stream, Pointer reductionPointer, Pointer allocationPointer);
|
||||||
public native void setGraphContextInputArray(OpaqueContext ptr, int index, Pointer buffer, Pointer shapeInfo, Pointer specialBuffer, Pointer specialShapeInfo);
|
public native void setGraphContextInputArray(OpaqueContext ptr, int index, Pointer buffer, Pointer shapeInfo, Pointer specialBuffer, Pointer specialShapeInfo);
|
||||||
|
@ -3634,25 +3635,7 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
// #include <execution/AffinityManager.h>
|
// #include <execution/AffinityManager.h>
|
||||||
|
|
||||||
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator -") NDArray subtract(float arg0, @Const @ByRef NDArray arg1);
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator -") NDArray subtract(@Cast("const float16") short arg0, @Const @ByRef NDArray arg1);
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator -") NDArray subtract(double arg0, @Const @ByRef NDArray arg1);
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator -") NDArray subtract(int arg0, @Const @ByRef NDArray arg1);
|
|
||||||
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator +") NDArray add(float arg0, @Const @ByRef NDArray arg1);
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator +") NDArray add(@Cast("const float16") short arg0, @Const @ByRef NDArray arg1);
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator +") NDArray add(double arg0, @Const @ByRef NDArray arg1);
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator +") NDArray add(int arg0, @Const @ByRef NDArray arg1);
|
|
||||||
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator *") NDArray multiply(float arg0, @Const @ByRef NDArray arg1);
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator *") NDArray multiply(@Cast("const float16") short arg0, @Const @ByRef NDArray arg1);
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator *") NDArray multiply(double arg0, @Const @ByRef NDArray arg1);
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator *") NDArray multiply(int arg0, @Const @ByRef NDArray arg1);
|
|
||||||
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator /") NDArray divide(float arg0, @Const @ByRef NDArray arg1);
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator /") NDArray divide(@Cast("const float16") short arg0, @Const @ByRef NDArray arg1);
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator /") NDArray divide(double arg0, @Const @ByRef NDArray arg1);
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator /") NDArray divide(int arg0, @Const @ByRef NDArray arg1);
|
|
||||||
|
|
||||||
@Namespace("nd4j") public static native @ByVal NDArray mmul(@Const @ByRef NDArray arg0, @Const @ByRef NDArray arg1);
|
@Namespace("nd4j") public static native @ByVal NDArray mmul(@Const @ByRef NDArray arg0, @Const @ByRef NDArray arg1);
|
||||||
|
|
||||||
|
@ -3903,9 +3886,9 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
* axis - axis along which to repeat elements
|
* axis - axis along which to repeat elements
|
||||||
* repeats - number of repetitions
|
* repeats - number of repetitions
|
||||||
*/
|
*/
|
||||||
public native NDArray repeat(int axis, @StdVector IntPointer repeats);
|
public native @ByVal NDArray repeat(int axis, @StdVector IntPointer repeats);
|
||||||
public native NDArray repeat(int axis, @StdVector IntBuffer repeats);
|
public native @ByVal NDArray repeat(int axis, @StdVector IntBuffer repeats);
|
||||||
public native NDArray repeat(int axis, @StdVector int[] repeats);
|
public native @ByVal NDArray repeat(int axis, @StdVector int[] repeats);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method fills this array with zeros
|
* This method fills this array with zeros
|
||||||
|
@ -3918,14 +3901,7 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
* @param array
|
* @param array
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static native @ByVal NDArray quantize(@ByRef NDArray array);
|
public static native @ByVal NDArray quantize(@Const @ByRef NDArray array);
|
||||||
|
|
||||||
/**
|
|
||||||
* This method returns quantized copy of given array
|
|
||||||
*
|
|
||||||
* @param array
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fill target array by repeating current array
|
* fill target array by repeating current array
|
||||||
|
@ -3946,10 +3922,9 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
/**
|
/**
|
||||||
* cast array elements to given dtype
|
* cast array elements to given dtype
|
||||||
*/
|
*/
|
||||||
|
public native @ByVal NDArray cast(@Cast("nd4j::DataType") int dtype);
|
||||||
|
|
||||||
public native NDArray cast(@Cast("nd4j::DataType") int dtype);
|
public native void cast(@ByRef NDArray target, @Cast("nd4j::DataType") int dtype);
|
||||||
|
|
||||||
public native void cast(NDArray target, @Cast("nd4j::DataType") int dtype);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns _context
|
* returns _context
|
||||||
|
@ -4120,26 +4095,12 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
/**
|
/**
|
||||||
* this method assigns given value to all elements in array
|
* this method assigns given value to all elements in array
|
||||||
*/
|
*/
|
||||||
public native void assign(double value, @Cast("bool") boolean allowParallelism/*=true*/);
|
|
||||||
public native void assign(double value);
|
|
||||||
public native void assign(float value, @Cast("bool") boolean allowParallelism/*=true*/);
|
|
||||||
public native void assign(float value);
|
|
||||||
public native void assign(@Cast("const float16") short value, @Cast("bool") boolean allowParallelism/*=true*/);
|
|
||||||
public native void assign(@Cast("const float16") short value);
|
|
||||||
public native void assign(@Cast("const Nd4jLong") long value, @Cast("bool") boolean allowParallelism/*=true*/);
|
|
||||||
public native void assign(@Cast("const Nd4jLong") long value);
|
|
||||||
public native void assign(int value, @Cast("bool") boolean allowParallelism/*=true*/);
|
|
||||||
public native void assign(int value);
|
|
||||||
public native void assign(@Cast("const uint8_t") byte value, @Cast("bool") boolean allowParallelism/*=true*/);
|
|
||||||
public native void assign(@Cast("const uint8_t") byte value);
|
|
||||||
public native void assign(@Cast("const bool") boolean value, @Cast("bool") boolean allowParallelism/*=true*/);
|
|
||||||
public native void assign(@Cast("const bool") boolean value);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns new copy of this array, optionally in different order
|
* returns new copy of this array, optionally in different order
|
||||||
*/
|
*/
|
||||||
public native NDArray dup(byte newOrder/*='a'*/);
|
public native @ByVal NDArray dup(byte newOrder/*='a'*/);
|
||||||
public native NDArray dup();
|
public native @ByVal NDArray dup();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns sum of all elements of array
|
* returns sum of all elements of array
|
||||||
|
@ -4176,9 +4137,9 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
* index - the number of array to be returned among set of possible arrays
|
* index - the number of array to be returned among set of possible arrays
|
||||||
* dimensions - array of dimensions to point on
|
* dimensions - array of dimensions to point on
|
||||||
*/
|
*/
|
||||||
public native NDArray tensorAlongDimension(@Cast("Nd4jLong") long index, @StdVector IntPointer dimensions);
|
public native @ByVal NDArray tensorAlongDimension(@Cast("Nd4jLong") long index, @StdVector IntPointer dimensions);
|
||||||
public native NDArray tensorAlongDimension(@Cast("Nd4jLong") long index, @StdVector IntBuffer dimensions);
|
public native @ByVal NDArray tensorAlongDimension(@Cast("Nd4jLong") long index, @StdVector IntBuffer dimensions);
|
||||||
public native NDArray tensorAlongDimension(@Cast("Nd4jLong") long index, @StdVector int[] dimensions);
|
public native @ByVal NDArray tensorAlongDimension(@Cast("Nd4jLong") long index, @StdVector int[] dimensions);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the number of arrays pointing on specified dimension(s)
|
* returns the number of arrays pointing on specified dimension(s)
|
||||||
|
@ -4200,54 +4161,54 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
* add given row vector to all rows of this array
|
* add given row vector to all rows of this array
|
||||||
* row - row vector to add
|
* row - row vector to add
|
||||||
*/
|
*/
|
||||||
public native void addiRowVector(@Const NDArray row);
|
public native void addiRowVector(@Const @ByRef NDArray row);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add given row vector to all rows of this array, store result in target
|
* add given row vector to all rows of this array, store result in target
|
||||||
* row - row vector to add
|
* row - row vector to add
|
||||||
* target - where to store result
|
* target - where to store result
|
||||||
*/
|
*/
|
||||||
public native void addRowVector(@Const NDArray row, NDArray target);
|
public native void addRowVector(@Const @ByRef NDArray row, @ByRef NDArray target);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* subtract given row vector from all rows of this array, store result in target
|
* subtract given row vector from all rows of this array, store result in target
|
||||||
* row - row vector to subtract
|
* row - row vector to subtract
|
||||||
* target - where to store result
|
* target - where to store result
|
||||||
*/
|
*/
|
||||||
public native void subRowVector(@Const NDArray row, NDArray target);
|
public native void subRowVector(@Const @ByRef NDArray row, @ByRef NDArray target);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* multiply all rows of this array on given row vector, store result in target
|
* multiply all rows of this array on given row vector, store result in target
|
||||||
* row - row vector to multiply on
|
* row - row vector to multiply on
|
||||||
* target - where to store result
|
* target - where to store result
|
||||||
*/
|
*/
|
||||||
public native void mulRowVector(@Const NDArray row, NDArray target);
|
public native void mulRowVector(@Const @ByRef NDArray row, @ByRef NDArray target);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* divide all rows of this array on given row vector, store result in target
|
* divide all rows of this array on given row vector, store result in target
|
||||||
* row - row vector to divide on
|
* row - row vector to divide on
|
||||||
* target - where to store result
|
* target - where to store result
|
||||||
*/
|
*/
|
||||||
public native void divRowVector(@Const NDArray row, NDArray target);
|
public native void divRowVector(@Const @ByRef NDArray row, @ByRef NDArray target);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add given column vector to all columns of this array, store result in target
|
* add given column vector to all columns of this array, store result in target
|
||||||
* column - column vector to add
|
* column - column vector to add
|
||||||
* target - where to store result
|
* target - where to store result
|
||||||
*/
|
*/
|
||||||
public native void addColumnVector(@Const NDArray column, NDArray target);
|
public native void addColumnVector(@Const @ByRef NDArray column, @ByRef NDArray target);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add given column vector to all columns of this array, this array becomes affected (in-place operation)
|
* add given column vector to all columns of this array, this array becomes affected (in-place operation)
|
||||||
* column - column vector to add
|
* column - column vector to add
|
||||||
*/
|
*/
|
||||||
public native void addiColumnVector(@Const NDArray column);
|
public native void addiColumnVector(@Const @ByRef NDArray column);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* multiply all columns of this array on given column vector, this array becomes affected (in-place operation)
|
* multiply all columns of this array on given column vector, this array becomes affected (in-place operation)
|
||||||
* column - column vector to multiply on
|
* column - column vector to multiply on
|
||||||
*/
|
*/
|
||||||
public native void muliColumnVector(@Const NDArray column);
|
public native void muliColumnVector(@Const @ByRef NDArray column);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns number of bytes used by _buffer & _shapeInfo
|
* returns number of bytes used by _buffer & _shapeInfo
|
||||||
|
@ -4324,12 +4285,6 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
*/
|
*/
|
||||||
public native void tile(@ByRef NDArray target);
|
public native void tile(@ByRef NDArray target);
|
||||||
|
|
||||||
/**
|
|
||||||
* returns an array which is result of broadcasting of this and other arrays
|
|
||||||
* other - input array
|
|
||||||
*/
|
|
||||||
public native NDArray broadcast(@Const @ByRef NDArray other);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check whether array is identity matrix
|
* check whether array is identity matrix
|
||||||
*/
|
*/
|
||||||
|
@ -4340,7 +4295,6 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
*/
|
*/
|
||||||
public native @Cast("bool") boolean isUnitary();
|
public native @Cast("bool") boolean isUnitary();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* operator returns subarray with buffer pointing at this->_buffer with offset defined by given intervals
|
* operator returns subarray with buffer pointing at this->_buffer with offset defined by given intervals
|
||||||
* idx - intervals of indexes which define the subarrays to point on, idx has form {dim0Start,dim0End, dim1Start,dim1End, ....} and length (2 * this->rankOf())
|
* idx - intervals of indexes which define the subarrays to point on, idx has form {dim0Start,dim0End, dim1Start,dim1End, ....} and length (2 * this->rankOf())
|
||||||
|
@ -4386,25 +4340,6 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
public native void getSubArrShapeAndOffsets(@StdVector int[] dimsToExclude, @Cast("Nd4jLong*&") @ByPtrRef long[] subArrShapeInfo, @Cast("Nd4jLong*&") @ByPtrRef long[] subArrOffsets, @Cast("bool") boolean keepUnitiesInShape/*=false*/);
|
public native void getSubArrShapeAndOffsets(@StdVector int[] dimsToExclude, @Cast("Nd4jLong*&") @ByPtrRef long[] subArrShapeInfo, @Cast("Nd4jLong*&") @ByPtrRef long[] subArrOffsets, @Cast("bool") boolean keepUnitiesInShape/*=false*/);
|
||||||
public native void getSubArrShapeAndOffsets(@StdVector int[] dimsToExclude, @Cast("Nd4jLong*&") @ByPtrRef long[] subArrShapeInfo, @Cast("Nd4jLong*&") @ByPtrRef long[] subArrOffsets);
|
public native void getSubArrShapeAndOffsets(@StdVector int[] dimsToExclude, @Cast("Nd4jLong*&") @ByPtrRef long[] subArrShapeInfo, @Cast("Nd4jLong*&") @ByPtrRef long[] subArrOffsets);
|
||||||
|
|
||||||
/**
|
|
||||||
* addition operator: array + other
|
|
||||||
* other - input array to add
|
|
||||||
*/
|
|
||||||
public native @ByVal @Name("operator +") NDArray add(@Const @ByRef NDArray other);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* addition operator: array + scalar
|
|
||||||
* scalar - input scalar to add
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* friend functions which implement addition operator: scalar + array
|
|
||||||
* scalar - input scalar to add
|
|
||||||
*/
|
|
||||||
//template <typename T>
|
|
||||||
//friend NDArray nd4j::operator+(const T scalar, const NDArray& arr);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* addition unary operator array += other
|
* addition unary operator array += other
|
||||||
* other - input array to add
|
* other - input array to add
|
||||||
|
@ -4417,39 +4352,11 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
*/
|
*/
|
||||||
public native @Name("operator -=") void subtractPut(@Const @ByRef NDArray other);
|
public native @Name("operator -=") void subtractPut(@Const @ByRef NDArray other);
|
||||||
|
|
||||||
/**
|
|
||||||
* subtraction operator: array - other
|
|
||||||
* other - input array to subtract
|
|
||||||
*/
|
|
||||||
public native @ByVal @Name("operator -") NDArray subtract(@Const @ByRef NDArray other);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* subtraction operator: array - scalar
|
|
||||||
* scalar - input scalar to subtract
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* negative operator, it changes sign of all array elements on opposite
|
* negative operator, it changes sign of all array elements on opposite
|
||||||
*/
|
*/
|
||||||
public native @ByVal @Name("operator -") NDArray subtract();
|
public native @ByVal @Name("operator -") NDArray subtract();
|
||||||
|
|
||||||
/**
|
|
||||||
* friend functions which implement subtraction operator: scalar - array
|
|
||||||
* scalar - input scalar to subtract
|
|
||||||
*/
|
|
||||||
//friend NDArray nd4j::operator-(const float scalar, const NDArray& arr);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* pairwise multiplication operator: array * other
|
|
||||||
* other - input array to multiply on
|
|
||||||
*/
|
|
||||||
public native @ByVal @Name("operator *") NDArray multiply(@Const @ByRef NDArray other);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* multiplication operator: array * scalar
|
|
||||||
* scalar - input scalar to multiply on
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pairwise multiplication unary operator array *= other
|
* pairwise multiplication unary operator array *= other
|
||||||
* other - input array to multiply on
|
* other - input array to multiply on
|
||||||
|
@ -4461,17 +4368,6 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
* scalar - input scalar to multiply on
|
* scalar - input scalar to multiply on
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* pairwise division operator: array / other
|
|
||||||
* other - input array to divide on
|
|
||||||
*/
|
|
||||||
public native @ByVal @Name("operator /") NDArray divide(@Const @ByRef NDArray other);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* division operator: array / scalar
|
|
||||||
* scalar - input scalar to divide each array element on
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pairwise division unary operator: array /= other
|
* pairwise division unary operator: array /= other
|
||||||
* other - input array to divide on
|
* other - input array to divide on
|
||||||
|
@ -4510,7 +4406,7 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
* return vector with buffer which points on corresponding diagonal elements of array
|
* return vector with buffer which points on corresponding diagonal elements of array
|
||||||
* type - means of vector to be returned: column ('c') or row ('r')
|
* type - means of vector to be returned: column ('c') or row ('r')
|
||||||
*/
|
*/
|
||||||
public native NDArray diagonal(byte type );
|
public native @ByVal NDArray diagonal(byte type );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fill target matrix with given value in one or two directions from main diagonal:
|
* fill target matrix with given value in one or two directions from main diagonal:
|
||||||
|
@ -4533,13 +4429,13 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
public native @ByVal NDArray tileToShape(@Cast("const Nd4jLong*") LongPointer shapeInfo);
|
public native @ByVal NDArray tileToShape(@Cast("const Nd4jLong*") LongPointer shapeInfo);
|
||||||
public native @ByVal NDArray tileToShape(@Cast("const Nd4jLong*") LongBuffer shapeInfo);
|
public native @ByVal NDArray tileToShape(@Cast("const Nd4jLong*") LongBuffer shapeInfo);
|
||||||
public native @ByVal NDArray tileToShape(@Cast("const Nd4jLong*") long[] shapeInfo);
|
public native @ByVal NDArray tileToShape(@Cast("const Nd4jLong*") long[] shapeInfo);
|
||||||
public native void tileToShape(@Cast("Nd4jLong*") @StdVector LongPointer shape, NDArray target/*=nullptr*/);
|
public native void tileToShape(@Cast("Nd4jLong*") @StdVector LongPointer shape, @ByRef NDArray target);
|
||||||
public native void tileToShape(@Cast("Nd4jLong*") @StdVector LongBuffer shape, NDArray target/*=nullptr*/);
|
public native void tileToShape(@Cast("Nd4jLong*") @StdVector LongBuffer shape, @ByRef NDArray target);
|
||||||
public native void tileToShape(@Cast("Nd4jLong*") @StdVector long[] shape, NDArray target/*=nullptr*/);
|
public native void tileToShape(@Cast("Nd4jLong*") @StdVector long[] shape, @ByRef NDArray target);
|
||||||
// #ifndef __JAVACPP_HACK__
|
// #ifndef __JAVACPP_HACK__
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
public native NDArray asT(@Cast("nd4j::DataType") int dtype);
|
public native @ByVal NDArray asT(@Cast("nd4j::DataType") int dtype);
|
||||||
|
|
||||||
|
|
||||||
public native void linspace(double start);
|
public native void linspace(double start);
|
||||||
|
@ -4551,17 +4447,15 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
*/
|
*/
|
||||||
public native double getTrace();
|
public native double getTrace();
|
||||||
|
|
||||||
public native ResultSet multipleTensorsAlongDimension(@StdVector IntPointer indices, @StdVector IntPointer dimensions);
|
public native @ByVal ResultSet multipleTensorsAlongDimension(@StdVector IntPointer indices, @StdVector IntPointer dimensions);
|
||||||
public native ResultSet multipleTensorsAlongDimension(@StdVector IntBuffer indices, @StdVector IntBuffer dimensions);
|
public native @ByVal ResultSet multipleTensorsAlongDimension(@StdVector IntBuffer indices, @StdVector IntBuffer dimensions);
|
||||||
public native ResultSet multipleTensorsAlongDimension(@StdVector int[] indices, @StdVector int[] dimensions);
|
public native @ByVal ResultSet multipleTensorsAlongDimension(@StdVector int[] indices, @StdVector int[] dimensions);
|
||||||
|
|
||||||
public native ResultSet allTensorsAlongDimension(@StdVector IntPointer dimensions);
|
public native @ByVal ResultSet allTensorsAlongDimension(@StdVector IntPointer dimensions);
|
||||||
public native ResultSet allTensorsAlongDimension(@StdVector IntBuffer dimensions);
|
public native @ByVal ResultSet allTensorsAlongDimension(@StdVector IntBuffer dimensions);
|
||||||
public native ResultSet allTensorsAlongDimension(@StdVector int[] dimensions);
|
public native @ByVal ResultSet allTensorsAlongDimension(@StdVector int[] dimensions);
|
||||||
|
|
||||||
//ResultSet allTensorsAlongDims(const std::vector<int>& dimensions) const;
|
public native @ByVal ResultSet allExamples();
|
||||||
|
|
||||||
public native ResultSet allExamples();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set _shapeInfo
|
* set _shapeInfo
|
||||||
|
@ -4669,7 +4563,7 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
/**
|
/**
|
||||||
* returns true if these two NDArrays have same rank, dimensions, strides, ews and order
|
* returns true if these two NDArrays have same rank, dimensions, strides, ews and order
|
||||||
*/
|
*/
|
||||||
public native @Cast("bool") boolean isSameShapeStrict(@Const NDArray other);
|
public native @Cast("bool") boolean isSameShapeStrict(@Const @ByRef NDArray other);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns true if buffer && shapeInfo were defined (non nullptr)
|
* returns true if buffer && shapeInfo were defined (non nullptr)
|
||||||
|
@ -4728,11 +4622,6 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
*/
|
*/
|
||||||
public native void p(@Cast("const Nd4jLong") long i, @Cast("const Nd4jLong") long j, @Cast("const Nd4jLong") long k, @Cast("const Nd4jLong") long l, @Const @ByRef NDArray value);
|
public native void p(@Cast("const Nd4jLong") long i, @Cast("const Nd4jLong") long j, @Cast("const Nd4jLong") long k, @Cast("const Nd4jLong") long l, @Const @ByRef NDArray value);
|
||||||
|
|
||||||
/**
|
|
||||||
* creates array which points on certain sub-range of this array, sub-range is defined by given indices
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns true if array is 2D
|
* returns true if array is 2D
|
||||||
*/
|
*/
|
||||||
|
@ -4803,59 +4692,6 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
*/
|
*/
|
||||||
public native @Cast("bool") boolean isS();
|
public native @Cast("bool") boolean isS();
|
||||||
|
|
||||||
/**
|
|
||||||
* inline accessing operator for matrix, i - absolute index
|
|
||||||
*/
|
|
||||||
//FORCEINLINE NDArray operator()(const Nd4jLong i) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* inline modifying operator for matrix, i - absolute index
|
|
||||||
*/
|
|
||||||
//FORCEINLINE NDArray& operator()(const Nd4jLong i);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* inline accessing operator for 2D array, i - row, j - column
|
|
||||||
*/
|
|
||||||
//FORCEINLINE NDArray operator()(const Nd4jLong i, const Nd4jLong j) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* inline modifying operator for 2D array, i - row, j - column
|
|
||||||
*/
|
|
||||||
//FORCEINLINE NDArray& operator()(const Nd4jLong i, const Nd4jLong j);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* inline accessing operator for 3D array, i - height, j - width, k - depth
|
|
||||||
*/
|
|
||||||
//FORCEINLINE NDArray operator()(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* inline modifying operator for 3D array, i - height, j - width, k - depth
|
|
||||||
*/
|
|
||||||
//FORCEINLINE NDArray& operator()(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* inline modifying operator for 4D array, i - height, j - width, k - depth
|
|
||||||
*/
|
|
||||||
//FORCEINLINE NDArray& operator()(const Nd4jLong t, const Nd4jLong u, const Nd4jLong v, const Nd4jLong w);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* inline accessing operator for 4D array, i - height, j - width, k - depth
|
|
||||||
*/
|
|
||||||
//FORCEINLINE NDArray operator()(const Nd4jLong t, const Nd4jLong u, const Nd4jLong v, const Nd4jLong w) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* inline modifying operator for ND array
|
|
||||||
* idx - array with corresponding indexes, for example {2,10,0,5,...,8}, number of indexes should be equal to array rank
|
|
||||||
*/
|
|
||||||
//FORCEINLINE NDArray& operator()(const Nd4jLong* idx);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* inline accessing operator for ND array
|
|
||||||
* idx - array with corresponding indexes, for example {2,10,0,5,...,8}, number of indexes should be equal to array rank
|
|
||||||
*/
|
|
||||||
//FORCEINLINE NDArray operator()(const Nd4jLong* idx) const;
|
|
||||||
|
|
||||||
|
|
||||||
public native @Cast("bool") boolean isAttached();
|
public native @Cast("bool") boolean isAttached();
|
||||||
|
|
||||||
public native NDArray detach();
|
public native NDArray detach();
|
||||||
|
@ -4875,263 +4711,70 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// accessing operator for matrix, i - absolute index
|
|
||||||
/*
|
|
||||||
NDArray NDArray::operator()(const Nd4jLong i) const {
|
|
||||||
|
|
||||||
if (i >= shape::length(_shapeInfo))
|
|
||||||
throw std::invalid_argument("NDArray::operator(i): input index is out of array length !");
|
|
||||||
|
|
||||||
auto ews = shape::elementWiseStride(_shapeInfo);
|
|
||||||
char order = ordering();
|
|
||||||
|
|
||||||
if(ews == 1 && order == 'c') {
|
|
||||||
auto cast = reinterpret_cast<int8_t *>(_buffer) + (i * this->sizeOfT());
|
|
||||||
NDArray result(cast, nd4j::ShapeBuilders::createScalarShapeInfo(this->dataType(), this->getWorkspace()));
|
|
||||||
return result;
|
|
||||||
} else if(ews > 1 && order == 'c') {
|
|
||||||
auto cast = reinterpret_cast<int8_t *>(_buffer) + (i * ews * this->sizeOfT());
|
|
||||||
NDArray result(cast, nd4j::ShapeBuilders::createScalarShapeInfo(this->dataType(), this->getWorkspace()));
|
|
||||||
return result;
|
|
||||||
} else {
|
|
||||||
Nd4jLong idx[MAX_RANK];
|
|
||||||
shape::ind2subC(rankOf(), shapeOf(), i, idx);
|
|
||||||
auto xOffset = shape::getOffset(getShapeInfo(), idx);
|
|
||||||
|
|
||||||
auto cast = reinterpret_cast<int8_t *>(_buffer) + (xOffset * this->sizeOfT());
|
|
||||||
NDArray result(cast, nd4j::ShapeBuilders::createScalarShapeInfo(this->dataType(), this->getWorkspace()));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
// modifying operator for matrix, i - absolute index
|
|
||||||
/*
|
|
||||||
NDArray& NDArray::operator()(const Nd4jLong i) {
|
|
||||||
if (i >= shape::length(_shapeInfo))
|
|
||||||
throw std::invalid_argument("NDArray::operator(i): input index is out of array length !");
|
|
||||||
|
|
||||||
auto ews = shape::elementWiseStride(_shapeInfo);
|
|
||||||
auto order = ordering();
|
|
||||||
|
|
||||||
if(ews == 1 && order == 'c') {
|
|
||||||
auto cast = reinterpret_cast<int8_t *>(_buffer) + (i * this->sizeOfT());
|
|
||||||
NDArray result(cast, nd4j::ShapeBuilders::createScalarShapeInfo(this->dataType(), this->getWorkspace()));
|
|
||||||
|
|
||||||
// FIXME: bad
|
|
||||||
return result;
|
|
||||||
} else if(ews > 1 && order == 'c') {
|
|
||||||
auto cast = reinterpret_cast<int8_t *>(_buffer) + (i * ews * this->sizeOfT());
|
|
||||||
NDArray result(cast, nd4j::ShapeBuilders::createScalarShapeInfo(this->dataType(), this->getWorkspace()));
|
|
||||||
return result;
|
|
||||||
} else {
|
|
||||||
Nd4jLong idx[MAX_RANK];
|
|
||||||
shape::ind2subC(rankOf(), shapeOf(), i, idx);
|
|
||||||
auto xOffset = shape::getOffset(getShapeInfo(), idx);
|
|
||||||
|
|
||||||
auto cast = reinterpret_cast<int8_t *>(_buffer) + (xOffset * this->sizeOfT());
|
|
||||||
NDArray result(cast, nd4j::ShapeBuilders::createScalarShapeInfo(this->dataType(), this->getWorkspace()));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// accessing operator for 2D matrix, i - row, j - column
|
|
||||||
/*
|
|
||||||
NDArray NDArray::operator()(const Nd4jLong i, const Nd4jLong j) const {
|
|
||||||
|
|
||||||
if (rankOf() != 2 || i >= shapeOf()[0] || j >= shapeOf()[1])
|
|
||||||
throw std::invalid_argument("NDArray::operator(i,j): one of input indexes is out of array length or rank!=2 !");
|
|
||||||
|
|
||||||
Nd4jLong coords[2] = {i, j};
|
|
||||||
auto xOffset = shape::getOffset(getShapeInfo(), coords);
|
|
||||||
|
|
||||||
// TODO: do we really want a view here?
|
|
||||||
auto cast = reinterpret_cast<int8_t *>(_buffer) + (xOffset * this->sizeOfT());
|
|
||||||
NDArray result(cast, nd4j::ShapeBuilders::createScalarShapeInfo(this->dataType(), this->getWorkspace()));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
// modifying operator for 2D matrix, i - row, j - column
|
|
||||||
/*
|
|
||||||
NDArray& NDArray::operator()(const Nd4jLong i, const Nd4jLong j) {
|
|
||||||
if (rankOf() != 2 || i >= shapeOf()[0] || j >= shapeOf()[1])
|
|
||||||
throw std::invalid_argument("NDArray::operator(i,j): one of input indexes is out of array length or rank!=2 !");
|
|
||||||
|
|
||||||
Nd4jLong coords[2] = {i, j};
|
|
||||||
auto xOffset = shape::getOffset(getShapeInfo(), coords);
|
|
||||||
|
|
||||||
auto cast = reinterpret_cast<int8_t *>(_buffer) + (xOffset * this->sizeOfT());
|
|
||||||
NDArray result(cast, nd4j::ShapeBuilders::createScalarShapeInfo(this->dataType(), this->getWorkspace()));
|
|
||||||
|
|
||||||
//FIXME: bad, will crash!
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// accessing operator for 3D array, i - row, j - column
|
|
||||||
/*
|
|
||||||
NDArray NDArray::operator()(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k) const {
|
|
||||||
|
|
||||||
if (rankOf() != 3 || i >= shapeOf()[0] || j >= shapeOf()[1] || j >= shapeOf()[2])
|
|
||||||
throw std::invalid_argument("NDArray::operator(i,j,k): one of input indexes is out of array length or rank!=3 !");
|
|
||||||
|
|
||||||
Nd4jLong coords[3] = {i, j, k};
|
|
||||||
auto xOffset = shape::getOffset(getShapeInfo(), coords);
|
|
||||||
|
|
||||||
auto cast = reinterpret_cast<int8_t *>(_buffer) + (xOffset * this->sizeOfT());
|
|
||||||
NDArray result(cast, nd4j::ShapeBuilders::createScalarShapeInfo(this->dataType(), this->getWorkspace()));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// modifying operator for 3D array
|
|
||||||
/*
|
|
||||||
NDArray& NDArray::operator()(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k) {
|
|
||||||
|
|
||||||
if (rankOf() != 3 || i >= shapeOf()[0] || j >= shapeOf()[1] || k >= shapeOf()[2])
|
|
||||||
throw std::invalid_argument("NDArray::operator(i,j,k): one of input indexes is out of array length or rank!=3 !");
|
|
||||||
|
|
||||||
Nd4jLong coords[3] = {i, j, k};
|
|
||||||
auto xOffset = shape::getOffset(getShapeInfo(), coords);
|
|
||||||
|
|
||||||
auto cast = reinterpret_cast<int8_t *>(_buffer) + (xOffset * this->sizeOfT());
|
|
||||||
NDArray result(cast, nd4j::ShapeBuilders::createScalarShapeInfo(this->dataType(), this->getWorkspace()));
|
|
||||||
|
|
||||||
//FIXME: bad, will crash!
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
NDArray NDArray::operator()(const Nd4jLong t, const Nd4jLong u, const Nd4jLong v, const Nd4jLong w) const {
|
|
||||||
|
|
||||||
if (rankOf() != 4 || t >= shapeOf()[0] || u >= shapeOf()[1] || v >= shapeOf()[2] || w >= shapeOf()[3])
|
|
||||||
throw std::invalid_argument("NDArray::operator(t,u,v,w): one of input indexes is out of array length or rank!=4 !");
|
|
||||||
|
|
||||||
Nd4jLong coords[4] = {t, u, v, w};
|
|
||||||
auto xOffset = shape::getOffset(getShapeInfo(), coords);
|
|
||||||
|
|
||||||
auto cast = reinterpret_cast<int8_t *>(_buffer) + (xOffset * this->sizeOfT());
|
|
||||||
NDArray result(cast, nd4j::ShapeBuilders::createScalarShapeInfo(this->dataType(), this->getWorkspace()));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
NDArray& NDArray::operator()(const Nd4jLong t, const Nd4jLong u, const Nd4jLong v, const Nd4jLong w) {
|
|
||||||
|
|
||||||
if (rankOf() != 4 || t >= shapeOf()[0] || u >= shapeOf()[1] || v >= shapeOf()[2] || w >= shapeOf()[3])
|
|
||||||
throw std::invalid_argument("NDArray::operator(t,u,v,w): one of input indexes is out of array length or rank!=4 !");
|
|
||||||
|
|
||||||
Nd4jLong coords[4] = {t, u, v, w};
|
|
||||||
auto xOffset = shape::getOffset(getShapeInfo(), coords);
|
|
||||||
|
|
||||||
// FIXME
|
|
||||||
auto cast = reinterpret_cast<int8_t *>(_buffer) + (xOffset * this->sizeOfT());
|
|
||||||
NDArray result(cast, nd4j::ShapeBuilders::createScalarShapeInfo(this->dataType(), this->getWorkspace()));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/*
|
|
||||||
NDArray NDArray::operator()(const Nd4jLong* idx) const {
|
|
||||||
|
|
||||||
for(int i = 0; i < rankOf(); ++i)
|
|
||||||
if (idx[i] >= sizeAt(i))
|
|
||||||
throw std::invalid_argument("NDArray::operator(const Nd4jLong* idx): input index is out of dimension length !");
|
|
||||||
|
|
||||||
auto xOffset = shape::getOffset(getShapeInfo(), idx);
|
|
||||||
|
|
||||||
auto cast = reinterpret_cast<int8_t *>(_buffer) + (xOffset * this->sizeOfT());
|
|
||||||
NDArray result(cast, nd4j::ShapeBuilders::createScalarShapeInfo(this->dataType(), this->getWorkspace()));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/*
|
|
||||||
NDArray& NDArray::operator()(const Nd4jLong* idx) {
|
|
||||||
|
|
||||||
for(int i = 0; i < rankOf(); ++i)
|
|
||||||
if (idx[i] >= sizeAt(i))
|
|
||||||
throw std::invalid_argument("NDArray::operator(const Nd4jLong* idx): input index is out of dimension length !");
|
|
||||||
|
|
||||||
auto xOffset = shape::getOffset(getShapeInfo(), idx);
|
|
||||||
|
|
||||||
auto cast = reinterpret_cast<int8_t *>(_buffer) + (xOffset * this->sizeOfT());
|
|
||||||
NDArray result(cast, nd4j::ShapeBuilders::createScalarShapeInfo(this->dataType(), this->getWorkspace()));
|
|
||||||
|
|
||||||
// FIXME
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// still the definition of inline function must be in header file
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
// still the definition of inline function must be in header file
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -6778,9 +6421,11 @@ NDArray& NDArray::operator()(const Nd4jLong* idx) {
|
||||||
|
|
||||||
public native void setCudaContext(@Cast("Nd4jPointer") Pointer cudaStream, @Cast("Nd4jPointer") Pointer reductionPointer, @Cast("Nd4jPointer") Pointer allocationPointer);
|
public native void setCudaContext(@Cast("Nd4jPointer") Pointer cudaStream, @Cast("Nd4jPointer") Pointer reductionPointer, @Cast("Nd4jPointer") Pointer allocationPointer);
|
||||||
|
|
||||||
|
|
||||||
public native void allowHelpers(@Cast("bool") boolean reallyAllow);
|
public native void allowHelpers(@Cast("bool") boolean reallyAllow);
|
||||||
public native @Cast("bool") boolean helpersAllowed();
|
public native @Cast("bool") boolean helpersAllowed();
|
||||||
|
|
||||||
|
public native void setShapeFunctionOverride(@Cast("bool") boolean reallyOverride);
|
||||||
|
public native @Cast("bool") boolean shapeFunctionOverride();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -10630,6 +10275,7 @@ public static final int PREALLOC_SIZE = 33554432;
|
||||||
// #include <ops/declarable/headers/tests.h>
|
// #include <ops/declarable/headers/tests.h>
|
||||||
// #include <ops/declarable/headers/kernels.h>
|
// #include <ops/declarable/headers/kernels.h>
|
||||||
// #include <ops/declarable/headers/BarnesHutTsne.h>
|
// #include <ops/declarable/headers/BarnesHutTsne.h>
|
||||||
|
// #include <ops/declarable/headers/images.h>
|
||||||
// #include <dll.h>
|
// #include <dll.h>
|
||||||
// #include <helpers/shape.h>
|
// #include <helpers/shape.h>
|
||||||
// #include <helpers/TAD.h>
|
// #include <helpers/TAD.h>
|
||||||
|
|
|
@ -110,4 +110,9 @@ public class CpuOpContext extends BaseOpContext implements OpContext {
|
||||||
public void allowHelpers(boolean reallyAllow) {
|
public void allowHelpers(boolean reallyAllow) {
|
||||||
nativeOps.ctxAllowHelpers(context, reallyAllow);
|
nativeOps.ctxAllowHelpers(context, reallyAllow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void shapeFunctionOverride(boolean reallyOverride) {
|
||||||
|
nativeOps.ctxShapeFunctionOverride(context, reallyOverride);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1691,6 +1691,7 @@ public class NativeOpExecutioner extends DefaultOpExecutioner {
|
||||||
@Override
|
@Override
|
||||||
public INDArray[] exec(@NonNull CustomOp op) {
|
public INDArray[] exec(@NonNull CustomOp op) {
|
||||||
|
|
||||||
|
boolean shapeOverride = false;
|
||||||
if (op.numOutputArguments() == 0 && !op.isInplaceCall()) {
|
if (op.numOutputArguments() == 0 && !op.isInplaceCall()) {
|
||||||
try {
|
try {
|
||||||
val list = this.calculateOutputShape(op);
|
val list = this.calculateOutputShape(op);
|
||||||
|
@ -1699,6 +1700,8 @@ public class NativeOpExecutioner extends DefaultOpExecutioner {
|
||||||
|
|
||||||
for (LongShapeDescriptor shape : list)
|
for (LongShapeDescriptor shape : list)
|
||||||
op.addOutputArgument(Nd4j.create(shape, false));
|
op.addOutputArgument(Nd4j.create(shape, false));
|
||||||
|
|
||||||
|
shapeOverride = true;
|
||||||
} catch (ND4JIllegalStateException e){
|
} catch (ND4JIllegalStateException e){
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -1709,6 +1712,10 @@ public class NativeOpExecutioner extends DefaultOpExecutioner {
|
||||||
val name = op.opName();
|
val name = op.opName();
|
||||||
try (val context = buildContext()) {
|
try (val context = buildContext()) {
|
||||||
|
|
||||||
|
// optionally skip shape validation on op execution
|
||||||
|
if (shapeOverride)
|
||||||
|
context.shapeFunctionOverride(true);
|
||||||
|
|
||||||
context.markInplace(op.isInplaceCall());
|
context.markInplace(op.isInplaceCall());
|
||||||
|
|
||||||
// transferring rng state
|
// transferring rng state
|
||||||
|
|
|
@ -3103,6 +3103,7 @@ public native void deleteShapeBuffer(OpaqueConstantDataBuffer ptr);
|
||||||
public native OpaqueContext createGraphContext(int nodeId);
|
public native OpaqueContext createGraphContext(int nodeId);
|
||||||
public native OpaqueRandomGenerator getGraphContextRandomGenerator(OpaqueContext ptr);
|
public native OpaqueRandomGenerator getGraphContextRandomGenerator(OpaqueContext ptr);
|
||||||
public native void ctxAllowHelpers(OpaqueContext ptr, @Cast("bool") boolean reallyAllow);
|
public native void ctxAllowHelpers(OpaqueContext ptr, @Cast("bool") boolean reallyAllow);
|
||||||
|
public native void ctxShapeFunctionOverride(OpaqueContext ptr, @Cast("bool") boolean reallyOverride);
|
||||||
public native void markGraphContextInplace(OpaqueContext ptr, @Cast("bool") boolean reallyInplace);
|
public native void markGraphContextInplace(OpaqueContext ptr, @Cast("bool") boolean reallyInplace);
|
||||||
public native void setGraphContextCudaContext(OpaqueContext ptr, Pointer stream, Pointer reductionPointer, Pointer allocationPointer);
|
public native void setGraphContextCudaContext(OpaqueContext ptr, Pointer stream, Pointer reductionPointer, Pointer allocationPointer);
|
||||||
public native void setGraphContextInputArray(OpaqueContext ptr, int index, Pointer buffer, Pointer shapeInfo, Pointer specialBuffer, Pointer specialShapeInfo);
|
public native void setGraphContextInputArray(OpaqueContext ptr, int index, Pointer buffer, Pointer shapeInfo, Pointer specialBuffer, Pointer specialShapeInfo);
|
||||||
|
@ -3637,25 +3638,7 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
// #include <execution/AffinityManager.h>
|
// #include <execution/AffinityManager.h>
|
||||||
|
|
||||||
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator -") NDArray subtract(float arg0, @Const @ByRef NDArray arg1);
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator -") NDArray subtract(@Cast("const float16") short arg0, @Const @ByRef NDArray arg1);
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator -") NDArray subtract(double arg0, @Const @ByRef NDArray arg1);
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator -") NDArray subtract(int arg0, @Const @ByRef NDArray arg1);
|
|
||||||
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator +") NDArray add(float arg0, @Const @ByRef NDArray arg1);
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator +") NDArray add(@Cast("const float16") short arg0, @Const @ByRef NDArray arg1);
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator +") NDArray add(double arg0, @Const @ByRef NDArray arg1);
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator +") NDArray add(int arg0, @Const @ByRef NDArray arg1);
|
|
||||||
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator *") NDArray multiply(float arg0, @Const @ByRef NDArray arg1);
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator *") NDArray multiply(@Cast("const float16") short arg0, @Const @ByRef NDArray arg1);
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator *") NDArray multiply(double arg0, @Const @ByRef NDArray arg1);
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator *") NDArray multiply(int arg0, @Const @ByRef NDArray arg1);
|
|
||||||
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator /") NDArray divide(float arg0, @Const @ByRef NDArray arg1);
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator /") NDArray divide(@Cast("const float16") short arg0, @Const @ByRef NDArray arg1);
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator /") NDArray divide(double arg0, @Const @ByRef NDArray arg1);
|
|
||||||
@Namespace("nd4j") public static native @ByVal @Name("operator /") NDArray divide(int arg0, @Const @ByRef NDArray arg1);
|
|
||||||
|
|
||||||
@Namespace("nd4j") public static native @ByVal NDArray mmul(@Const @ByRef NDArray arg0, @Const @ByRef NDArray arg1);
|
@Namespace("nd4j") public static native @ByVal NDArray mmul(@Const @ByRef NDArray arg0, @Const @ByRef NDArray arg1);
|
||||||
|
|
||||||
|
@ -3906,9 +3889,9 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
* axis - axis along which to repeat elements
|
* axis - axis along which to repeat elements
|
||||||
* repeats - number of repetitions
|
* repeats - number of repetitions
|
||||||
*/
|
*/
|
||||||
public native NDArray repeat(int axis, @StdVector IntPointer repeats);
|
public native @ByVal NDArray repeat(int axis, @StdVector IntPointer repeats);
|
||||||
public native NDArray repeat(int axis, @StdVector IntBuffer repeats);
|
public native @ByVal NDArray repeat(int axis, @StdVector IntBuffer repeats);
|
||||||
public native NDArray repeat(int axis, @StdVector int[] repeats);
|
public native @ByVal NDArray repeat(int axis, @StdVector int[] repeats);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method fills this array with zeros
|
* This method fills this array with zeros
|
||||||
|
@ -3921,14 +3904,7 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
* @param array
|
* @param array
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static native @ByVal NDArray quantize(@ByRef NDArray array);
|
public static native @ByVal NDArray quantize(@Const @ByRef NDArray array);
|
||||||
|
|
||||||
/**
|
|
||||||
* This method returns quantized copy of given array
|
|
||||||
*
|
|
||||||
* @param array
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fill target array by repeating current array
|
* fill target array by repeating current array
|
||||||
|
@ -3949,10 +3925,9 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
/**
|
/**
|
||||||
* cast array elements to given dtype
|
* cast array elements to given dtype
|
||||||
*/
|
*/
|
||||||
|
public native @ByVal NDArray cast(@Cast("nd4j::DataType") int dtype);
|
||||||
|
|
||||||
public native NDArray cast(@Cast("nd4j::DataType") int dtype);
|
public native void cast(@ByRef NDArray target, @Cast("nd4j::DataType") int dtype);
|
||||||
|
|
||||||
public native void cast(NDArray target, @Cast("nd4j::DataType") int dtype);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns _context
|
* returns _context
|
||||||
|
@ -4123,26 +4098,12 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
/**
|
/**
|
||||||
* this method assigns given value to all elements in array
|
* this method assigns given value to all elements in array
|
||||||
*/
|
*/
|
||||||
public native void assign(double value, @Cast("bool") boolean allowParallelism/*=true*/);
|
|
||||||
public native void assign(double value);
|
|
||||||
public native void assign(float value, @Cast("bool") boolean allowParallelism/*=true*/);
|
|
||||||
public native void assign(float value);
|
|
||||||
public native void assign(@Cast("const float16") short value, @Cast("bool") boolean allowParallelism/*=true*/);
|
|
||||||
public native void assign(@Cast("const float16") short value);
|
|
||||||
public native void assign(@Cast("const Nd4jLong") long value, @Cast("bool") boolean allowParallelism/*=true*/);
|
|
||||||
public native void assign(@Cast("const Nd4jLong") long value);
|
|
||||||
public native void assign(int value, @Cast("bool") boolean allowParallelism/*=true*/);
|
|
||||||
public native void assign(int value);
|
|
||||||
public native void assign(@Cast("const uint8_t") byte value, @Cast("bool") boolean allowParallelism/*=true*/);
|
|
||||||
public native void assign(@Cast("const uint8_t") byte value);
|
|
||||||
public native void assign(@Cast("const bool") boolean value, @Cast("bool") boolean allowParallelism/*=true*/);
|
|
||||||
public native void assign(@Cast("const bool") boolean value);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns new copy of this array, optionally in different order
|
* returns new copy of this array, optionally in different order
|
||||||
*/
|
*/
|
||||||
public native NDArray dup(byte newOrder/*='a'*/);
|
public native @ByVal NDArray dup(byte newOrder/*='a'*/);
|
||||||
public native NDArray dup();
|
public native @ByVal NDArray dup();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns sum of all elements of array
|
* returns sum of all elements of array
|
||||||
|
@ -4179,9 +4140,9 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
* index - the number of array to be returned among set of possible arrays
|
* index - the number of array to be returned among set of possible arrays
|
||||||
* dimensions - array of dimensions to point on
|
* dimensions - array of dimensions to point on
|
||||||
*/
|
*/
|
||||||
public native NDArray tensorAlongDimension(@Cast("Nd4jLong") long index, @StdVector IntPointer dimensions);
|
public native @ByVal NDArray tensorAlongDimension(@Cast("Nd4jLong") long index, @StdVector IntPointer dimensions);
|
||||||
public native NDArray tensorAlongDimension(@Cast("Nd4jLong") long index, @StdVector IntBuffer dimensions);
|
public native @ByVal NDArray tensorAlongDimension(@Cast("Nd4jLong") long index, @StdVector IntBuffer dimensions);
|
||||||
public native NDArray tensorAlongDimension(@Cast("Nd4jLong") long index, @StdVector int[] dimensions);
|
public native @ByVal NDArray tensorAlongDimension(@Cast("Nd4jLong") long index, @StdVector int[] dimensions);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the number of arrays pointing on specified dimension(s)
|
* returns the number of arrays pointing on specified dimension(s)
|
||||||
|
@ -4203,54 +4164,54 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
* add given row vector to all rows of this array
|
* add given row vector to all rows of this array
|
||||||
* row - row vector to add
|
* row - row vector to add
|
||||||
*/
|
*/
|
||||||
public native void addiRowVector(@Const NDArray row);
|
public native void addiRowVector(@Const @ByRef NDArray row);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add given row vector to all rows of this array, store result in target
|
* add given row vector to all rows of this array, store result in target
|
||||||
* row - row vector to add
|
* row - row vector to add
|
||||||
* target - where to store result
|
* target - where to store result
|
||||||
*/
|
*/
|
||||||
public native void addRowVector(@Const NDArray row, NDArray target);
|
public native void addRowVector(@Const @ByRef NDArray row, @ByRef NDArray target);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* subtract given row vector from all rows of this array, store result in target
|
* subtract given row vector from all rows of this array, store result in target
|
||||||
* row - row vector to subtract
|
* row - row vector to subtract
|
||||||
* target - where to store result
|
* target - where to store result
|
||||||
*/
|
*/
|
||||||
public native void subRowVector(@Const NDArray row, NDArray target);
|
public native void subRowVector(@Const @ByRef NDArray row, @ByRef NDArray target);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* multiply all rows of this array on given row vector, store result in target
|
* multiply all rows of this array on given row vector, store result in target
|
||||||
* row - row vector to multiply on
|
* row - row vector to multiply on
|
||||||
* target - where to store result
|
* target - where to store result
|
||||||
*/
|
*/
|
||||||
public native void mulRowVector(@Const NDArray row, NDArray target);
|
public native void mulRowVector(@Const @ByRef NDArray row, @ByRef NDArray target);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* divide all rows of this array on given row vector, store result in target
|
* divide all rows of this array on given row vector, store result in target
|
||||||
* row - row vector to divide on
|
* row - row vector to divide on
|
||||||
* target - where to store result
|
* target - where to store result
|
||||||
*/
|
*/
|
||||||
public native void divRowVector(@Const NDArray row, NDArray target);
|
public native void divRowVector(@Const @ByRef NDArray row, @ByRef NDArray target);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add given column vector to all columns of this array, store result in target
|
* add given column vector to all columns of this array, store result in target
|
||||||
* column - column vector to add
|
* column - column vector to add
|
||||||
* target - where to store result
|
* target - where to store result
|
||||||
*/
|
*/
|
||||||
public native void addColumnVector(@Const NDArray column, NDArray target);
|
public native void addColumnVector(@Const @ByRef NDArray column, @ByRef NDArray target);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add given column vector to all columns of this array, this array becomes affected (in-place operation)
|
* add given column vector to all columns of this array, this array becomes affected (in-place operation)
|
||||||
* column - column vector to add
|
* column - column vector to add
|
||||||
*/
|
*/
|
||||||
public native void addiColumnVector(@Const NDArray column);
|
public native void addiColumnVector(@Const @ByRef NDArray column);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* multiply all columns of this array on given column vector, this array becomes affected (in-place operation)
|
* multiply all columns of this array on given column vector, this array becomes affected (in-place operation)
|
||||||
* column - column vector to multiply on
|
* column - column vector to multiply on
|
||||||
*/
|
*/
|
||||||
public native void muliColumnVector(@Const NDArray column);
|
public native void muliColumnVector(@Const @ByRef NDArray column);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns number of bytes used by _buffer & _shapeInfo
|
* returns number of bytes used by _buffer & _shapeInfo
|
||||||
|
@ -4327,12 +4288,6 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
*/
|
*/
|
||||||
public native void tile(@ByRef NDArray target);
|
public native void tile(@ByRef NDArray target);
|
||||||
|
|
||||||
/**
|
|
||||||
* returns an array which is result of broadcasting of this and other arrays
|
|
||||||
* other - input array
|
|
||||||
*/
|
|
||||||
public native NDArray broadcast(@Const @ByRef NDArray other);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check whether array is identity matrix
|
* check whether array is identity matrix
|
||||||
*/
|
*/
|
||||||
|
@ -4343,7 +4298,6 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
*/
|
*/
|
||||||
public native @Cast("bool") boolean isUnitary();
|
public native @Cast("bool") boolean isUnitary();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* operator returns subarray with buffer pointing at this->_buffer with offset defined by given intervals
|
* operator returns subarray with buffer pointing at this->_buffer with offset defined by given intervals
|
||||||
* idx - intervals of indexes which define the subarrays to point on, idx has form {dim0Start,dim0End, dim1Start,dim1End, ....} and length (2 * this->rankOf())
|
* idx - intervals of indexes which define the subarrays to point on, idx has form {dim0Start,dim0End, dim1Start,dim1End, ....} and length (2 * this->rankOf())
|
||||||
|
@ -4389,25 +4343,6 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
public native void getSubArrShapeAndOffsets(@StdVector int[] dimsToExclude, @Cast("Nd4jLong*&") @ByPtrRef long[] subArrShapeInfo, @Cast("Nd4jLong*&") @ByPtrRef long[] subArrOffsets, @Cast("bool") boolean keepUnitiesInShape/*=false*/);
|
public native void getSubArrShapeAndOffsets(@StdVector int[] dimsToExclude, @Cast("Nd4jLong*&") @ByPtrRef long[] subArrShapeInfo, @Cast("Nd4jLong*&") @ByPtrRef long[] subArrOffsets, @Cast("bool") boolean keepUnitiesInShape/*=false*/);
|
||||||
public native void getSubArrShapeAndOffsets(@StdVector int[] dimsToExclude, @Cast("Nd4jLong*&") @ByPtrRef long[] subArrShapeInfo, @Cast("Nd4jLong*&") @ByPtrRef long[] subArrOffsets);
|
public native void getSubArrShapeAndOffsets(@StdVector int[] dimsToExclude, @Cast("Nd4jLong*&") @ByPtrRef long[] subArrShapeInfo, @Cast("Nd4jLong*&") @ByPtrRef long[] subArrOffsets);
|
||||||
|
|
||||||
/**
|
|
||||||
* addition operator: array + other
|
|
||||||
* other - input array to add
|
|
||||||
*/
|
|
||||||
public native @ByVal @Name("operator +") NDArray add(@Const @ByRef NDArray other);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* addition operator: array + scalar
|
|
||||||
* scalar - input scalar to add
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* friend functions which implement addition operator: scalar + array
|
|
||||||
* scalar - input scalar to add
|
|
||||||
*/
|
|
||||||
//template <typename T>
|
|
||||||
//friend NDArray nd4j::operator+(const T scalar, const NDArray& arr);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* addition unary operator array += other
|
* addition unary operator array += other
|
||||||
* other - input array to add
|
* other - input array to add
|
||||||
|
@ -4420,39 +4355,11 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
*/
|
*/
|
||||||
public native @Name("operator -=") void subtractPut(@Const @ByRef NDArray other);
|
public native @Name("operator -=") void subtractPut(@Const @ByRef NDArray other);
|
||||||
|
|
||||||
/**
|
|
||||||
* subtraction operator: array - other
|
|
||||||
* other - input array to subtract
|
|
||||||
*/
|
|
||||||
public native @ByVal @Name("operator -") NDArray subtract(@Const @ByRef NDArray other);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* subtraction operator: array - scalar
|
|
||||||
* scalar - input scalar to subtract
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* negative operator, it changes sign of all array elements on opposite
|
* negative operator, it changes sign of all array elements on opposite
|
||||||
*/
|
*/
|
||||||
public native @ByVal @Name("operator -") NDArray subtract();
|
public native @ByVal @Name("operator -") NDArray subtract();
|
||||||
|
|
||||||
/**
|
|
||||||
* friend functions which implement subtraction operator: scalar - array
|
|
||||||
* scalar - input scalar to subtract
|
|
||||||
*/
|
|
||||||
//friend NDArray nd4j::operator-(const float scalar, const NDArray& arr);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* pairwise multiplication operator: array * other
|
|
||||||
* other - input array to multiply on
|
|
||||||
*/
|
|
||||||
public native @ByVal @Name("operator *") NDArray multiply(@Const @ByRef NDArray other);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* multiplication operator: array * scalar
|
|
||||||
* scalar - input scalar to multiply on
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pairwise multiplication unary operator array *= other
|
* pairwise multiplication unary operator array *= other
|
||||||
* other - input array to multiply on
|
* other - input array to multiply on
|
||||||
|
@ -4464,17 +4371,6 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
* scalar - input scalar to multiply on
|
* scalar - input scalar to multiply on
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* pairwise division operator: array / other
|
|
||||||
* other - input array to divide on
|
|
||||||
*/
|
|
||||||
public native @ByVal @Name("operator /") NDArray divide(@Const @ByRef NDArray other);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* division operator: array / scalar
|
|
||||||
* scalar - input scalar to divide each array element on
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pairwise division unary operator: array /= other
|
* pairwise division unary operator: array /= other
|
||||||
* other - input array to divide on
|
* other - input array to divide on
|
||||||
|
@ -4513,7 +4409,7 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
* return vector with buffer which points on corresponding diagonal elements of array
|
* return vector with buffer which points on corresponding diagonal elements of array
|
||||||
* type - means of vector to be returned: column ('c') or row ('r')
|
* type - means of vector to be returned: column ('c') or row ('r')
|
||||||
*/
|
*/
|
||||||
public native NDArray diagonal(byte type );
|
public native @ByVal NDArray diagonal(byte type );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fill target matrix with given value in one or two directions from main diagonal:
|
* fill target matrix with given value in one or two directions from main diagonal:
|
||||||
|
@ -4536,13 +4432,13 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
public native @ByVal NDArray tileToShape(@Cast("const Nd4jLong*") LongPointer shapeInfo);
|
public native @ByVal NDArray tileToShape(@Cast("const Nd4jLong*") LongPointer shapeInfo);
|
||||||
public native @ByVal NDArray tileToShape(@Cast("const Nd4jLong*") LongBuffer shapeInfo);
|
public native @ByVal NDArray tileToShape(@Cast("const Nd4jLong*") LongBuffer shapeInfo);
|
||||||
public native @ByVal NDArray tileToShape(@Cast("const Nd4jLong*") long[] shapeInfo);
|
public native @ByVal NDArray tileToShape(@Cast("const Nd4jLong*") long[] shapeInfo);
|
||||||
public native void tileToShape(@Cast("Nd4jLong*") @StdVector LongPointer shape, NDArray target/*=nullptr*/);
|
public native void tileToShape(@Cast("Nd4jLong*") @StdVector LongPointer shape, @ByRef NDArray target);
|
||||||
public native void tileToShape(@Cast("Nd4jLong*") @StdVector LongBuffer shape, NDArray target/*=nullptr*/);
|
public native void tileToShape(@Cast("Nd4jLong*") @StdVector LongBuffer shape, @ByRef NDArray target);
|
||||||
public native void tileToShape(@Cast("Nd4jLong*") @StdVector long[] shape, NDArray target/*=nullptr*/);
|
public native void tileToShape(@Cast("Nd4jLong*") @StdVector long[] shape, @ByRef NDArray target);
|
||||||
// #ifndef __JAVACPP_HACK__
|
// #ifndef __JAVACPP_HACK__
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
public native NDArray asT(@Cast("nd4j::DataType") int dtype);
|
public native @ByVal NDArray asT(@Cast("nd4j::DataType") int dtype);
|
||||||
|
|
||||||
|
|
||||||
public native void linspace(double start);
|
public native void linspace(double start);
|
||||||
|
@ -4554,17 +4450,15 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
*/
|
*/
|
||||||
public native double getTrace();
|
public native double getTrace();
|
||||||
|
|
||||||
public native ResultSet multipleTensorsAlongDimension(@StdVector IntPointer indices, @StdVector IntPointer dimensions);
|
public native @ByVal ResultSet multipleTensorsAlongDimension(@StdVector IntPointer indices, @StdVector IntPointer dimensions);
|
||||||
public native ResultSet multipleTensorsAlongDimension(@StdVector IntBuffer indices, @StdVector IntBuffer dimensions);
|
public native @ByVal ResultSet multipleTensorsAlongDimension(@StdVector IntBuffer indices, @StdVector IntBuffer dimensions);
|
||||||
public native ResultSet multipleTensorsAlongDimension(@StdVector int[] indices, @StdVector int[] dimensions);
|
public native @ByVal ResultSet multipleTensorsAlongDimension(@StdVector int[] indices, @StdVector int[] dimensions);
|
||||||
|
|
||||||
public native ResultSet allTensorsAlongDimension(@StdVector IntPointer dimensions);
|
public native @ByVal ResultSet allTensorsAlongDimension(@StdVector IntPointer dimensions);
|
||||||
public native ResultSet allTensorsAlongDimension(@StdVector IntBuffer dimensions);
|
public native @ByVal ResultSet allTensorsAlongDimension(@StdVector IntBuffer dimensions);
|
||||||
public native ResultSet allTensorsAlongDimension(@StdVector int[] dimensions);
|
public native @ByVal ResultSet allTensorsAlongDimension(@StdVector int[] dimensions);
|
||||||
|
|
||||||
//ResultSet allTensorsAlongDims(const std::vector<int>& dimensions) const;
|
public native @ByVal ResultSet allExamples();
|
||||||
|
|
||||||
public native ResultSet allExamples();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set _shapeInfo
|
* set _shapeInfo
|
||||||
|
@ -4672,7 +4566,7 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
/**
|
/**
|
||||||
* returns true if these two NDArrays have same rank, dimensions, strides, ews and order
|
* returns true if these two NDArrays have same rank, dimensions, strides, ews and order
|
||||||
*/
|
*/
|
||||||
public native @Cast("bool") boolean isSameShapeStrict(@Const NDArray other);
|
public native @Cast("bool") boolean isSameShapeStrict(@Const @ByRef NDArray other);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns true if buffer && shapeInfo were defined (non nullptr)
|
* returns true if buffer && shapeInfo were defined (non nullptr)
|
||||||
|
@ -4731,11 +4625,6 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
*/
|
*/
|
||||||
public native void p(@Cast("const Nd4jLong") long i, @Cast("const Nd4jLong") long j, @Cast("const Nd4jLong") long k, @Cast("const Nd4jLong") long l, @Const @ByRef NDArray value);
|
public native void p(@Cast("const Nd4jLong") long i, @Cast("const Nd4jLong") long j, @Cast("const Nd4jLong") long k, @Cast("const Nd4jLong") long l, @Const @ByRef NDArray value);
|
||||||
|
|
||||||
/**
|
|
||||||
* creates array which points on certain sub-range of this array, sub-range is defined by given indices
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns true if array is 2D
|
* returns true if array is 2D
|
||||||
*/
|
*/
|
||||||
|
@ -4806,59 +4695,6 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
*/
|
*/
|
||||||
public native @Cast("bool") boolean isS();
|
public native @Cast("bool") boolean isS();
|
||||||
|
|
||||||
/**
|
|
||||||
* inline accessing operator for matrix, i - absolute index
|
|
||||||
*/
|
|
||||||
//FORCEINLINE NDArray operator()(const Nd4jLong i) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* inline modifying operator for matrix, i - absolute index
|
|
||||||
*/
|
|
||||||
//FORCEINLINE NDArray& operator()(const Nd4jLong i);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* inline accessing operator for 2D array, i - row, j - column
|
|
||||||
*/
|
|
||||||
//FORCEINLINE NDArray operator()(const Nd4jLong i, const Nd4jLong j) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* inline modifying operator for 2D array, i - row, j - column
|
|
||||||
*/
|
|
||||||
//FORCEINLINE NDArray& operator()(const Nd4jLong i, const Nd4jLong j);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* inline accessing operator for 3D array, i - height, j - width, k - depth
|
|
||||||
*/
|
|
||||||
//FORCEINLINE NDArray operator()(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* inline modifying operator for 3D array, i - height, j - width, k - depth
|
|
||||||
*/
|
|
||||||
//FORCEINLINE NDArray& operator()(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* inline modifying operator for 4D array, i - height, j - width, k - depth
|
|
||||||
*/
|
|
||||||
//FORCEINLINE NDArray& operator()(const Nd4jLong t, const Nd4jLong u, const Nd4jLong v, const Nd4jLong w);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* inline accessing operator for 4D array, i - height, j - width, k - depth
|
|
||||||
*/
|
|
||||||
//FORCEINLINE NDArray operator()(const Nd4jLong t, const Nd4jLong u, const Nd4jLong v, const Nd4jLong w) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* inline modifying operator for ND array
|
|
||||||
* idx - array with corresponding indexes, for example {2,10,0,5,...,8}, number of indexes should be equal to array rank
|
|
||||||
*/
|
|
||||||
//FORCEINLINE NDArray& operator()(const Nd4jLong* idx);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* inline accessing operator for ND array
|
|
||||||
* idx - array with corresponding indexes, for example {2,10,0,5,...,8}, number of indexes should be equal to array rank
|
|
||||||
*/
|
|
||||||
//FORCEINLINE NDArray operator()(const Nd4jLong* idx) const;
|
|
||||||
|
|
||||||
|
|
||||||
public native @Cast("bool") boolean isAttached();
|
public native @Cast("bool") boolean isAttached();
|
||||||
|
|
||||||
public native NDArray detach();
|
public native NDArray detach();
|
||||||
|
@ -4878,263 +4714,70 @@ public native @Cast("bool") boolean isOptimalRequirementsMet();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// accessing operator for matrix, i - absolute index
|
|
||||||
/*
|
|
||||||
NDArray NDArray::operator()(const Nd4jLong i) const {
|
|
||||||
|
|
||||||
if (i >= shape::length(_shapeInfo))
|
|
||||||
throw std::invalid_argument("NDArray::operator(i): input index is out of array length !");
|
|
||||||
|
|
||||||
auto ews = shape::elementWiseStride(_shapeInfo);
|
|
||||||
char order = ordering();
|
|
||||||
|
|
||||||
if(ews == 1 && order == 'c') {
|
|
||||||
auto cast = reinterpret_cast<int8_t *>(_buffer) + (i * this->sizeOfT());
|
|
||||||
NDArray result(cast, nd4j::ShapeBuilders::createScalarShapeInfo(this->dataType(), this->getWorkspace()));
|
|
||||||
return result;
|
|
||||||
} else if(ews > 1 && order == 'c') {
|
|
||||||
auto cast = reinterpret_cast<int8_t *>(_buffer) + (i * ews * this->sizeOfT());
|
|
||||||
NDArray result(cast, nd4j::ShapeBuilders::createScalarShapeInfo(this->dataType(), this->getWorkspace()));
|
|
||||||
return result;
|
|
||||||
} else {
|
|
||||||
Nd4jLong idx[MAX_RANK];
|
|
||||||
shape::ind2subC(rankOf(), shapeOf(), i, idx);
|
|
||||||
auto xOffset = shape::getOffset(getShapeInfo(), idx);
|
|
||||||
|
|
||||||
auto cast = reinterpret_cast<int8_t *>(_buffer) + (xOffset * this->sizeOfT());
|
|
||||||
NDArray result(cast, nd4j::ShapeBuilders::createScalarShapeInfo(this->dataType(), this->getWorkspace()));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
// modifying operator for matrix, i - absolute index
|
|
||||||
/*
|
|
||||||
NDArray& NDArray::operator()(const Nd4jLong i) {
|
|
||||||
if (i >= shape::length(_shapeInfo))
|
|
||||||
throw std::invalid_argument("NDArray::operator(i): input index is out of array length !");
|
|
||||||
|
|
||||||
auto ews = shape::elementWiseStride(_shapeInfo);
|
|
||||||
auto order = ordering();
|
|
||||||
|
|
||||||
if(ews == 1 && order == 'c') {
|
|
||||||
auto cast = reinterpret_cast<int8_t *>(_buffer) + (i * this->sizeOfT());
|
|
||||||
NDArray result(cast, nd4j::ShapeBuilders::createScalarShapeInfo(this->dataType(), this->getWorkspace()));
|
|
||||||
|
|
||||||
// FIXME: bad
|
|
||||||
return result;
|
|
||||||
} else if(ews > 1 && order == 'c') {
|
|
||||||
auto cast = reinterpret_cast<int8_t *>(_buffer) + (i * ews * this->sizeOfT());
|
|
||||||
NDArray result(cast, nd4j::ShapeBuilders::createScalarShapeInfo(this->dataType(), this->getWorkspace()));
|
|
||||||
return result;
|
|
||||||
} else {
|
|
||||||
Nd4jLong idx[MAX_RANK];
|
|
||||||
shape::ind2subC(rankOf(), shapeOf(), i, idx);
|
|
||||||
auto xOffset = shape::getOffset(getShapeInfo(), idx);
|
|
||||||
|
|
||||||
auto cast = reinterpret_cast<int8_t *>(_buffer) + (xOffset * this->sizeOfT());
|
|
||||||
NDArray result(cast, nd4j::ShapeBuilders::createScalarShapeInfo(this->dataType(), this->getWorkspace()));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// accessing operator for 2D matrix, i - row, j - column
|
|
||||||
/*
|
|
||||||
NDArray NDArray::operator()(const Nd4jLong i, const Nd4jLong j) const {
|
|
||||||
|
|
||||||
if (rankOf() != 2 || i >= shapeOf()[0] || j >= shapeOf()[1])
|
|
||||||
throw std::invalid_argument("NDArray::operator(i,j): one of input indexes is out of array length or rank!=2 !");
|
|
||||||
|
|
||||||
Nd4jLong coords[2] = {i, j};
|
|
||||||
auto xOffset = shape::getOffset(getShapeInfo(), coords);
|
|
||||||
|
|
||||||
// TODO: do we really want a view here?
|
|
||||||
auto cast = reinterpret_cast<int8_t *>(_buffer) + (xOffset * this->sizeOfT());
|
|
||||||
NDArray result(cast, nd4j::ShapeBuilders::createScalarShapeInfo(this->dataType(), this->getWorkspace()));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
// modifying operator for 2D matrix, i - row, j - column
|
|
||||||
/*
|
|
||||||
NDArray& NDArray::operator()(const Nd4jLong i, const Nd4jLong j) {
|
|
||||||
if (rankOf() != 2 || i >= shapeOf()[0] || j >= shapeOf()[1])
|
|
||||||
throw std::invalid_argument("NDArray::operator(i,j): one of input indexes is out of array length or rank!=2 !");
|
|
||||||
|
|
||||||
Nd4jLong coords[2] = {i, j};
|
|
||||||
auto xOffset = shape::getOffset(getShapeInfo(), coords);
|
|
||||||
|
|
||||||
auto cast = reinterpret_cast<int8_t *>(_buffer) + (xOffset * this->sizeOfT());
|
|
||||||
NDArray result(cast, nd4j::ShapeBuilders::createScalarShapeInfo(this->dataType(), this->getWorkspace()));
|
|
||||||
|
|
||||||
//FIXME: bad, will crash!
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// accessing operator for 3D array, i - row, j - column
|
|
||||||
/*
|
|
||||||
NDArray NDArray::operator()(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k) const {
|
|
||||||
|
|
||||||
if (rankOf() != 3 || i >= shapeOf()[0] || j >= shapeOf()[1] || j >= shapeOf()[2])
|
|
||||||
throw std::invalid_argument("NDArray::operator(i,j,k): one of input indexes is out of array length or rank!=3 !");
|
|
||||||
|
|
||||||
Nd4jLong coords[3] = {i, j, k};
|
|
||||||
auto xOffset = shape::getOffset(getShapeInfo(), coords);
|
|
||||||
|
|
||||||
auto cast = reinterpret_cast<int8_t *>(_buffer) + (xOffset * this->sizeOfT());
|
|
||||||
NDArray result(cast, nd4j::ShapeBuilders::createScalarShapeInfo(this->dataType(), this->getWorkspace()));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// modifying operator for 3D array
|
|
||||||
/*
|
|
||||||
NDArray& NDArray::operator()(const Nd4jLong i, const Nd4jLong j, const Nd4jLong k) {
|
|
||||||
|
|
||||||
if (rankOf() != 3 || i >= shapeOf()[0] || j >= shapeOf()[1] || k >= shapeOf()[2])
|
|
||||||
throw std::invalid_argument("NDArray::operator(i,j,k): one of input indexes is out of array length or rank!=3 !");
|
|
||||||
|
|
||||||
Nd4jLong coords[3] = {i, j, k};
|
|
||||||
auto xOffset = shape::getOffset(getShapeInfo(), coords);
|
|
||||||
|
|
||||||
auto cast = reinterpret_cast<int8_t *>(_buffer) + (xOffset * this->sizeOfT());
|
|
||||||
NDArray result(cast, nd4j::ShapeBuilders::createScalarShapeInfo(this->dataType(), this->getWorkspace()));
|
|
||||||
|
|
||||||
//FIXME: bad, will crash!
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
NDArray NDArray::operator()(const Nd4jLong t, const Nd4jLong u, const Nd4jLong v, const Nd4jLong w) const {
|
|
||||||
|
|
||||||
if (rankOf() != 4 || t >= shapeOf()[0] || u >= shapeOf()[1] || v >= shapeOf()[2] || w >= shapeOf()[3])
|
|
||||||
throw std::invalid_argument("NDArray::operator(t,u,v,w): one of input indexes is out of array length or rank!=4 !");
|
|
||||||
|
|
||||||
Nd4jLong coords[4] = {t, u, v, w};
|
|
||||||
auto xOffset = shape::getOffset(getShapeInfo(), coords);
|
|
||||||
|
|
||||||
auto cast = reinterpret_cast<int8_t *>(_buffer) + (xOffset * this->sizeOfT());
|
|
||||||
NDArray result(cast, nd4j::ShapeBuilders::createScalarShapeInfo(this->dataType(), this->getWorkspace()));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
NDArray& NDArray::operator()(const Nd4jLong t, const Nd4jLong u, const Nd4jLong v, const Nd4jLong w) {
|
|
||||||
|
|
||||||
if (rankOf() != 4 || t >= shapeOf()[0] || u >= shapeOf()[1] || v >= shapeOf()[2] || w >= shapeOf()[3])
|
|
||||||
throw std::invalid_argument("NDArray::operator(t,u,v,w): one of input indexes is out of array length or rank!=4 !");
|
|
||||||
|
|
||||||
Nd4jLong coords[4] = {t, u, v, w};
|
|
||||||
auto xOffset = shape::getOffset(getShapeInfo(), coords);
|
|
||||||
|
|
||||||
// FIXME
|
|
||||||
auto cast = reinterpret_cast<int8_t *>(_buffer) + (xOffset * this->sizeOfT());
|
|
||||||
NDArray result(cast, nd4j::ShapeBuilders::createScalarShapeInfo(this->dataType(), this->getWorkspace()));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/*
|
|
||||||
NDArray NDArray::operator()(const Nd4jLong* idx) const {
|
|
||||||
|
|
||||||
for(int i = 0; i < rankOf(); ++i)
|
|
||||||
if (idx[i] >= sizeAt(i))
|
|
||||||
throw std::invalid_argument("NDArray::operator(const Nd4jLong* idx): input index is out of dimension length !");
|
|
||||||
|
|
||||||
auto xOffset = shape::getOffset(getShapeInfo(), idx);
|
|
||||||
|
|
||||||
auto cast = reinterpret_cast<int8_t *>(_buffer) + (xOffset * this->sizeOfT());
|
|
||||||
NDArray result(cast, nd4j::ShapeBuilders::createScalarShapeInfo(this->dataType(), this->getWorkspace()));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/*
|
|
||||||
NDArray& NDArray::operator()(const Nd4jLong* idx) {
|
|
||||||
|
|
||||||
for(int i = 0; i < rankOf(); ++i)
|
|
||||||
if (idx[i] >= sizeAt(i))
|
|
||||||
throw std::invalid_argument("NDArray::operator(const Nd4jLong* idx): input index is out of dimension length !");
|
|
||||||
|
|
||||||
auto xOffset = shape::getOffset(getShapeInfo(), idx);
|
|
||||||
|
|
||||||
auto cast = reinterpret_cast<int8_t *>(_buffer) + (xOffset * this->sizeOfT());
|
|
||||||
NDArray result(cast, nd4j::ShapeBuilders::createScalarShapeInfo(this->dataType(), this->getWorkspace()));
|
|
||||||
|
|
||||||
// FIXME
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// still the definition of inline function must be in header file
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
// still the definition of inline function must be in header file
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -6781,9 +6424,11 @@ NDArray& NDArray::operator()(const Nd4jLong* idx) {
|
||||||
|
|
||||||
public native void setCudaContext(@Cast("Nd4jPointer") Pointer cudaStream, @Cast("Nd4jPointer") Pointer reductionPointer, @Cast("Nd4jPointer") Pointer allocationPointer);
|
public native void setCudaContext(@Cast("Nd4jPointer") Pointer cudaStream, @Cast("Nd4jPointer") Pointer reductionPointer, @Cast("Nd4jPointer") Pointer allocationPointer);
|
||||||
|
|
||||||
|
|
||||||
public native void allowHelpers(@Cast("bool") boolean reallyAllow);
|
public native void allowHelpers(@Cast("bool") boolean reallyAllow);
|
||||||
public native @Cast("bool") boolean helpersAllowed();
|
public native @Cast("bool") boolean helpersAllowed();
|
||||||
|
|
||||||
|
public native void setShapeFunctionOverride(@Cast("bool") boolean reallyOverride);
|
||||||
|
public native @Cast("bool") boolean shapeFunctionOverride();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -11193,7 +10838,9 @@ public static final int TAD_THRESHOLD = TAD_THRESHOLD();
|
||||||
// #if defined(_MSC_VER) || defined(_WIN64) || defined(_WIN32) || defined(__CLION_IDE__) || defined(__VSCODE__)
|
// #if defined(_MSC_VER) || defined(_WIN64) || defined(_WIN32) || defined(__CLION_IDE__) || defined(__VSCODE__)
|
||||||
// #define NOT_EXCLUDED(NAME) 1>0
|
// #define NOT_EXCLUDED(NAME) 1>0
|
||||||
// #else
|
// #else
|
||||||
// #define NOT_EXCLUDED(NAME) defined(LIBND4J_ALL_OPS) || defined(NAME)
|
// for now we don't want minifier mechanics working
|
||||||
|
//#define NOT_EXCLUDED(NAME) defined(LIBND4J_ALL_OPS) || defined(NAME)
|
||||||
|
// #define NOT_EXCLUDED(NAME) 1>0
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// #ifdef __JAVACPP_HACK__
|
// #ifdef __JAVACPP_HACK__
|
||||||
|
@ -12368,6 +12015,7 @@ public static final int TAD_THRESHOLD = TAD_THRESHOLD();
|
||||||
// #include <ops/declarable/headers/tests.h>
|
// #include <ops/declarable/headers/tests.h>
|
||||||
// #include <ops/declarable/headers/kernels.h>
|
// #include <ops/declarable/headers/kernels.h>
|
||||||
// #include <ops/declarable/headers/BarnesHutTsne.h>
|
// #include <ops/declarable/headers/BarnesHutTsne.h>
|
||||||
|
// #include <ops/declarable/headers/images.h>
|
||||||
// #include <dll.h>
|
// #include <dll.h>
|
||||||
// #include <helpers/shape.h>
|
// #include <helpers/shape.h>
|
||||||
// #include <helpers/TAD.h>
|
// #include <helpers/TAD.h>
|
||||||
|
@ -17115,7 +16763,7 @@ public static final int TAD_THRESHOLD = TAD_THRESHOLD();
|
||||||
* This operation calculates hash code, optionally along dimension
|
* This operation calculates hash code, optionally along dimension
|
||||||
*/
|
*/
|
||||||
// #if NOT_EXCLUDED(OP_hashcode)
|
// #if NOT_EXCLUDED(OP_hashcode)
|
||||||
@Namespace("nd4j::ops") public static class hashcode extends DeclarableReductionOp {
|
@Namespace("nd4j::ops") public static class hashcode extends DeclarableCustomOp {
|
||||||
static { Loader.load(); }
|
static { Loader.load(); }
|
||||||
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
|
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
|
||||||
public hashcode(Pointer p) { super(p); }
|
public hashcode(Pointer p) { super(p); }
|
||||||
|
@ -17128,6 +16776,7 @@ public static final int TAD_THRESHOLD = TAD_THRESHOLD();
|
||||||
|
|
||||||
public hashcode() { super((Pointer)null); allocate(); }
|
public hashcode() { super((Pointer)null); allocate(); }
|
||||||
private native void allocate();
|
private native void allocate();
|
||||||
|
public native ShapeList calculateOutputShape(ShapeList inputShape, @ByRef Context block);
|
||||||
}
|
}
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
|
@ -19345,6 +18994,38 @@ public static final int TAD_THRESHOLD = TAD_THRESHOLD();
|
||||||
}
|
}
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* lu op. - make LUP decomposition of given batch of 2D square matricies
|
||||||
|
*
|
||||||
|
* input params:
|
||||||
|
* 0 - float tensor with dimension (x * y * z * ::: * M * M)
|
||||||
|
*
|
||||||
|
* return value:
|
||||||
|
* 0 - float tensor with dimension (x * y * z * ::: * M * M) with LU M x M matricies in it
|
||||||
|
* 1 - int (32 or 64) batched vector of permutations with length M - shape (x * y * z * ::: * M)
|
||||||
|
*
|
||||||
|
* int argument:
|
||||||
|
* 0 - data type of output permutaion vector (int32 or int64), optional, default INT32
|
||||||
|
*/
|
||||||
|
|
||||||
|
// #if NOT_EXCLUDED(OP_matrix_inverse)
|
||||||
|
@Namespace("nd4j::ops") public static class lu extends DeclarableCustomOp {
|
||||||
|
static { Loader.load(); }
|
||||||
|
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
|
||||||
|
public lu(Pointer p) { super(p); }
|
||||||
|
/** Native array allocator. Access with {@link Pointer#position(long)}. */
|
||||||
|
public lu(long size) { super((Pointer)null); allocateArray(size); }
|
||||||
|
private native void allocateArray(long size);
|
||||||
|
@Override public lu position(long position) {
|
||||||
|
return (lu)super.position(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
public lu() { super((Pointer)null); allocate(); }
|
||||||
|
private native void allocate();
|
||||||
|
public native ShapeList calculateOutputShape(ShapeList inputShape, @ByRef Context block);
|
||||||
|
}
|
||||||
|
// #endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sequence_mask op. - make mask for given tensor filled by (j > x[i_1, i_2,...,i_n]) -> z[i_1, i_2,...,i_n,j]
|
* sequence_mask op. - make mask for given tensor filled by (j > x[i_1, i_2,...,i_n]) -> z[i_1, i_2,...,i_n,j]
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue