1. 01 Nov, 2019 1 commit
  2. 24 Oct, 2019 1 commit
  3. 20 Oct, 2019 1 commit
  4. 07 Oct, 2019 1 commit
    • Hide symbols from dependent libraries if HIDE_PRIVATE_SYMBOLS is ON. (#4041) · a6cd6485
      In current implementation HIDE_PRIVATE_SYMBOLS hides symbols from TVM
      itself but not from its dependent libraries. This is problematic when
      other third-party libraries with the same symbols are linked to the
      same executable.
      
      One example is using TVM with Mesa OpenCL drivers: they depend on LLVM
      and load its shared libraries with RTLD_GLOBAL flag, which results in
      conflicts with LLVM symbols that TVM uses. Arguably this particular
      issue belongs to Mesa (here's their tracking bug:
      https://gitlab.freedesktop.org/mesa/mesa/issues/236) but in general
      that's the right thing to do regardless of this particular bug.
      
      Note that I'm not enabling this functionality for Darwin as in my
      earlier tests their linker didn't seem to understand "--exclude-libs"
      (but I don't have test platform ATM to double-check).
      ndl committed
  5. 30 Sep, 2019 1 commit
  6. 17 Sep, 2019 1 commit
  7. 12 Sep, 2019 1 commit
    • [RFC] [Contrib] Minimal runtime (~12kb .text on ARMv7/x86) for subset of TVM models (#3567) · 1de52bb0
      This is an alternative implementation of a subset of the TVM runtime API (and
      graph runtime) that focuses entirely on reducing code size, at the expense of
      functionality (no tvm.extern(..) calls via PackedFunc, CPU only, etc). It might
      be worth incrementally expanding the surface area if there's interest.
      
      The motivation for this work was seeing what the minimal useful subset of the
      TVM runtime is. This is relevant for e.g. super code-size constrained
      applications in e.g. embedded/mobile. The current runtime is more like O(100KiB)
      or so, so this might be compelling for some users.
      
      The smaller surface area for auditing might make this relevant for
      https://github.com/dmlc/tvm/issues/3159, or the usecases I was thinking about in
      https://github.com/dmlc/tvm/issues/2523#issuecomment-459165815 re: the Rust
      runtime.
      
      The symbols in the tvm::minimalruntime space (i.e. excluding std:: and
      picojson::) are about 5KiB, so I think there's a bunch of room here (i.e. we
      could replace picojson:: with [`jsmn`](https://zserge.com/jsmn.html) or
      something, and we could replace more of the `std::unordered_map` usage, etc with
      custom primitives as well (similar to the `DynArray`).
      Andrew Tulloch committed
  8. 07 Sep, 2019 1 commit
  9. 21 Aug, 2019 1 commit
    • [Relay][VM]VM Profiler (#3727) · 95f12e31
      * [Relay][VM]VM debugger
      
      * Report mean/min/max for op duration
      
      * Typos
      
      * Lint
      
      * Lint
      
      * Lint
      
      * Support build debug VM in CMake
      
      * Lint
      
      * Enable VM debug in unit test
      
      * Disable debug vm test until new docker image is built
      
      * Add device sync code
      
      * Fix qnn unit test
      
      * Disable vm debug by default
      
      * Rename files
      
      * Rename classes
      
      * Fix comment
      
      * Fix comment
      Wei Chen committed
  10. 03 Aug, 2019 1 commit
  11. 26 Jul, 2019 1 commit
  12. 25 Jul, 2019 2 commits
    • Implementation of uTVM (#3227) · ef909df1
      * uTVM interfaces (#14)
      
      * some minor interface changes
      
      * implemented HostLowLevelDevice
      
      * added MicroDeviceAPI
      
      * implemented micro_common and added Python interfaces
      
      * current status, semi implemented micro session
      
      * added micro_common implementation and python interfaces (#18)
      
      * added micro_common implementation and python interfaces (#18)
      
      * current status, semi implemented
      
      * host test working
      
      * updated interfaces for MicroSession arguments allocation
      
      * make somewhat lint compatible
      
      * fix based on comments
      
      * added rounding macro
      
      * fix minor bug
      
      * improvements based on comments
      
      * Clean up `binutil.py` and make Python-3-compatible
      
      * Change argument allocation design
      
      * Address feedback and lint errors
      
      * Improve binutil tests
      
      * Simplify allocator (per @tqchen's suggestions)
      
      * Doc/style fixes
      
      * farts
      
      * mcgee
      
      * rodata section werks
      
      (and so does `test_runtime_micro_workspace.py`)
      
      * simple graph runtime werk
      
      * TEMP
      
      * ResNet works, yo
      
      * First round of cleanup
      
      * More cleanup
      
      * runs a dyson over the code
      
      * Another pass
      
      * Fix `make lint` issues
      
      * ready to pr... probably
      
      * final
      
      * Undo change
      
      * Fix rebase resolution
      
      * Minor fixes
      
      * Undo changes to C codegen tests
      
      * Add `obj_path` in `create_micro_lib`
      
      * TEMP
      
      * Address feedback
      
      * Add missing TODO
      
      * Partially address feedback
      
      * Fix headers
      
      * Switch to enum class for `SectionKind`
      
      * Add missing ASF header
      
      * Fix lint
      
      * Fix lint again
      
      * Fix lint
      
      * Kill lint warnings
      
      * Address feedback
      
      * Change Python interface to MicroTVM
      
      All interaction with the device is now through `Session` objects, which
      are used through Python's `with` blocks.
      
      * Reorder LowLevelDevice interface
      
      * Store shared ptr to session in all alloced objects
      
      * Move helper functions out of `tvm.micro`
      
      * Switch static char arr to vector
      
      * Improve general infra and code quality
      
      Does not yet address all of tqchen's feedback
      
      * Forgot a rename
      
      * Fix lint
      
      * Add ASF header
      
      * Fix lint
      
      * Partially address MarisaKirisame's feedback
      
      * Lint
      
      * Expose `MicroSession` as a node to Python
      
      * Revert to using `Session` constructor
      
      * Fix compiler error
      
      * (Maybe) fix CI error
      
      * Debugging
      
      * Remove
      
      * Quell lint
      
      * Switch to stack-based session contexts
      
      * Make uTVM less intrusive to host codegen
      
      And use SSA for operands of generated ternary operators
      
      * Inline UTVMArgs into UTVMTask struct
      
      * Remove `HostLowLevelDevice` header
      
      * Remove `BaseAddr` class
      
      * Address feedback
      
      * Add "utvm" prefix to global vars in runtime
      
      * Fix lint
      
      * Fix CI
      
      * Fix `test_binutil.py`
      
      * Fix submodules
      
      * Remove ResNet tests
      
      * Make `test_binutil.py` work with nose
      
      * Fix CI
      
      * I swear this actually fixes the binutil tests
      
      * lint
      
      * lint
      
      * Add fcompile-compatible cross-compile func
      
      * Add docs for uTVM runtime files
      
      * Move pointer patching into `MicroSession`
      
      * Fix lint
      
      * First attempt at unifying cross-compile APIs
      
      * Fix lint
      
      * Rename `cross_compile` back to `cc`
      
      * Address feedback
      
      * Remove commented code
      
      * Lint
      
      * Figure out failing function
      
      * Remove debugging code
      
      * Change "micro_dev" target to "micro"
      
      * Add checks in tests for whether uTVM is enabled
      
      * Add TODO for 32-bit support
      
      * Rename more "micro_dev" to "micro"
      
      * Undo rename
      
      We already have `tvm.micro` as a namespace.  Can't have it as a method
      as well.
      
      * Fix failing CI
      
      Thanks to @tqchen for finding this bug.  Emitting ternary operators for
      `min` and `max` causes concurrency bugs in CUDA, so we're moving the
      ternary op emissions from `CodeGenC` to `CodeGenCHost`.
      
      * Address feedback
      
      * Fix lint
      Logan Weber committed
    • fix typo (#3611) · e7fb2d4d
      Jian Weng committed
  13. 11 Jul, 2019 1 commit
  14. 01 Jul, 2019 1 commit
  15. 14 Jun, 2019 2 commits
  16. 13 Jun, 2019 1 commit
  17. 15 May, 2019 1 commit
    • [Datatypes] Custom datatypes (#2900) · 7d845f0d
      * Register and use custom datatypes in TVM
      
      This patch adds the ability to register and use a custom datatype from Python,
      using the `register_datatype` call. The datatype can then be passed as the
      `dtype` parameter using the syntax `dtype="custom[<type_name>]bitsxlanes"`.
      
      * Removes extra file
      
      * Register custom datatypes with TVM; specify Cast and Add lowering
      
      This commit adds functionality for registering custom datatypes with TVM, and
      furthermore adding custom lowering functions to lower those custom datatypes.
      This commit only adds lowering for the Cast and Add ops; more ops will be added
      soon.
      
      Check out some custom datatype samples in my repository of samples:
      https://github.com/gussmith23/tvm-custom-datatype-samples
      
      * Register and lower casts from Python
      
      * Formatting
      
      * Fix include; was including too much
      
      * Add comment
      
      * Add DatatypeRegistered
      
      * Add storage size field to custom datatypes
      
      This field indicates the bitwidth of the opaque block of data into which
      instances of the datatype will be stored, when TVM compiles. For example, if I
      create a datatype with a storage size of 16, then
      - Constants of that datatype will be created as unsigned 16-bit ints
      - Calls to external functions taking that datatype will pass the data as
        unsigned 16-bit ints
      - External functions returning that datatype will be assumed to return unsigned
        16-bit ints.
      
      * Change how lowering funcs (Cast and other ops) are named in registry
      
      tvm.datatypes.lower.<target>.cast.<dst-type>.<src-type>
      becomes
      tvm.datatypes.lower.<target>.Cast.<dst-type>.<src-type>
      
      And fixes some sloppy code around how the other ops were being formatted.
      
      * Update Python register_datatype to accept storage size
      
      * Oops, left out one cast->Cast change
      
      * Look up storage size when parsing `custom[typename]`
      
      When we encounter this type string in Python, it will be parsed into a Halide
      type object in C++. Some of my original code supported this parsing, but we now
      have to attach the storage type to the type (by setting the bits field).
      
      * Change how external calls for casting/other ops are done
      
      Firstly, we now use the storage size of the custom type when determining
      input/output types; e.g. a cast to a custom type with storage size 16 is seen as
      a call to an external function returning an opaque uint of size 16.
      
      Secondly, write a macro to handle the other ops. Originally I thought I could
      handle these at runtime, with a single `_register_op` global. I transitioned
      instead to using individual `_register_Add` etc. calls generated with a macro,
      but I don't remember why.
      
      * When encountering a custom type immediate, generate UIntImm
      
      * Translate custom types to LLVM type
      
      * Generate correct return type in Casts
      
      Originally I was assuming that the result type from casts was always a custom
      datatype, and so I was making the Call return a UInt type.
      
      * Use TVM-idiomatic recursion style in DatatypesLowerer
      
      This was actually a bug, I'm pretty sure; we wouldn't have recursed deep on any
      complex programs. As a result of making this change, I also uncovered another
      potential bug, where the datatypes lowering pass would attempt to lower a Load
      of a custom type. By commenting out the `Mutate_` for Load, I was able to stop
      the error from cropping up, but frankly, I'm not satisfied with the solution;
      how is it that we are able to run codegen when Loads of custom datatypes are
      present in the IR? I have not written any code, to my knowledge, that will
      support this. Perhaps Load does not care about the underlying datatype?
      
      * Use CHECK
      
      * Add comment about which Mutate_s are needed
      
      * Add comments
      
      * Add GetCustomDatatypeRegistered as an extern C function
      
      * Formatting, comments, casting
      
      * Change how datatype string is formatted
      
      * Use bits() instead of GetStorageSize
      
      Use bits() instead of GetStorageSize
      
      * Change comment
      
      * Add datatype.py
      
      * Change registered function name (datatypes->datatype)
      
      * Remove GetStorageSize
      
      * Format custom datatypes like any other datatype
      
      Specifically, we now print the bits and lanes after the `custom[...]` string.
      
      * Correctly implement datatype lowering in Python
      
      * Remove unneeded include
      
      * Make function naming consistent
      
      * Use CHECK instead of internal_assert
      
      * Rename macro
      
      * Formatting
      
      * Rename functions
      
      * Implement Cast lowering
      
      `_datatype_register_op` is now able to lower both binary ops and Casts.
      
      * Formatting
      
      * Formatting
      
      * Clang format, google style
      
      * Fix std::string/extern "C" warnings
      
      * Formatting
      
      * Formatting
      
      * Lower Allocates and Loads during datatype lowering
      
      This should ensure that there are no custom datatypes remaining once datatype
      lowering is done. This will allow us to remove the code in the LLVM codegen
      which deals with custom datatypes.
      
      * Revert additions to codegen_llvm.cc which are now unneeded
      
      * Pass cpplint on lower_datatypes.cc
      
      * Add clarifying comment
      
      * Remove datatype lowering registration funcs from C++
      
      * Add CHECKs
      
      * Remove TODO
      
      * Remove all references to storage size
      
      * Move and rename function
      
      * Rename function
      
      * Remove done TODOs and other handled comments
      
      * Remove irrelevant Load code and comments
      
      * Comment out the IR node types I'm not sure about yet
      
      * Add bfloat16 datatype unittest
      
      * Fix MakeConstScalar
      
      MakeConstScalar for a custom datatype will now call out to a function which can
      be registered on a per-datatype basis. The function will take a double and
      return the equivalent value in the custom datatype format.
      
      Note that these code paths are not actually used or tested at the moment. I have
      not yet written an example which uses const scalars of a custom datatype.
      
      * Formatting
      
      * Change pass name
      
      * Allow users to register whatever lowering function they want
      
      Tianqi pointed out that users should be able to register whatever lowering
      function they want, and should not be constrained to registering lowering
      functions which just call out to external libraries.
      
      I still provide a function for making lowering functions which call out to
      external libraries, for convenience.
      
      * Add clarifying comment
      
      * Remove unneeded comment
      
      * Remove unneeded function
      
      * Rename file
      
      * Undo unnecessary change
      
      * Undo unnecessary change
      
      * Make naming consistent
      
      Rename "datatypes" to "custom datatypes" in most contexts.
      
      * Revert an artifact of old code
      
      * Fix build warnings, add TODO
      
      * Lint
      
      * Remove unnecessary use of extern C by separating decl and impl
      
      * Error checking
      
      * Remove TODO
      
      * Missed a name change
      
      * Lint
      
      * Python lint
      
      * Correctly format datatype
      
      * Move bfloat16 to 3rdparty
      
      * "custom_datatypes" --> "datatype" in most places
      
      I left the pass as "LowerCustomDatatypes" to indicate that we're not lowering
      anything other than custom datatypes. Otherwise, everything else has been
      changed.
      
      * Upgrade datatype unittest
      
      I used a float calculator to generate some real testcases for the unittest.
      
      * Separate public includes and private implementation
      
      Specifically, create cleaner decoupling between datatypes stuff in packed_func
      and the datatype registry implementation.
      
      * Formatting
      
      * Limit custom datatype codes to >128
      
      * Add TODOs
      
      * Fix comment
      
      * Formatting
      
      * Clean up datatype unittest
      
      * Remove un-exported functions in public headers; UIntImm->FloatImm
      
      More places where I accidentally was using implementation-only functions in
      public headers.
      
      Additionally, store custom datatype immediates as FloatImms. A later change will
      add new lowering logic to lower these FloatImms to UIntImms.
      
      Plus formatting change.
      
      * Lint
      
      * Use FloatImm (not UIntImm) to hold immediates of custom datatypes
      
      This change switches from using UIntImm to FloatImm for storing immediates of
      custom datatypes. The value of the number is stored in a double, which should be
      enough precision for now, for most custom types we will explore in the immediate
      future.
      
      In line with this change, we change the datatype lowering so that FloatImms are
      lowered to UInts of the appropriate size. Originally, this was going to be done
      by allowing the user to register a double->uint_<storage size>_t conversion
      which would be called at compile time to convert the value from the FloatImm to
      a UInt and store it in a UIntImm. After discussions with Tianqi, we decided to
      take the simpler route, and lower FloatImms just as we lower all other ops: by
      replacing them with Call nodes. In this case, presumably the user will Call out
      to a conversion function in their datatype library.
      
      The justification for this decision is due to the functionality added in #1486.
      This pull request adds the ability to load LLVM bytecode in at compile time.
      This applies in our case as follows:
       1. The user writes their custom datatype programs and registers their lowering
          functions in the same way we've been doing it so far. All operations over
          custom datatypes are lowered to Calls to the datatype library.
       2. The user compiles their datatype library to LLVM bytecode.
       3. At TVM compile time, the user loads the LLVM bytecode. Depending on how the
          datatype library is written, Clang should be able to perform constant
          folding over the custom datatype immediates, even if their conversions are
          done with calls to the library.
      
      Additionally adds test to test the FloatImm codepath.
      
      * Re-add a change I removed accidentally during rebase
      
      * Cleanup
      
      * Remove unnecessary TVM_DLLs
      
      * Add custom datatype utilities source file to Go runtime pack
      
      * Revert "Remove unnecessary TVM_DLLs"
      
      This reverts commit 4b742b99557fd3bf0ce6617f033c8b444b74eda4.
      
      * Mark bfloat code as TVM_DLL
      
      * Moves custom datatype runtime utilities to c_runtime_api.cc
      
      * Revert "Add custom datatype utilities source file to Go runtime pack"
      
      This reverts commit aecbcde0b2cc09a2693955b77037fe20f93b5bfd.
      
      * Move datatype parsing to its own function
      
      * Change comments
      
      * Remove unneeded function
      
      * Formatting
      
      * Formatting
      
      * Documentation
      
      * Add kCustomBegin, use it for checking for custom types
      
      * Documentation
      
      * Formatting
      
      * Move static definition to implementation
      
      * Remove comment
      
      * Decide toBeLowered before lowering arguments of Expr
      
      In the past, e.g. when lowering custom datatypes for an Add, we would lower a
      and b first, and then decide whether the resulting new Add needed to be lowered
      based on the (new) types of a and b. Now, instead, we need to check the types of
      a and b first (to see if they're custom types), and then lower them (so they'll
      become non-custom types), and then lower the new Add.
      
      * Revert "Move datatype parsing to its own function"
      
      This reverts commit d554a5881afcf69af1c070d882a7651022703a09.
      
      This broke parsing. Will figure this out later. There isn't a really clean way
      to separate this out given how the rest of the function is written.
      
      * Replace comment
      
      * Documentation
      
      * Remove comment and TVM_DLL
      
      * Better error messages
      
      * Remove artifact of rebase
      
      * Separate datatypes parsing to its own function
      
      * Add \returns
      
      * Comment changes; add TODO
      
      * Refactor tests
      Gus Smith committed
  18. 09 May, 2019 1 commit
    • [Relay][Runtime] Implementation of Relay VM (#2889) · 4332b0aa
      * Implement the virtual machine
      
      Co-Authored-By: wweic <ipondering.weic@gmail.com>
      
      * Fix rebase build issues
      
      * Reorganize vm.py and fix allocator bug
      
      * Remove compiler
      
      * Remove tests
      
      * Remove backend/vm/vm.cc too
      
      * Fix docs
      
      * Fix doc
      
      * Fix doc
      
      * Add vm docs
      
      * Remove change to dead_code.cc
      
      * Remove Relay logging
      
      * Remove reduce
      
      * Update include/tvm/runtime/vm.h
      
      Co-Authored-By: jroesch <roeschinc@gmail.com>
      
      * Reformat
      
      * Update include/tvm/runtime/vm.h
      
      Co-Authored-By: jroesch <roeschinc@gmail.com>
      
      * Address feedback
      
      * Update include/tvm/runtime/vm.h
      
      Co-Authored-By: jroesch <roeschinc@gmail.com>
      
      * Apply suggestions from code review
      
      Co-Authored-By: jroesch <roeschinc@gmail.com>
      
      * Fix a couple outstanding comments
      
      * Last couple comments
      
      * Update include/tvm/runtime/vm.h
      
      Co-Authored-By: jroesch <roeschinc@gmail.com>
      
      * Address code review feedback
      
      * Fix final comment
      
      * Address comments
      
      * Error reporting and example
      
      * add Const
      
      * Explicitly delete copy assignment operator
      
      * Fix rebase
      
      * Pass 3rd arg to fusion
      Jared Roesch committed
  19. 12 Apr, 2019 1 commit
  20. 10 Apr, 2019 1 commit
  21. 04 Apr, 2019 1 commit
  22. 12 Mar, 2019 1 commit
  23. 13 Feb, 2019 1 commit
    • [Hybrid script] Backend support (#2477) · c53dd102
      * a preliminary version is done?
      
      * we no longer need the redundant hybrid/api.py
      
      * support assert stmt
      
      * cast supported
      
      * intrin -> runtime; util is mainly in charge of compilation time
      
      * assert statement
      
      * fix python lint
      
      * fix cpp lint
      
      * on the way to module
      
      * rollback .cc
      
      * fix typo, no direct expose then
      
      * @vinx13 ceil is added i guess?
      
      * wip...
      
      * temp commit
      
      * fix import
      
      * i preliminary version is done?
      
      * on the way to build hybrid module
      
      * nearly fixed...
      
      * dumped python are equiv as original python
      
      * on the way to bootstrap
      
      * cpu bootstrap done
      
      * bootstrap!
      
      * fix lint
      
      * fix doc
      
      * resolve some review concerns
      
      * support load/save
      
      * fix lint
      
      * thanks to xqdan fixed my typo
      
      * fix build, make dump non-optional
      
      * add vthread
      
      * jesus why i added this
      Jian Weng committed
  24. 29 Jan, 2019 1 commit
  25. 25 Jan, 2019 1 commit
  26. 19 Jan, 2019 1 commit
  27. 02 Dec, 2018 1 commit
  28. 19 Nov, 2018 1 commit
  29. 01 Nov, 2018 1 commit
  30. 18 Oct, 2018 1 commit
  31. 09 Oct, 2018 1 commit
  32. 04 Oct, 2018 1 commit
  33. 28 Sep, 2018 1 commit
  34. 25 Sep, 2018 1 commit
  35. 24 Sep, 2018 1 commit
  36. 19 Sep, 2018 1 commit
  37. 11 Aug, 2018 1 commit
  38. 27 Jul, 2018 1 commit