Skip to content
Snippets Groups Projects
  1. Mar 12, 2025
  2. Mar 10, 2025
    • Matt Smith's avatar
      Avoid double caching in mappers that derive from `CachedMapper` (#585) · ec98289c
      Matt Smith authored
      * refactor deduplicate_data_wrappers to avoid dependence on erroneous super().rec usage in CachedMapAndCopyMapper
      
      Here is a sketch of what happens with super().rec vs Mapper.rec for the previous implementation of
      deduplicate_data_wrappers. Suppose we have 2 data wrappers a and b with the same data pointer.
      
      With super().rec:
      
      1) map_fn maps a to itself, then mapper copies a to a'; mapper caches a -> a' (twice, once in
         super().rec and then again in rec),
      2) map_fn maps b to a, then mapper maps (via cache in super().rec call) a to a'; mapper caches
         b -> a'.
      
      => Only a' in output DAG.
      
      With Mapper.rec:
      
      1) map_fn maps a to itself, then mapper copies a to a'; caches a -> a',
      2) map_fn maps b to a, then mapper copies a to a''; caches b -> a''.
      
      => Both a' and a'' in output DAG.
      
      * call Mapper.rec instead of super().rec to avoid double caching
      
      * call Mapper.rec from CachedMapper too just to avoid copy/paste errors
      
      * add assertion to check for double caching
      
      * add comment explaining use of Mapper.rec
      ec98289c
  3. Feb 24, 2025
  4. Feb 06, 2025
  5. Feb 05, 2025
  6. Feb 04, 2025
  7. Feb 03, 2025
  8. Jan 30, 2025
  9. Jan 28, 2025
    • Matt Smith's avatar
      Use a class for `CachedMapper`-derived mappers instead of a dict (#549) · 26b2223e
      Matt Smith authored
      * make CombineMapper inherit from CachedMapper
      
      * move axis tag attaching code into a separate method in AxisTagAttacher
      
      * use a class for CachedMapper caches instead of using a dict directly
      
      * drop P from mapper caches, since it's not being used
      
      * add comment about type annotations in CachedMapperCache
      26b2223e
  10. Jan 23, 2025
  11. Jan 22, 2025
  12. Jan 17, 2025
    • Matt Smith's avatar
      Cache mapped functions (#531) · 46431ee2
      Matt Smith authored
      * avoid traversing functions multiple times
      
      * condense function cache setup
      
      * pass function cache to CombineMapper.__init__ too
      
      * use Never instead of None as the function result type for mappers that don't support functions
      
      * remove multiple inheritance for TransformMapperWithExtraArgs
      
      doesn't appear to be needed
      
      * add _verify_is_array to avoid the need for rec_ary
      
      the latter inflates recursion depth
      
      * remove map_foreign from Mapper
      
      * use Never as FunctionResultT for NumpyCodegenMapper and FancyDotWriter too
      
      * make PlaceholderSubstitutor explicit about not supporting functions
      
      * tweak types in rec/rec_function_definition
      
      * use P.args/P.kwargs in CachedWalkMapper
      
      * use a more specific type than Any for cache key in CachedWalkMapper
      
      * remove some more Anys
      46431ee2
  13. Jan 09, 2025
  14. Dec 20, 2024
  15. Dec 18, 2024
  16. Dec 13, 2024
  17. Dec 10, 2024
  18. Dec 04, 2024
  19. Dec 01, 2024
  20. Nov 25, 2024
  21. Nov 23, 2024
  22. Nov 22, 2024
  23. Nov 19, 2024
  24. Nov 17, 2024
Loading