Class SubGraphPredicate
- java.lang.Object
-
- org.nd4j.autodiff.samediff.transform.OpPredicate
-
- org.nd4j.autodiff.samediff.transform.SubGraphPredicate
-
public class SubGraphPredicate extends OpPredicate
-
-
Field Summary
Fields Modifier and Type Field Description protected Integer
inputCount
protected Map<Integer,OpPredicate>
opInputMatchPredicates
protected Map<Integer,OpPredicate>
opInputSubgraphPredicates
protected Integer
outputCount
protected OpPredicate
root
-
Constructor Summary
Constructors Modifier Constructor Description protected
SubGraphPredicate(OpPredicate root)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SubGraph
getSubGraph(SameDiff sd, DifferentialFunction rootFn)
Get the SubGraph that matches the predicateboolean
matches(SameDiff sameDiff, DifferentialFunction rootFn)
Determine if the subgraph, starting with the root function, matches the predicateSubGraphPredicate
withInputCount(int inputCount)
Modify the current subgraph to match only if the function has the specified number of inputsSubGraphPredicate
withInputMatching(int inputNum, @NonNull OpPredicate opPredicate)
Require the subgraph to match the specified predicate for the specified input.
Note that this does NOT add the specified input to part of the subgraph
i.e., the subgraph matches if the input matches the predicate, but when returning the SubGraph itself, the function for this input is not added to the SubGraphSubGraphPredicate
withInputSubgraph(int inputNum, @NonNull OpPredicate opPredicate)
Require the subgraph to match the specified predicate for the specified input.
Note that this DOES add the specified input to part of the subgraph
i.e., the subgraph matches if the input matches the predicate, and when returning the SubGraph itself, the function for this input IS added to the SubGraphSubGraphPredicate
withOutputCount(int outputCount)
Modify the current subgraph to match only if the function has the specified number of outputsstatic SubGraphPredicate
withRoot(@NonNull OpPredicate root)
Create a SubGraphPredicate with the specified root predicate-
Methods inherited from class org.nd4j.autodiff.samediff.transform.OpPredicate
classEquals, nameEquals, nameMatches, opNameEquals, opNameMatches
-
-
-
-
Field Detail
-
root
protected final OpPredicate root
-
inputCount
protected Integer inputCount
-
outputCount
protected Integer outputCount
-
opInputMatchPredicates
protected Map<Integer,OpPredicate> opInputMatchPredicates
-
opInputSubgraphPredicates
protected Map<Integer,OpPredicate> opInputSubgraphPredicates
-
-
Constructor Detail
-
SubGraphPredicate
protected SubGraphPredicate(OpPredicate root)
-
-
Method Detail
-
matches
public boolean matches(SameDiff sameDiff, DifferentialFunction rootFn)
Determine if the subgraph, starting with the root function, matches the predicate- Specified by:
matches
in classOpPredicate
- Parameters:
sameDiff
- SameDiff instance the function belongs torootFn
- Function that defines the root of the subgraph- Returns:
- True if the subgraph mathes the predicate
-
getSubGraph
public SubGraph getSubGraph(SameDiff sd, DifferentialFunction rootFn)
Get the SubGraph that matches the predicate- Parameters:
sd
- SameDiff instance the function belongs torootFn
- Function that defines the root of the subgraph- Returns:
- The subgraph that matches the predicate
-
withRoot
public static SubGraphPredicate withRoot(@NonNull @NonNull OpPredicate root)
Create a SubGraphPredicate with the specified root predicate- Parameters:
root
- Predicate for matching the root
-
withInputCount
public SubGraphPredicate withInputCount(int inputCount)
Modify the current subgraph to match only if the function has the specified number of inputs- Parameters:
inputCount
- Match only if the function has the specified number of inputs
-
withOutputCount
public SubGraphPredicate withOutputCount(int outputCount)
Modify the current subgraph to match only if the function has the specified number of outputs- Parameters:
outputCount
- Match only if the function has the specified number of outputs
-
withInputMatching
public SubGraphPredicate withInputMatching(int inputNum, @NonNull @NonNull OpPredicate opPredicate)
Require the subgraph to match the specified predicate for the specified input.
Note that this does NOT add the specified input to part of the subgraph
i.e., the subgraph matches if the input matches the predicate, but when returning the SubGraph itself, the function for this input is not added to the SubGraph- Parameters:
inputNum
- Input numberopPredicate
- Predicate that the input must match- Returns:
- This predicate with the additional requirement added
-
withInputSubgraph
public SubGraphPredicate withInputSubgraph(int inputNum, @NonNull @NonNull OpPredicate opPredicate)
Require the subgraph to match the specified predicate for the specified input.
Note that this DOES add the specified input to part of the subgraph
i.e., the subgraph matches if the input matches the predicate, and when returning the SubGraph itself, the function for this input IS added to the SubGraph- Parameters:
inputNum
- Input numberopPredicate
- Predicate that the input must match- Returns:
- This predicate with the additional requirement added
-
-