Class SubGraphPredicate

    • 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 class OpPredicate
        Parameters:
        sameDiff - SameDiff instance the function belongs to
        rootFn - 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 to
        rootFn - 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 number
        opPredicate - 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 number
        opPredicate - Predicate that the input must match
        Returns:
        This predicate with the additional requirement added