1. 08 Apr, 2020 1 commit
    • [RELAY][BYOC] Add support for composite functions in BYOC (#5261) · d2de35eb
      * [RELAY] Add 'check' functions to MergeComposite
      
      Currently, MergeComposite can only perform structural
      matches. This patch introduces the ability to specify
      a 'check' function alongside the pattern which can include
      custom logic to determine whether an extracted pattern
      should be merged.
      
      For example, if you only want to merge 'NHWC' convolutions,
      you can specify a 'check' function which queries the
      data_layout value of the extracted pattern (see the test).
      
      Change-Id: I9337ce39f10997051a286d888be38ed0d410d340
      
      * [RELAY] Reformat merge_composite.cc
      
      Run clang-format on merge_composite.cc
      
      Change-Id: I1736bff798cc6d93e57519b08ab3362869098779
      
      * [RELAY][BYOC] Support composite functions in AnnotateTarget
      
      This patch introduces support to annotate composite functions
      in the AnnotateTarget pass. In order for a composite function
      to be annotated, you should name it according to the style:
      
      {codegen}.{name}
      eg. dnnl.add_relu
      
      Change-Id: I74d6c0b506153d866f6d1feb203b32dad59f2871
      mbaret committed
  2. 27 Mar, 2020 1 commit
  3. 23 Mar, 2020 1 commit
  4. 12 Mar, 2020 2 commits
    • [REFACTOR] Streamline Function Attr interface. (#5045) · ec86d7f1
      * [REFACTOR] Streamline Function Attr interface.
      
      There has been quite a few recent changes that depends heavily on
      the function attr interface. This PR streamlines that interface by introducing
      two APIs that covers most of the usages.
      
      - GetAttr which gets a typed object for a given key
        - HasNonzeroAttr is a quick helper that calls GetAttr to quickly check an attribute
      - WithAttr that creates a new function object with the given attr
        - The API comes with copy on write optimization to avoid multiple copies
        - We deliberately pick the prefix With(instead of Set) to indicate this
          function does not mutate the original input.
      
      On the python side:
      - We allow read access via func.attrs (which is a DictAttr)
      - func.with_attrs to create a new instance with updated attrs.
      
      We also get rid of the small wrapper functions and make sure the API centered around
      the GetAttr and HasNonzeroAttr interface.
      
      This PR also changes the function construction to follow the new convention.
      
      * Address review comments
      
      * Address review comments
      
      * Fix doxygen path
      Tianqi Chen committed
    • [refactor][relay pass] Separate analysis and transform passes (#5035) · 14ba49c6
      * [refactor][relay pass] Separate analysis and transform passes into different subfolders
      
      * remove pass folder
      Zhi committed
  5. 10 Mar, 2020 1 commit
  6. 17 Feb, 2020 1 commit
  7. 10 Feb, 2020 1 commit
    • [Relay] Added Merge Composite pass (#4771) · 0dbe70c1
      * [Relay] Added MergeComposite pass
      
      This pass allows for patterns to be wrapped
      in a function marked with 'Composite' and a
      composite function name. This is intended to be
      used with the external codegen for the cases where
      an external operator maps to multiple Relay
      operators. In that case, the mapping can be expressed
      as a pattern and assigned a name.
      
      For more information on this pass and its motivation,
      see the RFC:
      https://discuss.tvm.ai/t/rfc-external-codegen-defining-composite-relay-operators/5470
      
      Change-Id: Icb1b803a9f0ac57c529143200228f3bb5793afc0
      
      * [Relay] Merge composite tests
      
      Added tests for the merge_composite pass.
      
      Change-Id: I1728b4a05b0c1c36140a40f1afe028fde62185dd
      
      * Merge composite additional test
      
      Change-Id: I9bc7d6053c575e9468ac5abc31214c6ad8507e46
      
      * Support priority order in merge_composite
      
      The order in which the patterns are matched
      was currently random as an unordered_map was
      used to store the pattern table. This uses
      arrays instead so that a distinct priority
      order of matching can be defined. Additional
      tests have also been added to verify this
      behaviour.
      
      Change-Id: Ief347df4262639138d5d9d7c8cee7ef233af7b56
      
      * Improved merge composite docs
      
      Change-Id: Ie3a72045ecc3f13ad3c302fbdf192b7296a306a8
      
      * Removed unused variable
      
      Change-Id: I7814d5fde368ffaf1b3d6d806060c774c7720364
      
      * Remove unnecessary op check
      
      Change-Id: I38e78d2acd5b86cb8e837be72ff9d72cd10bcf33
      
      * Improve styling on composite function creation
      
      Change-Id: I37add1c3134e0b5d5085fe1eb9daf8e06890fa8c
      
      * Comment reword
      
      Change-Id: Ie05872dcbbe0c3e1190b0597083b9a64e6b66c66
      
      * Stylistic changes to avoid std::move
      
      Change-Id: I43a93995bbf10530399900c992aa99dd4ae4575f
      
      * Relax a check in ExtractPattern
      
      Change-Id: I0faef77a66c55f83f09e6e47c561ffaea63dedfa
      
      * Remove new line
      
      Change-Id: Ifdd02c12087a7e1a0a9b54825669bc0de8f13c3d
      
      * Removed MatchPattern from MergeComposite
      
      This is not necessary now that ExtractPattern
      can fulfill the same purpose.
      
      Change-Id: I14dc020afa8e50f2df4c0a2efb88a011987f8196
      
      * Removed a new line
      
      Change-Id: I8b50f0c9069aa1bcaccbe68eb421031f01a64842
      
      * Improved docs for merge composite
      
      Change-Id: Ib1959a35c856e7ea5639de2e4ef314a54f44caf5
      
      * Fixed free vars in test
      
      Change-Id: I2b7f273db275964ec0e9820560663f0808adee79
      
      * Handle case where root arg might not be a call
      
      Change-Id: I4eeea3ce723d3ba337d110dcc690377daebe8626
      
      * Removed blank line
      
      Change-Id: I07f5392c0e95cfe3cfa5c333703cc6f82d6034fb
      
      * Change to CHECK_EQ
      
      Change-Id: I5c5d62d3cd57f72508b30b926f72091ae6f0d1cc
      
      * Revised a conditional
      
      Change-Id: I23a7897ca15a7cd076db5039dc653a4b8c27e803
      
      * Improved doc styling
      
      Change-Id: I377f0a1c1ac70f3b8d7584b0c49bddc8c6c134ef
      
      * Fail extraction if vars conflict
      
      Change-Id: I78e36d805e8ed6b55e61d490212a967c857554a4
      
      * Added further merge composite tests
      
      Change-Id: Ib1d800409fca4c1834c7fe0cab5a26ab99a26820
      
      Co-authored-by: lhutton1 <35535092+lhutton1@users.noreply.github.com>
      mbarrett97 committed