Using FullyConnected operator in place of linalg_gemm to perform same operation
502159
def _fix_gemm(op_name, inputs, old_attr, proto_obj):
    """"""
    op_sym = getattr(symbol, op_name, None)
    alpha = float(old_attr.get('alpha', 1.0))
    beta = float(old_attr.get('beta', 1.0))
    trans_a = int(old_attr.get('transA', 0))
    trans_b = int(old_attr.get('transB', 0))
    if trans_a:
        inputs[0] = symbol.transpose(inputs[0], axes=(1, 0))
    if not trans_b:
        inputs[1] = symbol.transpose(inputs[1], axes=(1, 0))
    new_inputs = [alpha*inputs[0], inputs[1], beta*inputs[2]]
    new_attr = {'num_hidden' : proto_obj._params[inputs[2].name].shape[0]}
    return op_sym, new_attr, new_inputs
568030
def _gtu32(ins):
    
    op1, op2 = tuple(ins.quad[2:])
    rev = op1[0] != 't' and not is_int(op1) and op2[0] == 't'
    output = _32bit_oper(op1, op2, rev)
    output.append('pop bc')
    output.append('or a')
    output.append('sbc hl, bc')
    output.append('ex de, hl')
    output.append('pop de')
    output.append('sbc hl, de')
    output.append('sbc a, a')
    output.append('push af')
    return output
750850
def gru(num_hidden, indata, prev_state, param, seqidx, layeridx, dropout=0., is_batchnorm=False, gamma=None, beta=None, name=None):
    
    if dropout > 0.:
        indata = mx.sym.Dropout(data=indata, p=dropout)
    i2h = mx.sym.FullyConnected(data=indata,
                                weight=param.gates_i2h_weight,
                                bias=param.gates_i2h_bias,
                                num_hidden=num_hidden * 2,
                                name="t%d_l%d_gates_i2h" % (seqidx, layeridx))

    if is_batchnorm:
        if name is not None:
            i2h = batchnorm(net=i2h, gamma=gamma, beta=beta, name="%s_batchnorm" % name)
        else:
            i2h = batchnorm(net=i2h, gamma=gamma, beta=beta)
    h2h = mx.sym.FullyConnected(data=prev_state.h,
                                weight=param.gates_h2h_weight,
                                bias=param.gates_h2h_bias,
                                num_hidden=num_hidden * 2,
                                name="t%d_l%d_gates_h2h" % (seqidx, layeridx))
    gates = i2h + h2h
    slice_gates = mx.sym.SliceChannel(gates, num_outputs=2,
                                      name="t%d_l%d_slice" % (seqidx, layeridx))
    update_gate = mx.sym.Activation(slice_gates[0], act_type="sigmoid")
    reset_gate = mx.sym.Activation(slice_gates[1], act_type="sigmoid")
    # The transform part of GRU is a little magic
    htrans_i2h = mx.sym.FullyConnected(data=indata,
                                       weight=param.trans_i2h_weight,
                                       bias=param.trans_i2h_bias,
                                       num_hidden=num_hidden,
                                       name="t%d_l%d_trans_i2h" % (seqidx, layeridx))
    h_after_reset = prev_state.h * reset_gate
    htrans_h2h = mx.sym.FullyConnected(data=h_after_reset,
                                       weight=param.trans_h2h_weight,
                                       bias=param.trans_h2h_bias,
                                       num_hidden=num_hidden,
                                       name="t%d_l%d_trans_h2h" % (seqidx, layeridx))
    h_trans = htrans_i2h + htrans_h2h
    h_trans_active = mx.sym.Activation(h_trans, act_type="tanh")
    next_h = prev_state.h + update_gate * (h_trans_active - prev_state.h)
    return GRUState(h=next_h)
875025
def _setLogicalOperator(self, lop):
		""""""

		if not lop.lower() in ['and', 'or']:
			raise FMError, 'Unsupported logical operator (not one of "and" or "or").'

		self._lop = lop.lower()
597926
def _addf(ins):
    ''' 
    '''
    op1, op2 = tuple(ins.quad[2:])

    if _f_ops(op1, op2) is not None:
        opa, opb = _f_ops(op1, op2)
        if opb == 0:  # A + 0 => A
            output = _float_oper(opa)
            output.extend(_fpush())
            return output

    output = _float_oper(op1, op2)
    output.append('call __ADDF')
    output.extend(_fpush())
    REQUIRES.add('addf.asm')
    return output
283486
def apply_operator_overloading():
    
    # operator overloading is (unfortunately) not working for the following
    # cases:
    # int, float, str - should return appropriate type instead of a Publisher
    # len - should return an integer
    # "x in y" - is using __bool__ which is not working with Publisher
    for method in (
            '__lt__', '__le__', '__eq__', '__ne__', '__ge__', '__gt__',
            '__add__', '__and__', '__lshift__', '__mod__', '__mul__',
            '__pow__', '__rshift__', '__sub__', '__xor__', '__concat__',
            '__getitem__', '__floordiv__', '__truediv__'):
        def _op(operand_left, operand_right, operation=method):
            if isinstance(operand_right, Publisher):
                return CombineLatest(operand_left, operand_right,
                                     map_=getattr(operator, operation))
            return _MapConstant(operand_left, operand_right,
                                getattr(operator, operation))

        setattr(Publisher, method, _op)

    for method, _method in (
            ('__radd__', '__add__'), ('__rand__', '__and__'),
            ('__rlshift__', '__lshift__'), ('__rmod__', '__mod__'),
            ('__rmul__', '__mul__'), ('__rpow__', '__pow__'),
            ('__rrshift__', '__rshift__'), ('__rsub__', '__sub__'),
            ('__rxor__', '__xor__'), ('__rfloordiv__', '__floordiv__'),
            ('__rtruediv__', '__truediv__')):
        def _op(operand_left, operand_right, operation=_method):
            return _MapConstantReverse(operand_left, operand_right,
                                       getattr(operator, operation))

        setattr(Publisher, method, _op)

    for method, _method in (
            ('__neg__', operator.neg), ('__pos__', operator.pos),
            ('__abs__', operator.abs), ('__invert__', operator.invert),
            ('__round__', round), ('__trunc__', math.trunc),
            ('__floor__', math.floor), ('__ceil__', math.ceil)):
        def _op_unary(operand, operation=_method):
            return _MapUnary(operand, operation)

        setattr(Publisher, method, _op_unary)

    def _getattr(publisher, attribute_name):
        if not publisher.inherited_type or \
           not hasattr(publisher.inherited_type, attribute_name):
            raise AttributeError('Attribute %r not found' % attribute_name)
        return _GetAttr(publisher, attribute_name)

    setattr(Publisher, '__getattr__', _getattr)
1230187
def _call(self, x, out=None):
        """"""
        if out is None:
            out = self.range.element()

        # TODO: this pipes CUDA arrays through NumPy. Write native operator.
        with writable_array(out) as out_arr:
            finite_diff(x.asarray(), axis=self.axis, dx=self.dx,
                        method=self.method, pad_mode=self.pad_mode,
                        pad_const=self.pad_const, out=out_arr)
        return out
439145
def binary_operation_logical(self, rule, left, right, **kwargs):
        
        return LogicalBinOpRule(rule.operation, left, right)
1215042
def fixup_simple_stmt(parent, i, stmt_node):
    
    for semi_ind, node in enumerate(stmt_node.children):
        if node.type == token.SEMI: # *sigh*
            break
    else:
        return

    node.remove() # kill the semicolon
    new_expr = Node(syms.expr_stmt, [])
    new_stmt = Node(syms.simple_stmt, [new_expr])
    while stmt_node.children[semi_ind:]:
        move_node = stmt_node.children[semi_ind]
        new_expr.append_child(move_node.clone())
        move_node.remove()
    parent.insert_child(i, new_stmt)
    new_leaf1 = new_stmt.children[0].children[0]
    old_leaf1 = stmt_node.children[0].children[0]
    new_leaf1.prefix = old_leaf1.prefix
570184
def _parity_interaction(q0: ops.Qid,
                        q1: ops.Qid,
                        rads: float,
                        atol: float,
                        gate: Optional[ops.Gate] = None):
    """"""

    if abs(rads) < atol:
        return

    if gate is not None:
        g = cast(ops.Gate, gate)
        yield g.on(q0), g.on(q1)

    yield MS(-1 * rads).on(q0, q1)

    if gate is not None:
        g = protocols.inverse(gate)
        yield g.on(q0), g.on(q1)
224513
def level=(lev)
      SysLogger.level = SimpleLogger::CONSTANT_TO_SYMBOL[lev] if Logger.syslog
      super(lev)
    end
824895
@JRubyMethod(name = "<=>")
    public static IRubyObject cmp(IRubyObject alias1, IRubyObject alias2) {
        IRubyObject str1 = (IRubyObject)((RubyObject)alias1).fastGetInstanceVariable("@name");
        IRubyObject str2 = (IRubyObject)((RubyObject)alias2).fastGetInstanceVariable("@name");
        return str1.callMethod(alias1.getRuntime().getCurrentContext(), "<=>", str2);
    }
188653
def _operatorOperands(tokenlist):
        ""
        it = iter(tokenlist)
        while 1:
            try:
                yield (it.next(), it.next())
            except StopIteration:
                break
995632
def fully_connected(attrs, inputs, proto_obj):
    """"""
    new_attrs = translation_utils._remove_attributes(attrs, ['axis'])

    new_attrs = translation_utils._fix_bias('FullyConnected', new_attrs, len(inputs))

    new_attrs = translation_utils._fix_channels('FullyConnected', new_attrs, inputs, proto_obj)

    return 'FullyConnected', new_attrs, inputs
52045
def _mine_get(self, load, skip_verify=False):
        '''
        
        '''
        if not skip_verify:
            if any(key not in load for key in ('id', 'tgt', 'fun')):
                return {}

        if isinstance(load['fun'], six.string_types):
            functions = list(set(load['fun'].split(',')))
            _ret_dict = len(functions) > 1
        elif isinstance(load['fun'], list):
            functions = load['fun']
            _ret_dict = True
        else:
            return {}

        functions_allowed = []

        if 'mine_get' in self.opts:
            # If master side acl defined.
            if not isinstance(self.opts['mine_get'], dict):
                return {}
            perms = set()
            for match in self.opts['mine_get']:
                if re.match(match, load['id']):
                    if isinstance(self.opts['mine_get'][match], list):
                        perms.update(self.opts['mine_get'][match])

            for fun in functions:
                if any(re.match(perm, fun) for perm in perms):
                    functions_allowed.append(fun)

            if not functions_allowed:
                return {}
        else:
            functions_allowed = functions

        ret = {}
        if not salt.utils.verify.valid_id(self.opts, load['id']):
            return ret
        expr_form = load.get('expr_form')
        if expr_form is not None and 'tgt_type' not in load:
            salt.utils.versions.warn_until(
                'Neon',
                '_mine_get: minion {0} uses pre-Nitrogen API key '
                '"expr_form". Accepting for backwards compatibility '
                'but this is not guaranteed '
                'after the Neon release'.format(load['id'])
            )
            match_type = expr_form
        else:
            match_type = load.get('tgt_type', 'glob')
        if match_type.lower() == 'pillar':
            match_type = 'pillar_exact'
        if match_type.lower() == 'compound':
            match_type = 'compound_pillar_exact'
        checker = salt.utils.minions.CkMinions(self.opts)
        _res = checker.check_minions(
                load['tgt'],
                match_type,
                greedy=False
                )
        minions = _res['minions']
        for minion in minions:
            fdata = self.cache.fetch('minions/{0}'.format(minion), 'mine')

            if not isinstance(fdata, dict):
                continue

            if not _ret_dict and functions_allowed and functions_allowed[0] in fdata:
                ret[minion] = fdata.get(functions_allowed[0])
            elif _ret_dict:
                for fun in list(set(functions_allowed) & set(fdata.keys())):
                    ret.setdefault(fun, {})[minion] = fdata.get(fun)

        return ret
98077
def _ge_from_lt(self, other):
    """"""
    op_result = self.__lt__(other)
    if op_result is NotImplemented:
        return NotImplemented
    return not op_result
1169459
def _complete_type_chain(self, symbol, fullsymbol):
        """"""
        target, targmod = self._get_chain_parent_symbol(symbol, fullsymbol)
        if target is None:
            return {}

        result = {}
        #We might know what kind of symbol to limit the completion by depending on whether
        #it was preceded by a "call " for example. Check the context's el_call
        if symbol != "":
            if self.context.el_call != "sub":
                for mkey in target.members:
                    if self._symbol_in(symbol, mkey):
                        result[mkey] = target.members[mkey]

            for ekey in target.executables:
                if (self._symbol_in(symbol, ekey)):
                    if self.context.el_call == "sub":
                        if (isinstance(target.executables[ekey], Subroutine)):
                            result[ekey] = target.executables[ekey]
                    else:
                        if (isinstance(target.executables[ekey], Function)):
                            result[ekey] = target.executables[ekey]
        else:
            if self.context.el_call != "sub":
                result.update(target.members)
                subdict = {k: target.executables[k] for k in target.executables
                           if isinstance(target.executables[k].target, Function)}
                result.update(subdict)
            else:
                subdict = {k: target.executables[k] for k in target.executables
                           if isinstance(target.executables[k].target, Subroutine)}
                result.update(subdict)

        return result