Package org.nd4j.linalg.api.ops
Class BaseOp
- java.lang.Object
-
- org.nd4j.autodiff.functions.DifferentialFunction
-
- org.nd4j.linalg.api.ops.BaseOp
-
- All Implemented Interfaces:
Op
- Direct Known Subclasses:
BaseBroadcastBoolOp
,BaseBroadcastOp
,BaseGridOp
,BaseIndexAccumulation
,BaseRandomOp
,BaseReduceOp
,BaseScalarBoolOp
,BaseScalarOp
,BaseTransformOp
public abstract class BaseOp extends DifferentialFunction implements Op
-
-
Field Summary
Fields Modifier and Type Field Description protected INDArray
dimensionz
protected DataBuffer
extraArgz
protected INDArray
x
protected String
xVertexId
protected INDArray
y
protected String
yVertexId
protected INDArray
z
protected String
zVertexId
-
Fields inherited from class org.nd4j.autodiff.functions.DifferentialFunction
dimensions, extraArgs, inPlace, ownName, ownNameSetWithDefault, sameDiff, scalarValue
-
-
Constructor Summary
Constructors Constructor Description BaseOp()
BaseOp(SameDiff sameDiff, boolean inPlace, Object[] extraArgs)
BaseOp(SameDiff sameDiff, Object[] extraArgs)
BaseOp(INDArray x)
An op for one ndarrayBaseOp(INDArray x, INDArray z)
Specify an alternative result arrayBaseOp(INDArray x, INDArray y, INDArray z)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearArrays()
Clear the input and output INDArrays, if any are setvoid
computeVariables(SDVariable[] newVars)
Compute the output vars using this op and store them in the samediff instance.protected void
defineDimensions(int... dimensions)
INDArray
dimensions()
boolean
equals(Object o)
Object[]
extraArgs()
Extra argumentsBuffer
extraArgsBuff()
Returns a buffer of either float or double of the extra args for this bufferDataBuffer
extraArgsDataBuff(DataType dtype)
Returns the extra args as a data bufferNumber
getFinalResult()
INDArray
getInputArgument(int index)
int
getNumOutputs()
static Op.Type
getOpType(Op op)
int
hashCode()
void
initFromOnnx(Onnx.NodeProto node, SameDiff initWith, Map<String,Onnx.AttributeProto> attributesForNode, Onnx.GraphProto graph)
Iniitialize the function from the givenOnnx.NodeProto
void
initFromTensorFlow(NodeDef nodeDef, SameDiff initWith, Map<String,AttrValue> attributesForNode, GraphDef graph)
Initialize the function from the givenNodeDef
String
onnxName()
The opName of this function in onnxSDVariable[]
outputVariables(String baseName)
Return the output functions for this differential function.void
setX(INDArray x)
set x (the input ndarray)void
setY(INDArray y)
set y(the pairwise ndarray)void
setZ(INDArray z)
set z (the solution ndarray)String
tensorflowName()
The opName of this function tensorflowCustomOp
toCustomOp()
String
toString()
INDArray
x()
The origin ndarrayINDArray
y()
The pairwise op ndarrayINDArray
z()
The resulting ndarray-
Methods inherited from class org.nd4j.autodiff.functions.DifferentialFunction
arg, arg, argNames, args, attributeAdaptersForFunction, calculateOutputDataTypes, calculateOutputShape, calculateOutputShape, configFieldName, configureWithSameDiff, diff, doDiff, dup, getBooleanFromProperty, getDoubleValueFromProperty, getIntValueFromProperty, getLongValueFromProperty, getStringFromProperty, getValue, isConfigProperties, larg, mappingsForFunction, onnxNames, opName, opNum, opType, outputs, outputVariable, outputVariables, outputVariablesNames, propertiesForFunction, rarg, replaceArg, setInstanceId, setPropertiesForFunction, setValueFor, tensorflowNames
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.nd4j.linalg.api.ops.Op
opName, opNum, setExtraArgs
-
-
-
-
Method Detail
-
initFromTensorFlow
public void initFromTensorFlow(NodeDef nodeDef, SameDiff initWith, Map<String,AttrValue> attributesForNode, GraphDef graph)
Description copied from class:DifferentialFunction
Initialize the function from the givenNodeDef
- Specified by:
initFromTensorFlow
in classDifferentialFunction
-
initFromOnnx
public void initFromOnnx(Onnx.NodeProto node, SameDiff initWith, Map<String,Onnx.AttributeProto> attributesForNode, Onnx.GraphProto graph)
Description copied from class:DifferentialFunction
Iniitialize the function from the givenOnnx.NodeProto
- Specified by:
initFromOnnx
in classDifferentialFunction
-
extraArgsDataBuff
public DataBuffer extraArgsDataBuff(DataType dtype)
Description copied from interface:Op
Returns the extra args as a data buffer- Specified by:
extraArgsDataBuff
in interfaceOp
- Returns:
-
extraArgsBuff
public Buffer extraArgsBuff()
Description copied from interface:Op
Returns a buffer of either float or double of the extra args for this buffer- Specified by:
extraArgsBuff
in interfaceOp
- Returns:
- a buffer of either opType float or double representing the extra args for this op
-
setZ
public void setZ(INDArray z)
Description copied from interface:Op
set z (the solution ndarray)
-
setY
public void setY(INDArray y)
Description copied from interface:Op
set y(the pairwise ndarray)
-
getInputArgument
public INDArray getInputArgument(int index)
- Overrides:
getInputArgument
in classDifferentialFunction
-
outputVariables
public SDVariable[] outputVariables(String baseName)
Description copied from class:DifferentialFunction
Return the output functions for this differential function.- Specified by:
outputVariables
in classDifferentialFunction
- Returns:
-
computeVariables
public void computeVariables(SDVariable[] newVars)
Compute the output vars using this op and store them in the samediff instance.- Parameters:
newVars
- the new variables to compute arrays for
-
toCustomOp
public CustomOp toCustomOp()
Description copied from interface:Op
Converts this op to be aCustomOp
ACustomOp
is a more flexible op meant for multiple inputs and outputs. The default implementation inBaseOp
converts a simple op to a multi input/output operation by mapping the x and y on to inputs , the op opName and the z on to outputs.- Specified by:
toCustomOp
in interfaceOp
- Returns:
- the equivalent
CustomOp
-
equals
public boolean equals(Object o)
- Overrides:
equals
in classDifferentialFunction
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classDifferentialFunction
-
defineDimensions
protected void defineDimensions(int... dimensions)
-
dimensions
public INDArray dimensions()
-
getFinalResult
public Number getFinalResult()
-
getNumOutputs
public int getNumOutputs()
- Overrides:
getNumOutputs
in classDifferentialFunction
-
clearArrays
public void clearArrays()
Description copied from class:DifferentialFunction
Clear the input and output INDArrays, if any are set- Specified by:
clearArrays
in interfaceOp
- Specified by:
clearArrays
in classDifferentialFunction
-
onnxName
public String onnxName()
Description copied from class:DifferentialFunction
The opName of this function in onnx- Specified by:
onnxName
in classDifferentialFunction
- Returns:
-
tensorflowName
public String tensorflowName()
Description copied from class:DifferentialFunction
The opName of this function tensorflow- Specified by:
tensorflowName
in classDifferentialFunction
- Returns:
-
-