Module ImportFrom alias Import alias ImportFrom alias identifier alias ImportFrom alias ImportFrom alias alias alias ImportFrom alias alias alias ImportFrom alias alias Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Num keyword Str FunctionDef arguments args NameParam NameParam defaults body Expr Str If CompareIsNot AttributeLoad NameLoad attr NameLoad body Assign NameStore AttributeLoad NameLoad attr If BoolOpAnd Call NameLoad AttributeLoad NameLoad attr TupleLoad NameLoad NameLoad CompareEq AttributeLoad AttributeLoad NameLoad attr attr BinOpMult TupleLoad Str NameLoad body Return Call NameLoad SubscriptLoad AttributeLoad NameLoad attr Index Num AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index Num attr orelse If Call NameLoad AttributeLoad NameLoad attr TupleLoad NameLoad NameLoad body Return Call NameLoad SubscriptLoad AttributeLoad NameLoad attr Index Num NameLoad orelse Return NameLoad orelse If BoolOpAnd Call NameLoad NameLoad NameLoad CompareEq AttributeLoad NameLoad attr BinOpMult TupleLoad NameLoad NameLoad body Return Call AttributeLoad NameLoad attr TupleLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str If BoolOpAnd CompareIsNot AttributeLoad NameLoad attr NameLoad BoolOpOr NameLoad CompareEq Call NameLoad AttributeLoad NameLoad attr Num body If Call NameLoad AttributeLoad AttributeLoad NameLoad attr attr NameLoad body Return AttributeLoad NameLoad attr orelse If BoolOpAnd Call NameLoad AttributeLoad AttributeLoad NameLoad attr attr NameLoad CompareIsNot AttributeLoad SubscriptLoad AttributeLoad AttributeLoad NameLoad attr attr Index Num attr NameLoad BoolOpOr NameLoad CompareEq Call NameLoad AttributeLoad SubscriptLoad AttributeLoad AttributeLoad NameLoad attr attr Index Num attr Num Call NameLoad AttributeLoad AttributeLoad SubscriptLoad AttributeLoad AttributeLoad NameLoad attr attr Index Num attr attr NameLoad body Return Call NameLoad SubscriptLoad AttributeLoad AttributeLoad SubscriptLoad AttributeLoad AttributeLoad NameLoad attr attr Index Num attr attr Index Num NameLoad orelse Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str TryExcept body Assign NameStore Call NameLoad NameLoad Return CompareEq NameLoad NameLoad handlers ExceptHandler type NameLoad body Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str FunctionDef arguments args NameParam defaults body FunctionDef arguments args NameParam defaults body If BoolOpAnd Call NameLoad AttributeLoad NameLoad attr NameLoad CompareEq AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr CompareEq AttributeLoad NameLoad attr Num body Assign NameStore Call NameLoad SubscriptLoad AttributeLoad NameLoad attr Index Num NameLoad If CompareIs NameLoad NameLoad body Assign NameStore Call NameLoad SubscriptLoad AttributeLoad NameLoad attr Index Num NameLoad If CompareIs NameLoad NameLoad body Return Assign NameStore Call NameLoad SubscriptLoad AttributeLoad NameLoad attr Index Num keyword AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index Num attr orelse Assign NameStore Call NameLoad SubscriptLoad AttributeLoad NameLoad attr Index Num keyword AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index Num attr If BoolOpOr CompareIs NameLoad NameLoad CompareNotEq AttributeLoad NameLoad attr AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index Num attr body Return NameLoad Assign NameStore Call NameLoad AttributeLoad NameLoad attr TryExcept body Assign NameStore Call NameLoad NameLoad If CompareEq NameLoad Num body Assign SubscriptStore NameLoad Index NameLoad NameLoad Assign SubscriptStore NameLoad Index NameLoad NameLoad orelse If CompareEq NameLoad Num body Assign SubscriptStore NameLoad Index NameLoad SubscriptLoad AttributeLoad NameLoad attr Index NameLoad Assign SubscriptStore NameLoad Index NameLoad SubscriptLoad AttributeLoad NameLoad attr Index NameLoad orelse Assign SubscriptStore NameLoad Index NameLoad BinOpMult NameLoad SubscriptLoad AttributeLoad NameLoad attr Index NameLoad Assign SubscriptStore NameLoad Index NameLoad BinOpMult NameLoad SubscriptLoad AttributeLoad NameLoad attr Index NameLoad handlers ExceptHandler type NameLoad body Assign SubscriptStore NameLoad Index NameLoad BinOpMult NameLoad SubscriptLoad AttributeLoad NameLoad attr Index NameLoad Assign SubscriptStore NameLoad Index NameLoad BinOpMult NameLoad SubscriptLoad AttributeLoad NameLoad attr Index NameLoad Return Call NameLoad NameLoad NameLoad decorator_list Call NameLoad ListLoad NameLoad Call NameLoad NameLoad Return NameLoad decorator_list Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str FunctionDef arguments args NameParam defaults body FunctionDef arguments args NameParam defaults body If BoolOpAnd Call NameLoad AttributeLoad NameLoad attr NameLoad CompareEq AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr CompareEq AttributeLoad NameLoad attr Num body Assign NameStore Call NameLoad SubscriptLoad AttributeLoad NameLoad attr Index Num NameLoad Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index Num If CompareIs NameLoad NameLoad body Assign NameStore Call NameLoad SubscriptLoad AttributeLoad NameLoad attr Index Num NameLoad Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index Num If CompareIs NameLoad NameLoad body Return NameLoad If CompareNotEq AttributeLoad NameLoad attr AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index Num attr body Return NameLoad If UnaryOpNot Call NameLoad SubscriptLoad AttributeLoad NameLoad attr Index NameLoad Num body Return NameLoad If CompareNotEq AttributeLoad NameLoad attr AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index NameLoad attr body Return NameLoad Assign NameStore Call NameLoad AttributeLoad NameLoad attr Assign SubscriptStore NameLoad Index NameLoad NameLoad Assign SubscriptStore NameLoad Index NameLoad Call AttributeLoad NameLoad attr Return Call NameLoad NameLoad NameLoad decorator_list Call NameLoad ListLoad NameLoad Call NameLoad NameLoad Return NameLoad decorator_list Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str FunctionDef arguments args NameParam defaults body FunctionDef arguments args NameParam defaults body If BoolOpOr CompareNotEq Call NameLoad AttributeLoad NameLoad attr NameLoad AttributeLoad AttributeLoad NameLoad attr attr body Return Assign NameStore Call NameLoad AttributeLoad NameLoad attr Assign NameStore SubscriptLoad NameLoad Index NameLoad If BoolOpAnd AttributeLoad NameLoad attr Call NameLoad AttributeLoad AttributeLoad NameLoad attr attr NameLoad CompareGt Call NameLoad AttributeLoad NameLoad attr Num body Assign NameStore Call NameLoad AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr Assign SubscriptStore NameLoad Index NameLoad Call NameLoad AttributeLoad AttributeLoad NameLoad attr attr Return Call NameLoad NameLoad NameLoad decorator_list Call NameLoad ListLoad NameLoad keyword NameLoad Call NameLoad NameLoad Return NameLoad decorator_list Return NameLoad decorator_list
N/A functools wraps N/A numpy theano scalar scal Constant theano.gof local_optimizer theano.tensor DimShuffle get_scalar_constant_value NotScalarConstantError basic_ops GpuFromHost HostFromGpu GpuAllocEmpty elemwise GpuDimShuffle GpuElemwise N/A _one N/A N/A scal constant N/A N/A numpy asarray 1.0 dtype float64 grab_cpu_scalar N/A N/A v nd N/A N/A N/A 
    Get a scalar variable value from the tree at `v`.

    This function will dig through transfers and dimshuffles to get
    the constant value. If no such constant is found, it returns None.

    Parameters
    ----------
    v
        Theano variable to extract the constant value from.
    nd : int
        Expected number of dimensions for the variable (for
        broadcasted constants).

     N/A N/A N/A v owner None N/A N/A n N/A v owner N/A N/A N/A isinstance N/A n op N/A GpuDimShuffle DimShuffle N/A N/A N/A n op new_order N/A N/A x nd N/A N/A N/A grab_cpu_scalar N/A N/A n inputs N/A 0 N/A N/A N/A n inputs N/A 0 ndim N/A N/A N/A isinstance N/A n op N/A GpuFromHost HostFromGpu N/A N/A N/A grab_cpu_scalar N/A N/A n inputs N/A 0 nd N/A N/A None N/A N/A N/A N/A isinstance v Constant N/A N/A v broadcastable N/A N/A True nd N/A N/A N/A N/A v dimshuffle N/A N/A find_node N/A N/A v cls ignore_clients N/A False N/A N/A 
    Find the node that has an op of of type `cls` in `v`.

    This digs through possibly redundant transfers to for the node
    that has the type `cls`. If `ignore_clients` is False (the
    default) it will only dig through nodes that have a single client
    to avoid duplicating computations.

    Parameters
    ----------
    v
        The variable to dig through
    cls : Op class
        The type of the node we are looking for
    ignore_clients : bool, optional
        Whether to ignore multiple clients or not.

     N/A N/A N/A N/A v owner None N/A ignore_clients N/A N/A len N/A v clients 1 N/A N/A N/A isinstance N/A N/A v owner op cls N/A N/A N/A v owner N/A N/A N/A N/A isinstance N/A N/A v owner op GpuFromHost N/A N/A N/A N/A N/A v owner inputs N/A 0 owner None N/A ignore_clients N/A N/A len N/A N/A N/A N/A v owner inputs N/A 0 clients 1 N/A isinstance N/A N/A N/A N/A N/A v owner inputs N/A 0 owner op HostFromGpu N/A N/A N/A find_node N/A N/A N/A N/A N/A N/A v owner inputs N/A 0 owner inputs N/A 0 cls N/A N/A None N/A is_equal N/A N/A var val N/A N/A N/A 
    Returns True if `var` is always equal to `val`.

    This will only return True if the variable will always be equal to
    the value.  If it might not be true in some cases then it returns False.

    Parameters
    ----------
    var
        Variable to compare
    val
        Python value

     N/A N/A N/A v N/A get_scalar_constant_value var N/A N/A v val N/A N/A N/A NotScalarConstantError N/A N/A False N/A alpha_merge N/A N/A cls alpha_in beta_in N/A N/A N/A 
    Decorator to merge multiplication by a scalar on the output.

    This will find a pattern of `scal * <yourop>(some, params, alpha,
    beta)` and update it so that the scalar multiplication happens as
    part of your op.

    The op needs to accept an alpha and a beta scalar which act this way::

       out = Op() * alpha + out_like * beta

    Where out_like is a buffer that has the same size as the output
    and gets added to the "real" output of the operation.  An example
    of an operation that respects this pattern is GEMM from blas.

    The decorated function must have this signature::

        maker(node, *inputs)

    The `node` argument you recieve is the original apply node that
    contains your op.  You should use it to grab relevant properties
    for your op so that the new version performs the same computation.
    The `*inputs` parameters contains the new inputs for your op.  You
    MUST use those inputs instead of the ones on `node`.  Note that
    this function can be as simple as::

        def maker(node, *inputs):
            return node.op(*inputs)

    Parameters
    ----------
    cls : op class
        The class of the op you want to merge
    alpha_in : int
        The input index for the alpha scalar for your op (in node.inputs).
    beta_in : int
        The input index for the beta scalar for your op (in node.inputs).

    Returns
    -------
    local optimizer
        an unregistered local optimizer that has the same name as the
        decorated function.

    Notes
    -----
    This was factored out since the code to deal with intervening
    transfers and correctness in the presence of different values of
    alpha and beta scaling factors is not trivial.

     wrapper N/A N/A maker N/A N/A opt N/A N/A node N/A N/A N/A N/A N/A isinstance N/A node op GpuElemwise N/A N/A N/A node op scalar_op N/A scal mul N/A N/A node nin 2 N/A N/A targ N/A find_node N/A N/A node inputs N/A 0 cls N/A N/A targ None N/A N/A targ N/A find_node N/A N/A node inputs N/A 1 cls N/A N/A targ None N/A N/A N/A lr N/A grab_cpu_scalar N/A N/A node inputs N/A 0 nd N/A N/A N/A targ outputs N/A 0 ndim N/A N/A lr N/A grab_cpu_scalar N/A N/A node inputs N/A 1 nd N/A N/A N/A targ outputs N/A 0 ndim N/A N/A N/A lr None N/A N/A lr dtype N/A N/A N/A targ outputs N/A 0 dtype N/A N/A None N/A inputs N/A list N/A targ inputs N/A N/A N/A c N/A get_scalar_constant_value lr N/A N/A c 0 N/A N/A N/A inputs N/A alpha_in lr N/A N/A inputs N/A beta_in lr N/A N/A N/A c 1 N/A N/A N/A inputs N/A alpha_in N/A N/A targ inputs N/A alpha_in N/A N/A inputs N/A beta_in N/A N/A targ inputs N/A beta_in N/A N/A N/A inputs N/A alpha_in N/A lr N/A N/A targ inputs N/A alpha_in N/A N/A inputs N/A beta_in N/A lr N/A N/A targ inputs N/A beta_in N/A N/A N/A NotScalarConstantError N/A N/A N/A inputs N/A alpha_in N/A lr N/A N/A targ inputs N/A alpha_in N/A N/A inputs N/A beta_in N/A lr N/A N/A targ inputs N/A beta_in N/A N/A maker targ inputs N/A N/A local_optimizer N/A GpuElemwise N/A wraps maker N/A opt N/A N/A wrapper N/A output_merge N/A N/A cls alpha_in beta_in out_in N/A N/A N/A 
    Decorator to merge addition by a value on the output.

    This will find a pattern of `val * <yourop>(some, params, alpha,
    beta, out_like)` and update it so that the addtition happens as
    part of your op.

    The op needs to accept an alpha and a beta scalar which act this way::

       out = Op() * alpha + out_like * beta

    Where out_like is a buffer that has the same size as the output
    and gets added to the "real" output of the operation.  An example
    of an operation that respects this pattern is GEMM from blas.

    The decorated function must have this signature::

        maker(node, *inputs)

    The `node` argument you recieve is the original apply node that
    contains your op.  You should use it to grab relevant properties
    for your op so that the new version performs the same computation.
    The `*inputs` parameters contains the new inputs for your op.  You
    MUST use those inputs instead of the ones on `node`.  Note that
    this function can be as simple as::

        def maker(node, *inputs):
            return node.op(*inputs)

    Parameters
    ----------
    cls : op class
        The class of the op you want to merge
    alpha_in : int
        The input index for the alpha scalar for your op (in node.inputs).
    beta_in : int
        The input index for the beta scalar for your op (in node.inputs).
    out_in : int
        The input index for the out_like input for your op (in node.inputs).

    Returns
    -------
    local optimizer
        an unregistered local optimizer that has the same name as the
        decorated function.

    Notes
    -----
    This was factored out since the code to deal with intervening
    transfers and correctness in the presence of different values of
    alpha and beta scaling factors is not trivial.

    This also correctly handles the case where the added value is
    broadcasted (by not performing the replacement).

     wrapper N/A N/A maker N/A N/A opt N/A N/A node N/A N/A N/A N/A N/A isinstance N/A node op GpuElemwise N/A N/A N/A node op scalar_op N/A scal add N/A N/A node nin 2 N/A N/A targ N/A find_node N/A N/A node inputs N/A 0 cls N/A W N/A N/A node inputs N/A 1 N/A N/A targ None N/A N/A targ N/A find_node N/A N/A node inputs N/A 1 cls N/A W N/A N/A node inputs N/A 0 N/A N/A targ None N/A N/A None N/A N/A N/A W dtype N/A N/A N/A targ outputs N/A 0 dtype N/A N/A None N/A N/A N/A is_equal N/A N/A targ inputs N/A beta_in 0.0 N/A N/A None N/A N/A N/A W broadcastable N/A N/A N/A targ inputs N/A out_in broadcastable N/A N/A None N/A inputs N/A list N/A targ inputs N/A N/A inputs N/A out_in W N/A N/A inputs N/A beta_in N/A N/A _one clone N/A N/A maker targ inputs N/A N/A local_optimizer N/A GpuElemwise N/A wraps maker N/A opt N/A N/A wrapper N/A inplace_allocempty N/A N/A op idx N/A N/A N/A 
    Wrapper to make an inplace optimization that deals with AllocEmpty

    This will duplicate the alloc input if it has more than one client
    to allow the op to work on it inplace.

    The decorated function must have this signature::

        maker(node, inputs)

    The `node` argument you recieve is the original apply node that
    contains your op.  You should use it to grab relevant properties
    for your op so that the new version performs the same computation.
    You should also switch the op to work inplace.  The `*inputs`
    parameters contains the new inputs for your op.  You MUST use
    those inputs instead of the ones on `node`.  Note that this
    function can be as simple as::

        def maker(node, inputs):
            return [node.op.__class__(inplace=True)(*inputs)]

    Parameters
    ----------
    op : op class
        The op class to look for to make inplace
    idx : int
        The index of the (possibly) AllocEmpty input (in node.inputs).

    Returns
    -------
    local optimizer
        an unregistered inplace local optimizer that has the same name
        as the decorated function.

     wrapper N/A N/A maker N/A N/A opt N/A N/A node N/A N/A N/A N/A N/A N/A type N/A node op op N/A N/A node op inplace N/A N/A N/A inputs N/A list N/A node inputs N/A alloc N/A inputs N/A idx N/A N/A N/A alloc owner N/A isinstance N/A N/A alloc owner op GpuAllocEmpty N/A N/A len N/A alloc clients 1 N/A N/A alloc_op N/A GpuAllocEmpty N/A N/A N/A alloc owner op dtype N/A N/A N/A alloc owner op context_name N/A N/A inputs N/A idx N/A alloc_op N/A N/A alloc owner inputs N/A N/A maker node inputs N/A N/A local_optimizer N/A op inplace True N/A wraps maker N/A opt N/A N/A wrapper N/A