public class DynamicCustomOp extends DifferentialFunction implements CustomOp
Modifier and Type | Class and Description |
---|---|
static class |
DynamicCustomOp.DynamicCustomOpsBuilder |
Modifier and Type | Field and Description |
---|---|
protected List<Integer> |
axis |
protected List<Boolean> |
bArguments |
protected List<DataType> |
dArguments |
protected List<Long> |
iArguments |
protected boolean |
inplaceCall |
protected List<INDArray> |
inputArguments |
protected List<INDArray> |
outputArguments |
protected SDVariable[] |
outputVariables |
protected List<Double> |
tArguments |
dimensions, extraArgs, inPlace, sameDiff, scalarValue
Modifier | Constructor and Description |
---|---|
|
DynamicCustomOp() |
|
DynamicCustomOp(INDArray[] inputs,
INDArray[] outputs)
Initialize this operation for execution (pre created ndarrays)
|
|
DynamicCustomOp(SameDiff sameDiff,
SDVariable arg) |
|
DynamicCustomOp(SameDiff sameDiff,
SDVariable[] args) |
|
DynamicCustomOp(SameDiff sameDiff,
SDVariable[] args,
boolean inPlace) |
protected |
DynamicCustomOp(String opName) |
|
DynamicCustomOp(String opName,
INDArray[] inputs,
INDArray[] outputs)
Initialize this operation for execution (pre created ndarrays)
|
|
DynamicCustomOp(String opName,
INDArray[] inputs,
INDArray[] outputs,
List<Double> tArguments,
int[] iArguments) |
|
DynamicCustomOp(String opName,
INDArray[] inputs,
INDArray[] outputs,
List<Double> tArguments,
List<Integer> iArguments)
Initialize this custom op with all of the
inputs, outputs, and respective
arguments for execution
|
|
DynamicCustomOp(String opName,
INDArray input,
INDArray output,
List<Double> tArguments,
int[] iArguments) |
|
DynamicCustomOp(String opName,
SameDiff sameDiff,
SDVariable[] args) |
|
DynamicCustomOp(String opName,
SameDiff sameDiff,
SDVariable[] args,
boolean inPlace)
Initialize this for
SameDiff execution
Any extra int or float arguments for operations
must be added to the respective TArguments
or IArguments lists upon construction |
Modifier and Type | Method and Description |
---|---|
void |
addBArgument(boolean... arg) |
void |
addDArgument(DataType... arg) |
void |
addIArgument(int... arg) |
void |
addIArgument(long... arg) |
void |
addInputArgument(INDArray... arg) |
void |
addOutputArgument(INDArray... arg) |
void |
addTArgument(double... arg) |
void |
assertValidForExecution()
Asserts a valid state for execution,
otherwise throws an
ND4JIllegalStateException |
boolean[] |
bArgs() |
static DynamicCustomOp.DynamicCustomOpsBuilder |
builder(String opName)
This method takes custom opname, and return Op DynamicCustomOpsBuilder instance
|
List<LongShapeDescriptor> |
calculateOutputShape()
Calculate the output shape for this op
|
List<LongShapeDescriptor> |
calculateOutputShape(OpContext oc)
Calculate the output shape for this op
|
void |
clearArrays()
Clear the input and output INDArrays, if any are set
|
DataType[] |
dArgs() |
List<SDVariable> |
doDiff(List<SDVariable> f1)
The actual implementation for automatic differentiation.
|
Boolean |
getBArgument(int index) |
CustomOpDescriptor |
getDescriptor()
Get the custom op descriptor if one is available.
|
Long |
getIArgument(int index) |
INDArray |
getInputArgument(int index) |
INDArray |
getOutputArgument(int index) |
Double |
getTArgument(int index) |
long[] |
iArgs() |
void |
initFromOnnx(Onnx.NodeProto node,
SameDiff initWith,
Map<String,Onnx.AttributeProto> attributesForNode,
Onnx.GraphProto graph)
Iniitialize the function from the given
Onnx.NodeProto |
void |
initFromTensorFlow(NodeDef nodeDef,
SameDiff initWith,
Map<String,AttrValue> attributesForNode,
GraphDef graph)
Initialize the function from the given
NodeDef |
List<INDArray> |
inputArguments() |
int |
numBArguments() |
int |
numDArguments() |
int |
numIArguments() |
int |
numInputArguments() |
int |
numOutputArguments() |
int |
numTArguments() |
String |
onnxName()
The opName of this function in onnx
|
long |
opHash()
This method returns LongHash of the opName()
|
String |
opName()
This method returns op opName as string
|
int |
opNum()
The number of the op (mainly for old legacy XYZ ops
like
Op ) |
Op.Type |
opType()
The type of the op
|
List<INDArray> |
outputArguments() |
SDVariable[] |
outputVariables()
Return the output variables for this differential function.
|
SDVariable[] |
outputVariables(String baseName)
Return the output functions for this differential function.
|
void |
removeIArgument(Integer arg) |
void |
removeInputArgument(INDArray arg) |
void |
removeOutputArgument(INDArray arg) |
void |
removeTArgument(Double arg) |
void |
setInputArgument(int index,
INDArray input) |
void |
setInputArguments(INDArray... inputs) |
void |
setOutputArgument(int index,
INDArray output) |
double[] |
tArgs() |
String |
tensorflowName()
The opName of this function tensorflow
|
String |
toString() |
protected static <T> T[] |
wrapFilterNull(T... in) |
protected static INDArray[] |
wrapOrNull(INDArray in) |
protected static SDVariable[] |
wrapOrNull(SDVariable in) |
arg, arg, argNames, args, attributeAdaptersForFunction, calculateOutputDataTypes, configFieldName, diff, dup, equals, getNumOutputs, getValue, hashCode, isConfigProperties, larg, mappingsForFunction, onnxNames, outputs, outputVariable, outputVariablesNames, propertiesForFunction, rarg, replaceArg, setInstanceId, setPropertiesForFunction, setValueFor, tensorflowNames
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
isInplaceCall
protected boolean inplaceCall
protected SDVariable[] outputVariables
public DynamicCustomOp()
public DynamicCustomOp(SameDiff sameDiff, SDVariable arg)
public DynamicCustomOp(SameDiff sameDiff, SDVariable[] args)
public DynamicCustomOp(String opName, SameDiff sameDiff, SDVariable[] args)
public DynamicCustomOp(String opName, INDArray input, INDArray output, List<Double> tArguments, int[] iArguments)
public DynamicCustomOp(String opName, INDArray[] inputs, INDArray[] outputs, List<Double> tArguments, int[] iArguments)
public DynamicCustomOp(String opName, INDArray[] inputs, INDArray[] outputs, List<Double> tArguments, List<Integer> iArguments)
opName
- the opName of the op to executeinputs
- the inputs to the opoutputs
- the outputs of the optArguments
- the input float argumentsiArguments
- the input int argumentspublic DynamicCustomOp(INDArray[] inputs, INDArray[] outputs)
inputs
- the inputsoutputs
- the outputs of the op, may be nullpublic DynamicCustomOp(String opName, INDArray[] inputs, INDArray[] outputs)
opName
- the operation opName to use for invocationinputs
- the inputsoutputs
- the outputs of the op, may be nullpublic DynamicCustomOp(String opName, SameDiff sameDiff, SDVariable[] args, boolean inPlace)
SameDiff
execution
Any extra int or float arguments for operations
must be added to the respective TArguments
or IArguments lists upon constructionopName
- the operation opNamesameDiff
- the samediff instance to useargs
- the arguments to useinPlace
- whether the operation is in place or notpublic DynamicCustomOp(SameDiff sameDiff, SDVariable[] args, boolean inPlace)
protected DynamicCustomOp(String opName)
public String opName()
opName
in interface CustomOp
opName
in class DifferentialFunction
public SDVariable[] outputVariables()
DifferentialFunction
outputVariables
in class DifferentialFunction
public SDVariable[] outputVariables(String baseName)
DifferentialFunction
outputVariables
in class DifferentialFunction
public long opHash()
public int numDArguments()
numDArguments
in interface CustomOp
public List<INDArray> outputArguments()
outputArguments
in interface CustomOp
public List<INDArray> inputArguments()
inputArguments
in interface CustomOp
public void addIArgument(int... arg)
addIArgument
in interface CustomOp
public void addIArgument(long... arg)
addIArgument
in interface CustomOp
public void removeIArgument(Integer arg)
removeIArgument
in interface CustomOp
public Long getIArgument(int index)
getIArgument
in interface CustomOp
public int numIArguments()
numIArguments
in interface CustomOp
public int numBArguments()
numBArguments
in interface CustomOp
public void addTArgument(double... arg)
addTArgument
in interface CustomOp
public void addDArgument(DataType... arg)
addDArgument
in interface CustomOp
public void removeTArgument(Double arg)
removeTArgument
in interface CustomOp
public Double getTArgument(int index)
getTArgument
in interface CustomOp
public int numTArguments()
numTArguments
in interface CustomOp
public void addInputArgument(INDArray... arg)
addInputArgument
in interface CustomOp
public void removeInputArgument(INDArray arg)
removeInputArgument
in interface CustomOp
public INDArray getInputArgument(int index)
getInputArgument
in interface CustomOp
getInputArgument
in class DifferentialFunction
public void setInputArgument(int index, INDArray input)
public void setInputArguments(INDArray... inputs)
public void setOutputArgument(int index, INDArray output)
public int numInputArguments()
numInputArguments
in interface CustomOp
public void addOutputArgument(INDArray... arg)
addOutputArgument
in interface CustomOp
public void removeOutputArgument(INDArray arg)
removeOutputArgument
in interface CustomOp
public INDArray getOutputArgument(int index)
getOutputArgument
in interface CustomOp
public int numOutputArguments()
numOutputArguments
in interface CustomOp
public int opNum()
DifferentialFunction
Op
)opNum
in class DifferentialFunction
public static DynamicCustomOp.DynamicCustomOpsBuilder builder(String opName)
opName
- public List<LongShapeDescriptor> calculateOutputShape()
DifferentialFunction
calculateOutputShape
in interface CustomOp
calculateOutputShape
in class DifferentialFunction
public List<LongShapeDescriptor> calculateOutputShape(OpContext oc)
CustomOp
calculateOutputShape
in interface CustomOp
calculateOutputShape
in class DifferentialFunction
public CustomOpDescriptor getDescriptor()
CustomOp
getDescriptor
in interface CustomOp
public void assertValidForExecution()
CustomOp
ND4JIllegalStateException
assertValidForExecution
in interface CustomOp
public List<SDVariable> doDiff(List<SDVariable> f1)
DifferentialFunction
doDiff
in class DifferentialFunction
public void addBArgument(boolean... arg)
addBArgument
in interface CustomOp
public Boolean getBArgument(int index)
getBArgument
in interface CustomOp
public String onnxName()
DifferentialFunction
onnxName
in class DifferentialFunction
public String tensorflowName()
DifferentialFunction
tensorflowName
in class DifferentialFunction
public Op.Type opType()
DifferentialFunction
opType
in class DifferentialFunction
public void initFromTensorFlow(NodeDef nodeDef, SameDiff initWith, Map<String,AttrValue> attributesForNode, GraphDef graph)
DifferentialFunction
NodeDef
initFromTensorFlow
in class DifferentialFunction
public void initFromOnnx(Onnx.NodeProto node, SameDiff initWith, Map<String,Onnx.AttributeProto> attributesForNode, Onnx.GraphProto graph)
DifferentialFunction
Onnx.NodeProto
initFromOnnx
in class DifferentialFunction
public void clearArrays()
DifferentialFunction
clearArrays
in interface CustomOp
clearArrays
in class DifferentialFunction
protected static SDVariable[] wrapOrNull(SDVariable in)
protected static <T> T[] wrapFilterNull(T... in)
Copyright © 2020. All rights reserved.