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 INDArraydimensionzprotected DataBufferextraArgzprotected INDArrayxprotected StringxVertexIdprotected INDArrayyprotected StringyVertexIdprotected INDArrayzprotected StringzVertexId-
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 voidclearArrays()Clear the input and output INDArrays, if any are setvoidcomputeVariables(SDVariable[] newVars)Compute the output vars using this op and store them in the samediff instance.protected voiddefineDimensions(int... dimensions)INDArraydimensions()booleanequals(Object o)Object[]extraArgs()Extra argumentsBufferextraArgsBuff()Returns a buffer of either float or double of the extra args for this bufferDataBufferextraArgsDataBuff(DataType dtype)Returns the extra args as a data bufferNumbergetFinalResult()INDArraygetInputArgument(int index)intgetNumOutputs()static Op.TypegetOpType(Op op)inthashCode()voidinitFromOnnx(Onnx.NodeProto node, SameDiff initWith, Map<String,Onnx.AttributeProto> attributesForNode, Onnx.GraphProto graph)Iniitialize the function from the givenOnnx.NodeProtovoidinitFromTensorFlow(NodeDef nodeDef, SameDiff initWith, Map<String,AttrValue> attributesForNode, GraphDef graph)Initialize the function from the givenNodeDefStringonnxName()The opName of this function in onnxSDVariable[]outputVariables(String baseName)Return the output functions for this differential function.voidsetX(INDArray x)set x (the input ndarray)voidsetY(INDArray y)set y(the pairwise ndarray)voidsetZ(INDArray z)set z (the solution ndarray)StringtensorflowName()The opName of this function tensorflowCustomOptoCustomOp()StringtoString()INDArrayx()The origin ndarrayINDArrayy()The pairwise op ndarrayINDArrayz()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:DifferentialFunctionInitialize the function from the givenNodeDef- Specified by:
initFromTensorFlowin classDifferentialFunction
-
initFromOnnx
public void initFromOnnx(Onnx.NodeProto node, SameDiff initWith, Map<String,Onnx.AttributeProto> attributesForNode, Onnx.GraphProto graph)
Description copied from class:DifferentialFunctionIniitialize the function from the givenOnnx.NodeProto- Specified by:
initFromOnnxin classDifferentialFunction
-
extraArgsDataBuff
public DataBuffer extraArgsDataBuff(DataType dtype)
Description copied from interface:OpReturns the extra args as a data buffer- Specified by:
extraArgsDataBuffin interfaceOp- Returns:
-
extraArgsBuff
public Buffer extraArgsBuff()
Description copied from interface:OpReturns a buffer of either float or double of the extra args for this buffer- Specified by:
extraArgsBuffin 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:Opset z (the solution ndarray)
-
setY
public void setY(INDArray y)
Description copied from interface:Opset y(the pairwise ndarray)
-
getInputArgument
public INDArray getInputArgument(int index)
- Overrides:
getInputArgumentin classDifferentialFunction
-
outputVariables
public SDVariable[] outputVariables(String baseName)
Description copied from class:DifferentialFunctionReturn the output functions for this differential function.- Specified by:
outputVariablesin 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:OpConverts this op to be aCustomOpACustomOpis a more flexible op meant for multiple inputs and outputs. The default implementation inBaseOpconverts 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:
toCustomOpin interfaceOp- Returns:
- the equivalent
CustomOp
-
equals
public boolean equals(Object o)
- Overrides:
equalsin classDifferentialFunction
-
hashCode
public int hashCode()
- Overrides:
hashCodein classDifferentialFunction
-
defineDimensions
protected void defineDimensions(int... dimensions)
-
dimensions
public INDArray dimensions()
-
getFinalResult
public Number getFinalResult()
-
getNumOutputs
public int getNumOutputs()
- Overrides:
getNumOutputsin classDifferentialFunction
-
clearArrays
public void clearArrays()
Description copied from class:DifferentialFunctionClear the input and output INDArrays, if any are set- Specified by:
clearArraysin interfaceOp- Specified by:
clearArraysin classDifferentialFunction
-
onnxName
public String onnxName()
Description copied from class:DifferentialFunctionThe opName of this function in onnx- Specified by:
onnxNamein classDifferentialFunction- Returns:
-
tensorflowName
public String tensorflowName()
Description copied from class:DifferentialFunctionThe opName of this function tensorflow- Specified by:
tensorflowNamein classDifferentialFunction- Returns:
-
-