public class DynamicCustomOp extends DifferentialFunction implements CustomOp
| Modifier and Type | Class and Description |
|---|---|
static class |
DynamicCustomOp.DynamicCustomOpsBuilder |
static class |
DynamicCustomOp.SameDiffBuilder |
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
inplaceCall |
protected SDVariable[] |
outputVariables |
dimensions, extraArgs, inPlace, sameDiff, scalarValue| Modifier | Constructor and Description |
|---|---|
|
DynamicCustomOp() |
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,
List<Integer> iArguments)
Initialize this custom op with all of the
inputs, outputs, and respective
arguments for execution
|
|
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 |
addIArgument(int... arg) |
void |
addInputArgument(INDArray... arg) |
void |
addOutputArgument(INDArray... arg) |
void |
addTArgument(double... arg) |
FunctionProperties |
asProperties()
Return function properties for the given function
|
void |
assertValidForExecution()
Asserts a valid state for execution,
otherwise throws an
ND4JIllegalStateException |
static DynamicCustomOp.DynamicCustomOpsBuilder |
builder(String opName)
This method takes custom opname, and return Op DynamicCustomOpsBuilder instance
|
List<int[]> |
calculateOutputShape()
Calculate
the output shape for this op
|
List<SDVariable> |
doDiff(List<SDVariable> f1)
The actual implementation for automatic differentiation.
|
CustomOpDescriptor |
getDescriptor()
Get the custom op descriptor if one is available.
|
Integer |
getIArgument(int index) |
INDArray |
getInputArgument(int index) |
INDArray |
getOutputArgument(int index) |
Double |
getTArgument(int index) |
int[] |
iArgs() |
void |
initFromOnnx(OnnxProto3.NodeProto node,
SameDiff initWith,
Map<String,OnnxProto3.AttributeProto> attributesForNode,
OnnxProto3.GraphProto graph)
Iniitialize the function from the given
OnnxProto3.NodeProto |
void |
initFromTensorFlow(NodeDef nodeDef,
SameDiff initWith,
Map<String,AttrValue> attributesForNode,
GraphDef graph)
Initialize the function from the given
NodeDef |
INDArray[] |
inputArguments() |
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
|
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 |
populateInputsAndOutputsFromSameDiff()
Attempt to populate inputs and outputs from samediff.
|
void |
removeIArgument(Integer arg) |
void |
removeInputArgument(INDArray arg) |
void |
removeOutputArgument(INDArray arg) |
void |
removeTArgument(Double arg) |
static DynamicCustomOp.SameDiffBuilder |
sameDiffBuilder(String opName,
SameDiff sameDiff) |
void |
setInputArgument(int index,
INDArray input) |
void |
setOutputArgument(int index,
INDArray output) |
double[] |
tArgs() |
String |
tensorflowName()
The opName of this function tensorflow
|
String |
toString() |
void |
updateInputsFromSameDiff() |
arg, args, attributeAdaptersForFunction, configFieldName, diff, dup, equals, f, getValue, hashCode, hasPlaceHolderInputs, isConfigProperties, larg, mappingsForFunction, onnxNames, propertiesForFunction, rarg, resolvePropertiesFromSameDiffBeforeExecution, setInstanceId, setValueFor, tensorflowNamesclone, finalize, getClass, notify, notifyAll, wait, wait, waitisInplaceCallprotected boolean inplaceCall
protected SDVariable[] outputVariables
public DynamicCustomOp()
public DynamicCustomOp(String opName, SameDiff sameDiff, SDVariable[] args)
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(String opName, INDArray[] inputs, INDArray[] outputs)
opName - the operation opName to use
for invocationinputs - the inputsoutputs - the outputs of the oppublic 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 notprotected DynamicCustomOp(String opName)
public String opName()
opName in interface CustomOpopName in class DifferentialFunctionpublic SDVariable[] outputVariables()
DifferentialFunctionoutputVariables in class DifferentialFunctionpublic SDVariable[] outputVariables(String baseName)
DifferentialFunctionoutputVariables in class DifferentialFunctionpublic long opHash()
public INDArray[] outputArguments()
outputArguments in interface CustomOppublic INDArray[] inputArguments()
inputArguments in interface CustomOppublic void addIArgument(int... arg)
addIArgument in interface CustomOppublic void removeIArgument(Integer arg)
removeIArgument in interface CustomOppublic Integer getIArgument(int index)
getIArgument in interface CustomOppublic int numIArguments()
numIArguments in interface CustomOppublic void addTArgument(double... arg)
addTArgument in interface CustomOppublic void removeTArgument(Double arg)
removeTArgument in interface CustomOppublic Double getTArgument(int index)
getTArgument in interface CustomOppublic int numTArguments()
numTArguments in interface CustomOppublic void addInputArgument(INDArray... arg)
addInputArgument in interface CustomOppublic void removeInputArgument(INDArray arg)
removeInputArgument in interface CustomOppublic INDArray getInputArgument(int index)
getInputArgument in interface CustomOppublic void setInputArgument(int index,
INDArray input)
public void setOutputArgument(int index,
INDArray output)
public int numInputArguments()
numInputArguments in interface CustomOppublic void addOutputArgument(INDArray... arg)
addOutputArgument in interface CustomOppublic void removeOutputArgument(INDArray arg)
removeOutputArgument in interface CustomOppublic INDArray getOutputArgument(int index)
getOutputArgument in interface CustomOppublic int numOutputArguments()
numOutputArguments in interface CustomOppublic int opNum()
DifferentialFunctionOp)opNum in class DifferentialFunctionpublic static DynamicCustomOp.DynamicCustomOpsBuilder builder(String opName)
opName - public List<int[]> calculateOutputShape()
DifferentialFunctioncalculateOutputShape in interface CustomOpcalculateOutputShape in class DifferentialFunctionpublic CustomOpDescriptor getDescriptor()
CustomOpgetDescriptor in interface CustomOppublic void assertValidForExecution()
CustomOpND4JIllegalStateExceptionassertValidForExecution in interface CustomOppublic void updateInputsFromSameDiff()
public void populateInputsAndOutputsFromSameDiff()
CustomOppopulateInputsAndOutputsFromSameDiff in interface CustomOppublic FunctionProperties asProperties()
asProperties in class DifferentialFunctionpublic List<SDVariable> doDiff(List<SDVariable> f1)
DifferentialFunctiondoDiff in class DifferentialFunctionpublic String onnxName()
DifferentialFunctiononnxName in class DifferentialFunctionpublic String tensorflowName()
DifferentialFunctiontensorflowName in class DifferentialFunctionpublic Op.Type opType()
DifferentialFunctionopType in class DifferentialFunctionpublic void initFromTensorFlow(NodeDef nodeDef, SameDiff initWith, Map<String,AttrValue> attributesForNode, GraphDef graph)
DifferentialFunctionNodeDefinitFromTensorFlow in class DifferentialFunctionpublic void initFromOnnx(OnnxProto3.NodeProto node, SameDiff initWith, Map<String,OnnxProto3.AttributeProto> attributesForNode, OnnxProto3.GraphProto graph)
DifferentialFunctionOnnxProto3.NodeProtoinitFromOnnx in class DifferentialFunctionpublic static DynamicCustomOp.SameDiffBuilder sameDiffBuilder(String opName, SameDiff sameDiff)
Copyright © 2018. All rights reserved.