@local_optimizer([CGemv(inplace=False)]) def make_c_gemv_destructive(node): if node.op == cgemv_no_inplace: return [cgemv_inplace(*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')
@local_optimizer([CGemv(inplace=False)]) def make_c_gemv_destructive(node): if isinstance(node.op, CGemv) and not node.op.inplace: inputs = list(node.inputs) dest = inputs[0] if (dest.owner and isinstance(dest.owner.op, tt.AllocEmpty) and len(dest.clients) > 1): inputs[0] = tt.AllocEmpty(dest.dtype)(*dest.owner.inputs) return [cgemv_inplace(*inputs)] # ##### ####### ####### # Optimizers # ##### ####### ####### blas_optdb.register("use_c_blas", in2out(use_c_ger, use_c_gemv), 20, "fast_run", "c_blas") # this matches the InplaceBlasOpt defined in blas.py optdb.register( "c_blas_destructive", in2out(make_c_ger_destructive, make_c_gemv_destructive, name="c_blas_destructive"), 70.0, "fast_run", "inplace", "c_blas", )
@local_optimizer([ger, ger_destructive]) def use_scipy_ger(node): if node.op == ger: return [scipy_ger_no_inplace(*node.inputs)] @local_optimizer([scipy_ger_no_inplace]) def make_ger_destructive(node): if node.op == scipy_ger_no_inplace: return [scipy_ger_inplace(*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')
cannot be performed at that time. """ force_init_beta = check_force_gemv_init() return [CGemv(inplace=False, force_init_beta=force_init_beta)(*node.inputs)] if node.op == gemv_inplace and node.outputs[0].dtype in ["float32", "float64"]: return [CGemv(inplace=True)(*node.inputs)] @local_optimizer([CGemv(inplace=False)]) def make_c_gemv_destructive(node): if node.op == cgemv_no_inplace: return [cgemv_inplace(*node.inputs)] # ##### ####### ####### # Optimizers # ##### ####### ####### blas_optdb.register("use_c_blas", in2out(use_c_ger, use_c_gemv), 20, "fast_run", "c_blas") # this matches the InplaceBlasOpt defined in blas.py optdb.register( "c_blas_destructive", in2out(make_c_ger_destructive, make_c_gemv_destructive, name="c_blas_destructive"), 70.0, "fast_run", "inplace", "c_blas", )
scipy_ger_no_inplace = ScipyGer(False) scipy_ger_inplace = ScipyGer(True) @local_optimizer([ger, ger_destructive]) def use_scipy_ger(node): if node.op == ger: return [scipy_ger_no_inplace(*node.inputs)] @local_optimizer([scipy_ger_no_inplace]) def make_ger_destructive(node): if node.op == scipy_ger_no_inplace: return [scipy_ger_inplace(*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')
""" force_init_beta = check_force_gemv_init() return [ CGemv(inplace=False, force_init_beta=force_init_beta)(*node.inputs) ] if (node.op == gemv_inplace and node.outputs[0].dtype in ['float32', 'float64']): return [CGemv(inplace=True)(*node.inputs)] @local_optimizer([CGemv(inplace=False)]) def make_c_gemv_destructive(node): if isinstance(node.op, CGemv) and not node.op.inplace: return [cgemv_inplace(*node.inputs)] # ##### ####### ####### # Optimizers # ##### ####### ####### blas_optdb.register('use_c_blas', in2out(use_c_ger, use_c_gemv), 20, 'fast_run', 'c_blas') # this matches the InplaceBlasOpt defined in blas.py optdb.register( 'c_blas_destructive', in2out(make_c_ger_destructive, make_c_gemv_destructive, name="c_blas_destructive"), 70.0, 'fast_run', 'inplace', 'c_blas')
def use_scipy_ger(node): if node.op == ger: return [scipy_ger_no_inplace(*node.inputs)] @local_optimizer([scipy_ger_no_inplace]) def make_ger_destructive(node): if node.op == scipy_ger_no_inplace: return [scipy_ger_inplace(*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", )
return [CGemv(inplace=True)(*node.inputs)] @local_optimizer([CGemv(inplace=False)]) def make_c_gemv_destructive(node): if isinstance(node.op, CGemv) and not node.op.inplace: inputs = list(node.inputs) dest = inputs[0] if (dest.owner and isinstance(dest.owner.op, T.AllocEmpty) and len(dest.clients) > 1): inputs[0] = T.AllocEmpty(dest.dtype)(*dest.owner.inputs) return [cgemv_inplace(*inputs)] # ##### ####### ####### # Optimizers # ##### ####### ####### blas_optdb.register('use_c_blas', in2out(use_c_ger, use_c_gemv), 20, 'fast_run', 'c_blas') # this matches the InplaceBlasOpt defined in blas.py optdb.register('c_blas_destructive', in2out(make_c_ger_destructive, make_c_gemv_destructive, name="c_blas_destructive"), 70.0, 'fast_run', 'inplace', 'c_blas')
@local_optimizer([CGemv(inplace=False)]) def make_c_gemv_destructive(node): if node.op == cgemv_no_inplace: return [cgemv_inplace(*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", )
@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')