@local_optimizer([CGemv(inplace=False)]) def make_c_gemv_destructive(node): if node.op == CGemv(inplace=False): return [CGemv(inplace=True)(*node.inputs)] ####### ####### ####### # Optimizers ####### ####### ####### blas_optdb.register('use_c_blas', EquilibriumOptimizer([ use_c_ger, use_c_gemv, ], max_use_ratio=5), 20, 'fast_run', 'c_blas') #print 'BLAS_OPTDB' #print blas_optdb # this matches the InplaceBlasOpt defined in blas.py optdb.register('c_blas_destructive', EquilibriumOptimizer([ make_c_ger_destructive, make_c_gemv_destructive, ], failure_callback=EquilibriumOptimizer.warn_inplace, max_use_ratio=5), 70.0, 'fast_run', 'inplace', 'c_blas')
rval.outputs = node_output_storage rval.lazy = False return rval @local_optimizer([ger, ger_destructive]) def use_scipy_ger(node): if node.op == ger: return [ScipyGer(False)(*node.inputs)] @local_optimizer([ScipyGer(False)]) def make_ger_destructive(node): if node.op == ScipyGer(False): return [ScipyGer(True)(*node.inputs)] use_scipy_blas = in2out(use_scipy_ger) make_scipy_blas_destructive = in2out(make_ger_destructive) if have_fblas: # scipy_blas is scheduled in the blas_optdb very late, because scipy sortof # sucks, but it is almost always present. # C implementations should be scheduled earlier than this, so that they take # precedence. Once the original Ger is replaced, then these optimizations # have no effect. blas_optdb.register("scipy_blas", use_scipy_blas, 100, "fast_run") # this matches the InplaceBlasOpt defined in blas.py optdb.register("make_scipy_blas_destructive", make_scipy_blas_destructive, 70.0, "fast_run", "inplace")
rval.lazy = False return rval @local_optimizer([ger, ger_destructive]) def use_scipy_ger(node): if node.op == ger: return [ScipyGer(False)(*node.inputs)] @local_optimizer([ScipyGer(False)]) def make_ger_destructive(node): if node.op == ScipyGer(False): return [ScipyGer(True)(*node.inputs)] use_scipy_blas = in2out(use_scipy_ger) make_scipy_blas_destructive = in2out(make_ger_destructive) if have_fblas: # scipy_blas is scheduled in the blas_optdb very late, because scipy sortof # sucks, but it is almost always present. # C implementations should be scheduled earlier than this, so that they take # precedence. Once the original Ger is replaced, then these optimizations # have no effect. blas_optdb.register('scipy_blas', use_scipy_blas, 100, 'fast_run') # this matches the InplaceBlasOpt defined in blas.py optdb.register('make_scipy_blas_destructive', make_scipy_blas_destructive, 70.0, 'fast_run', 'inplace')
@local_optimizer([CGemv(inplace=False)]) def make_c_gemv_destructive(node): if node.op == CGemv(inplace=False): return [CGemv(inplace=True)(*node.inputs)] ####### ####### ####### # Optimizers ####### ####### ####### blas_optdb.register( 'use_c_blas', EquilibriumOptimizer([ use_c_ger, use_c_gemv, ], max_use_ratio=5), 20, 'fast_run', 'c_blas') #print 'BLAS_OPTDB' #print blas_optdb # this matches the InplaceBlasOpt defined in blas.py optdb.register( 'c_blas_destructive', EquilibriumOptimizer([ make_c_ger_destructive, make_c_gemv_destructive, ], failure_callback=EquilibriumOptimizer.warn_inplace, max_use_ratio=5), 70.0, 'fast_run', 'inplace', 'c_blas')