• Luca Citi's avatar
    Use stricter numerical tolerance in rewrites and allow casting in `PatternNodeRewriter` (#1526) · d4e8f736
    Luca Citi 提交于
    * Implemented allow_cast in PatternNodeRewriter
    to allow rewrites that would otherwise fail when the new and old dtype differ.
    Example:
    `np.array(1., "float64") - sigmoid(x)` cannot be rewritten as
    `sigmoid(-x)` (where x is an fmatrix) because the type would change.
    This commit allows an automatic cast to be added so the expression
    is rewritten as `cast(sigmoid(-x), "float64")`.
    Relevant tests added.
    
    * Added test cases for which issue #1497 fails
    
    * Changed PatternNodeRewriter::transform to allow types that do not contain dtype
    like MyType in the tests
    
    * Address #1497 by changing instances of np.isclose to a function isclose, which uses 10 ULPs by default
    
    * Addressed failed tests (with older python/numpy versions)
    
    * Addressed feedback by ricardoV94
    
    * Test PatternNodeRewriter doesn't support multi-output nodes in pattern
    
    But it's fine if they're just root inputs
    
    ---------
    Co-authored-by: 's avatarLuca Citi <lciti@ieee.org>
    Co-authored-by: 's avatarRicardo Vieira <ricardo.vieira1994@gmail.com>
    d4e8f736
名称
最后提交
最后更新
..
conv 正在载入提交数据...
linalg 正在载入提交数据...
random 正在载入提交数据...
rewriting 正在载入提交数据...
signal 正在载入提交数据...
__init__.py 正在载入提交数据...
test_basic.py 正在载入提交数据...
test_blas.py 正在载入提交数据...
test_blas_c.py 正在载入提交数据...
test_blockwise.py 正在载入提交数据...
test_casting.py 正在载入提交数据...
test_complex.py 正在载入提交数据...
test_einsum.py 正在载入提交数据...
test_elemwise.py 正在载入提交数据...
test_extra_ops.py 正在载入提交数据...
test_fft.py 正在载入提交数据...
test_fourier.py 正在载入提交数据...
test_functional.py 正在载入提交数据...
test_gc.py 正在载入提交数据...
test_inplace.py 正在载入提交数据...
test_interpolate.py 正在载入提交数据...
test_io.py 正在载入提交数据...
test_keepdims.py 正在载入提交数据...
test_math.py 正在载入提交数据...
test_math_scipy.py 正在载入提交数据...
test_merge.py 正在载入提交数据...
test_nlinalg.py 正在载入提交数据...
test_optimize.py 正在载入提交数据...
test_pad.py 正在载入提交数据...
test_shape.py 正在载入提交数据...
test_sharedvar.py 正在载入提交数据...
test_slinalg.py 正在载入提交数据...
test_sort.py 正在载入提交数据...
test_special.py 正在载入提交数据...
test_subtensor.py 正在载入提交数据...
test_type.py 正在载入提交数据...
test_type_other.py 正在载入提交数据...
test_utils.py 正在载入提交数据...
test_variable.py 正在载入提交数据...
test_xlogx.py 正在载入提交数据...
utils.py 正在载入提交数据...