def f(local_opt): name = (kwargs and kwargs.pop('name')) or local_opt.__name__ optdb.register( name, TopoOptimizer(local_opt, failure_callback=TopoOptimizer.warn_inplace), 60, 'fast_run', 'inplace', *tags) return local_opt
def f(local_opt): name = (kwargs and kwargs.pop("name")) or local_opt.__name__ optdb.register( name, TopoOptimizer(local_opt, failure_callback=TopoOptimizer.warn_inplace), 60, "fast_run", "inplace", "gpuarray", *tags, ) return local_opt
def OpSubOptimizer(op1, op2, fail=NavigatorOptimizer.warn_ignore, ign=True): return TopoOptimizer(OpSub(op1, op2), ignore_newtrees=ign, failure_callback=fail)
out_tmp_padded = tensor.zeros(dtype=out_tmp.dtype, shape=(Ns, Ts + 2 * Tpad, Nf, Tf, Hout, Wout)) out_tmp_padded = tensor.set_subtensor( out_tmp_padded[:, Tpad:(Ts + Tpad), :, :, :, :], out_tmp) out_5d = diagonal_subtensor(out_tmp_padded, 1, 3).sum(axis=3) return out_5d @theano.gof.local_optimizer([DiagonalSubtensor, IncDiagonalSubtensor]) def local_inplace_DiagonalSubtensor(fgraph, node): """Also work for IncDiagonalSubtensor.""" if (isinstance(node.op, (DiagonalSubtensor, IncDiagonalSubtensor)) and not node.op.inplace): new_op = node.op.__class__(inplace=True) new_node = new_op(*node.inputs) copy_stack_trace(node.outputs[0], new_node) return [new_node] return False theano.compile.optdb.register( "local_inplace_DiagonalSubtensor", TopoOptimizer(local_inplace_DiagonalSubtensor, failure_callback=TopoOptimizer.warn_inplace), 60, "fast_run", "inplace", )
def TopoPatternOptimizer(p1, p2, ign=True): return TopoOptimizer(PatternSub(p1, p2), ignore_newtrees=ign)