• Frederic's avatar
    Make opt faster by calling get_scalar_constant_value() only on constant. · 64d621b4
    Frederic 提交于
    This last commit finish to bring from 584s to 66s the slow scan test:
    theano/scan_module/tests/test_scan.py:T_Scan.test_hessian_bug_grad_grad_two_scans
    
    The changed optimization:
    
    local_abs_merge, local_mul_switch_sink,
    local_upcast_elemwise_constant_inputs,
    local_remove_switch_const_con
    
    are called on nodes that aren't yet part of the graph, during
    local_subtensor_merge optimization. They aren't supposed to work on
    node that are in the graph, but as they called
    get_scalar_constant_value() they traversed it very frequently!
    
    This pre_greedy_local_optimizer call is needed as it would introduce
    too much scrapt that will be optimized away. So we preoptimize the
    graph.
    
    As now we do the constant_folding in the phase
    (canonicalize/stabilize/specialize) where those changed opt are used,
    they can work directly on Constant. Other opt will make sure their
    inputs get constant if possible.
    64d621b4
opt.py 194.2 KB