Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite the skip stages lowering pass #8115

Merged
merged 15 commits into from
Feb 27, 2024
Merged

Commits on Feb 18, 2024

  1. Avoid redundant scope lookups

    This pattern has been bugging me for a long time:
    
    ```
    if (scope.contains(key)) {
      Foo f = scope.get(key);
    }
    ```
    
    This redundantly looks up the key in the scope twice. I've finally
    gotten around to fixing it. I've introduced a find method that either
    returns a const pointer to the value, if it exists, or null. It also
    searches any containing scopes, which are held by const pointer, so the
    method has to return a const pointer.
    
    ```
    if (const Foo *f = scope.find(key)) {
    }
    ```
    
    For cases where you want to get and then mutate, I added shallow_find,
    which doesn't search enclosing scopes, but returns a mutable pointer.
    
    We were also doing redundant scope lookups in ScopedBinding. We stored
    the key in the helper object, and then did a pop on that key in the
    ScopedBinding destructor. This commit changes Scope so that Scope::push
    returns an opaque token that you can pass to Scope::pop to have it
    remove that element without doing a fresh lookup. ScopedBinding now uses
    this. Under the hood it's just an iterator on the underlying map (map
    iterators are not invalidated on inserting or removing other stuff).
    
    The net effect is to speed up local laplacian lowering by about 5%
    
    I also considered making it look more like an stl class, and having find
    return an iterator, but it doesn't really work. The iterator it returns
    might point to an entry in an enclosing scope, in which case you can't
    compare it to the .end() method of the scope you have. Scopes are
    different enough from maps that the interface really needs to be
    distinct.
    abadams committed Feb 18, 2024
    Configuration menu
    Copy the full SHA
    fb2cf29 View commit details
    Browse the repository at this point in the history
  2. Pacify clang-tidy

    abadams committed Feb 18, 2024
    Configuration menu
    Copy the full SHA
    72bcf1d View commit details
    Browse the repository at this point in the history

Commits on Feb 19, 2024

  1. Configuration menu
    Copy the full SHA
    1f8c8b5 View commit details
    Browse the repository at this point in the history

Commits on Feb 20, 2024

  1. Fix accidental Scope::get

    abadams committed Feb 20, 2024
    Configuration menu
    Copy the full SHA
    8d59c7c View commit details
    Browse the repository at this point in the history

Commits on Feb 21, 2024

  1. Configuration menu
    Copy the full SHA
    7534edb View commit details
    Browse the repository at this point in the history
  2. Rewrite the skip stages lowering pass

    Skip stages was slow due to crappy computational complexity (quadratic?)
    
    I reworked it into a two-pass linear-time algorithm. The first part
    remembers which pieces of IR are actually relevant to the task, and the
    second pass performs the task using a bounds-inference-like algorithm.
    
    On main resnet50 spends 519 ms in this pass. This commit reduces it to
    40 ms. Local laplacian with 100 pyramid levels spends 7.4 seconds in
    this pass. This commit reduces it to ~3 ms.
    
    This commit also moves the cache store for memoized Funcs into the
    produce node, instead of at the top of the consume node, because it
    naturally places it inside a condition you inject into the produce node.
    abadams committed Feb 21, 2024
    Configuration menu
    Copy the full SHA
    f488bbf View commit details
    Browse the repository at this point in the history
  3. clang-tidy fixes

    abadams committed Feb 21, 2024
    Configuration menu
    Copy the full SHA
    42ebab3 View commit details
    Browse the repository at this point in the history

Commits on Feb 22, 2024

  1. Configuration menu
    Copy the full SHA
    7ac285f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    8d7256f View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    7c2086c View commit details
    Browse the repository at this point in the history

Commits on Feb 23, 2024

  1. Configuration menu
    Copy the full SHA
    0aec3bc View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f77dc78 View commit details
    Browse the repository at this point in the history

Commits on Feb 24, 2024

  1. Another used -> loaded

    abadams committed Feb 24, 2024
    Configuration menu
    Copy the full SHA
    19d8368 View commit details
    Browse the repository at this point in the history

Commits on Feb 26, 2024

  1. Configuration menu
    Copy the full SHA
    e258e33 View commit details
    Browse the repository at this point in the history

Commits on Feb 27, 2024

  1. Configuration menu
    Copy the full SHA
    4e574c3 View commit details
    Browse the repository at this point in the history