1. 18 2月, 2025 8 次提交
    • Brendan Murphy's avatar
      Changed copy to deepcopy for rng · fb20e58a
      Brendan Murphy 提交于
      This was done for the python linker and numba linker.
      
      deepcopy seems to be the recommended method for
      copying a numpy Generator.
      
      After this numpy PR:
      https://github.com/numpy/numpy/pull/26293/commits/44ba7ca07984557f2006f9a6916adb8e3ecfca61
      `copy` didn't seem to actually make an independent copy of
      the `np.random.Generator` objects spawned by `RandomStream`.
      
      This was causing the "test values" computed by e.g.
      `RandomStream.uniform` to increment the RNG state, which
      was causing tests that rely on `RandomStream` to fail.
      
      Here is some related discussion:
      https://github.com/numpy/numpy/issues/24086
      
      I didn't see any official documentation about
      a change in numpy that would make copy stop
      working.
      fb20e58a
    • Brendan Murphy's avatar
      Use Python implementation for AdvancedInSubtensor1 · 48894fae
      Brendan Murphy 提交于
      MapIter was removed from the public numpy C-API in
      version 2.0, so we raise a not implemented error to
      default to the python code for the AdvancedInSubtensor1.
      
      The python version, defined in `AdvancedInSubtensor1.perform`
      calls `np.add.at`, which uses `MapIter` behind the scenes.
      There is active development on Numpy to improve the efficiency
      of `np.add.at`.
      
      To skip the C implementation and use the Python implementation,
      we raise a NotImplementedError for this op's c code if numpy>=2.0.
      48894fae
    • Brendan Murphy's avatar
      Make complex scalars work with numpy 2.0 · 756be77e
      Brendan Murphy 提交于
      This is done using C++ generic functions
      to get/set the real/imag parts of complex numbers.
      
      This gives us an easy way to support Numpy v < 2.0,
      and allows the type underlying the bit width types,
      like pytensor_complex128, to be correctly inferred
      from the numpy complex types they inherit from.
      
      Updated pytensor_complex struct to use get/set real/imag
      aliases defined above. Also updated operators such as
      `Abs` to use get_real, get_imag.
      
      Macros have been added to ensure compatibility with numpy < 2.0
      
      Note: redefining the complex arithmetic here means that we
      aren't treating NaNs and infinities as carefully as the C99
      standard suggets (see Appendix G of the standard).
      
      The code has been like this since it was added to Theano,
      so we're keeping the existing behavior.
      756be77e
    • Brendan Murphy's avatar
      Update type hint for c_code_cache_version · bfc07777
      Brendan Murphy 提交于
      Anything `Hashable` should work, but I've made the
      return type `tuple[Hashable]` to keep with the current style.
      
      This means, e.g., we can use strings in the cache version.
      bfc07777
    • Ricardo Vieira's avatar
      Changes for deprecations in numpy 2.0 C-API · 0145d609
      Ricardo Vieira 提交于
      - replace `->elsize` by `PyArray_ITEMSIZE`
      - don't use deprecated PyArray_MoveInto
      0145d609
    • Brendan Murphy's avatar
      Updated lazylinker C code · 8f4d7b1f
      Brendan Murphy 提交于
      Some macros were removed from npy_3k_compat.h.
      Following numpy, I updated the affected functions
      to the Python 3 names, and removed support for Python 2.
      
      Also updated lazylinker_c version to indicate substantial changes to the
      C code.
      8f4d7b1f
    • Virgile Andreani's avatar
      Changes for numpy 2.0 deprecations · ca089790
      Virgile Andreani 提交于
      - Replace np.cast with np.asarray: in numpy 2.0,
        `np.cast[new_dtype](arr)` is deprecated.
        The literal replacement is `np.asarray(arr, dtype=new_dtype)`.
      
      - Replace np.sctype2char and np.obj2sctype.
        Added try/except to handle change in behavior
        of `np.dtype`
      
      - Replace np.find_common_type with np.result_type
      
      Further changes to `TensorType`:
      
      TensorType.dtype must be a string, so the code
      has been changed from `self.dtype = np.dtype(dtype).type`,
      where the right-hand side is of type `np.generic`, to
      `self.dtype = str(np.dtype(dtype))`, where the right-hand
      side is a string that satisfies:
      
      `self.dtype == str(np.dtype(self.dtype))`
      
      This doesn't change the behavior of `np.array(..., dtype=self.dtype)`
      etc.
      ca089790
    • Ricardo Vieira's avatar
      Update numpy deprecated imports · e036caf9
      Ricardo Vieira 提交于
      - replaced np.AxisError with np.exceptions.AxisError
      - the `numpy.core` submodule has been renamed to `numpy._core`
      - some parts of `numpy.core` have been moved to `numpy.lib.array_utils`
      
      Except for `AxisError`, the updated imports are conditional on
      the version of numpy, so the imports should work for numpy >= 1.26.
      
      The conditional imports have been added to `npy_2_compat.py`, so the
      imports elsewhere are unconditonal.
      e036caf9
  2. 17 2月, 2025 13 次提交
  3. 13 2月, 2025 3 次提交
  4. 12 2月, 2025 6 次提交
  5. 10 2月, 2025 1 次提交
  6. 06 2月, 2025 1 次提交
  7. 04 2月, 2025 4 次提交
  8. 03 2月, 2025 2 次提交
  9. 01 2月, 2025 2 次提交