Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
167 commits
Select commit Hold shift + click to select a range
97eca8e
Add ChangeDatatype pass and unittest
gussmith23 May 3, 2019
4861ad5
[WIP] Jared's work on Fri
gussmith23 May 3, 2019
d6a0309
Fix simplify inference to work over different data types.
jroesch May 7, 2019
f5f37f0
Formatting
gussmith23 May 7, 2019
3b879c9
Copy setup code from other test file
gussmith23 May 7, 2019
143195d
Logging in Relay
gussmith23 May 7, 2019
95485b7
Remove duplicate TVM_DLL
gussmith23 May 10, 2019
73fe88f
Add Sub, Mul, Div, Max to bfloat lib
gussmith23 May 10, 2019
cbee8f6
Fix previous broken rebased commit
gussmith23 Jun 14, 2020
5b4e108
Remove line
gussmith23 Jun 15, 2020
10bf96a
Add LowerCustomDatatypes to build passes
gussmith23 May 10, 2019
549af5e
Upcast ints to custom datatypes too, as well as to floats
gussmith23 May 10, 2019
b290d29
Add and use convert_ndarray
gussmith23 Jun 15, 2020
40b3e82
Lower Call
gussmith23 May 10, 2019
dd615af
Relay: create constant scalars of custom dtypes
gussmith23 May 10, 2019
ab248f3
Custom datatype formatting in Relay
gussmith23 May 10, 2019
d2e4119
Update unittests
gussmith23 May 10, 2019
a4506ae
Add simpler example that's not working yet
gussmith23 May 11, 2019
fed9103
Add Python unittests to Makefile
gussmith23 May 14, 2019
8369343
Fix bug
gussmith23 Jun 15, 2020
4633964
Fix function name in GetPackedFunc call
gussmith23 Jun 15, 2020
a118a6e
convert_ndarray makes its own executor
gussmith23 Jun 15, 2020
d54e738
Add simple test case
gussmith23 May 17, 2019
d2f2e18
Move setup() calls
gussmith23 May 17, 2019
cdfda16
Use convert_ndarray
gussmith23 Jun 15, 2020
ef335e5
Change import to make it more specific
gussmith23 May 17, 2019
78438aa
Fix another Registry::Get call
gussmith23 Jun 15, 2020
49dad92
Allow users to register minimum functions for custom datatypes
gussmith23 Oct 17, 2019
bab3bb3
Remove check for float
gussmith23 Jun 15, 2020
97c3714
Add test
gussmith23 May 17, 2019
d78f8a7
Fix inception test
gussmith23 Jun 15, 2020
3b99965
Add MobileNet
gussmith23 May 22, 2019
62d26fe
Lower custom datatypes before intrinsics
gussmith23 May 23, 2019
5fe578c
Add exp and sqrt bfloat functions
gussmith23 May 24, 2019
6e3ee1f
[buggy commit] Lower intrinsics like sqrt, exp
gussmith23 May 24, 2019
e9997ba
Formatting
gussmith23 May 24, 2019
838e087
Fix bug
gussmith23 Jun 15, 2020
976113a
Add lowering for new ops in test
gussmith23 May 24, 2019
f82ad51
Add int to bfloat
gussmith23 May 24, 2019
a734c09
Remove print
gussmith23 May 24, 2019
02565f3
Add all tests
gussmith23 May 24, 2019
a7dbbdc
Correct image size
gussmith23 May 24, 2019
1dd86a6
Add TODO
gussmith23 Jun 21, 2019
4c592a0
Add "notbfloat" type
gussmith23 Jun 21, 2019
ab89ce8
Convert arguments
gussmith23 Jun 21, 2019
4848ab4
Rewrite custom datatype constants in Relay
gussmith23 Jun 21, 2019
f05cf34
Add test_ops
gussmith23 Jun 21, 2019
14d34b7
Print constants in Relay
gussmith23 Jun 21, 2019
c5cddb0
Use topi.testing
gussmith23 Jun 21, 2019
2ea0e84
Test conv2d
gussmith23 Jun 21, 2019
2c4b73f
Add test_model
gussmith23 Jun 21, 2019
b7191fb
Comment out model tests
gussmith23 Jun 21, 2019
119ea8d
Register notbfloat
gussmith23 Jun 21, 2019
e66c9c4
Add commented code
gussmith23 Jun 21, 2019
038b957
Add posit tests
gussmith23 Jun 22, 2019
69eebcd
test_ops_same_function
gussmith23 Jun 25, 2019
8077878
[temporary] move incomplete commit to macbook
gussmith23 Sep 12, 2019
ab4bd75
Add more to tests
gussmith23 Oct 2, 2019
a20c15c
Formatting
gussmith23 Oct 17, 2019
6008895
Uncomment add
gussmith23 Oct 9, 2019
7fa8275
Remove bad tests
gussmith23 Oct 9, 2019
ca27fbe
Change comments
gussmith23 Oct 9, 2019
40378b8
Change function name and docstring
gussmith23 Oct 9, 2019
0ed63f7
Change main function
gussmith23 Oct 9, 2019
f47b541
Restructure tests
gussmith23 Oct 9, 2019
190407e
Fix visibility of posit functions
gussmith23 Oct 9, 2019
2e17add
YAPF
gussmith23 Nov 14, 2019
8f26fce
Switching keywords around to resolve build errors on some systems
gussmith23 Dec 28, 2019
73ea71b
Improve test by running smaller mobilenet
gussmith23 Jan 14, 2020
545b80b
Add test_cast
gussmith23 Jan 15, 2020
134e597
Change datatype name; add simple test
gussmith23 Jan 31, 2020
27edbd0
Rename to posit32
gussmith23 Nov 20, 2019
899ce54
Merge 3 posit types into one file
gussmith23 Nov 20, 2019
26f4815
Add a nop type
gussmith23 Nov 20, 2019
cf4f1db
Remove bfloat
gussmith23 Nov 20, 2019
4e9b618
Refactor test comments
gussmith23 Jun 15, 2020
a8d10b0
Refactor conv2d test
gussmith23 Jun 15, 2020
442e4f5
Add optional tolerance arguments
gussmith23 Nov 20, 2019
660714e
Add posit8 and posit16
gussmith23 Nov 20, 2019
da22056
Add comment about posit8
gussmith23 Nov 20, 2019
20e3a7c
Whoops -- actually add noptype to CMakeLists
gussmith23 Nov 20, 2019
21e79b2
Add rtol, atol to run_workload
gussmith23 Jun 15, 2020
23b9d16
Add noptype to tests
gussmith23 Nov 20, 2019
d9db34b
Run noptype over other models, too
gussmith23 Nov 20, 2019
7335f1b
Pass correct arguments to calls
gussmith23 Jun 15, 2020
8fe5d27
Fix line length errors
gussmith23 Jun 15, 2020
fc82c57
Raise tolerances (again) to avoid flaky test
gussmith23 Jun 15, 2020
6e102f9
fix style
hypercubestart Jul 23, 2020
1312648
add test for tanh, log, sigmoid
hypercubestart Jul 25, 2020
08f86d0
Remove references to bfloat, notbfloat
gussmith23 Jun 15, 2020
e396fa7
Change comments
gussmith23 Jul 29, 2020
b3d25a8
Remove old test file
gussmith23 Jul 29, 2020
098e2d5
fix min func
hypercubestart Aug 1, 2020
b9afc23
refactoring unit test file
hypercubestart Aug 1, 2020
f225add
use posits es2
hypercubestart Aug 2, 2020
35742f8
cleanup
hypercubestart Aug 2, 2020
ce02836
comment
hypercubestart Aug 2, 2020
f855fa2
coment if_then_else
hypercubestart Aug 6, 2020
ce533ca
support different bit widths
hypercubestart Aug 7, 2020
bbe7a34
use random seed to create stable tests
hypercubestart Aug 7, 2020
4da49fc
update documentation
hypercubestart Aug 7, 2020
460d713
removed nop-type and code consistency
hypercubestart Aug 13, 2020
e14913b
add batchnorm test
hypercubestart Aug 15, 2020
2d43218
rebase and update
hypercubestart Aug 16, 2020
eb24a6a
fix tests and format
hypercubestart Aug 16, 2020
9501e55
pylint
hypercubestart Aug 16, 2020
640e745
change order of include
hypercubestart Aug 16, 2020
37a1540
include order
hypercubestart Aug 17, 2020
946902f
fix style
hypercubestart Aug 17, 2020
134fc52
remove posit c linkage
hypercubestart Aug 17, 2020
d97766d
update universal
hypercubestart Aug 18, 2020
28466ba
fix style
hypercubestart Aug 18, 2020
8de1844
fix test
hypercubestart Aug 18, 2020
99a5cda
fix overflow error with minfunc and posits
hypercubestart Aug 19, 2020
ab0235d
style
hypercubestart Aug 19, 2020
f58e263
use change_dtype to convert params
hypercubestart Aug 21, 2020
4189fdc
update universal
hypercubestart Aug 22, 2020
e136658
fix fatal error
hypercubestart Aug 22, 2020
3f90742
fix constant repr
hypercubestart Aug 22, 2020
7e2047e
minor update to posites2
hypercubestart Aug 23, 2020
ee640d5
update universal
hypercubestart Aug 23, 2020
8d49900
fix rst
hypercubestart Aug 23, 2020
d5c3d71
fix invalid import and sqrt
hypercubestart Aug 23, 2020
f543c80
update universal
hypercubestart Aug 23, 2020
5b4f126
comments
hypercubestart Aug 24, 2020
e9a6c44
comments and expand testing
hypercubestart Aug 25, 2020
34b762d
increase atol/rtol for custom[posites2]32
hypercubestart Aug 25, 2020
6231cb3
Re-add newline
gussmith23 Aug 19, 2020
f57c037
Remove comment
gussmith23 Aug 19, 2020
65c59eb
Remove opt level and comment
gussmith23 Aug 19, 2020
42501be
Change docstring
gussmith23 Aug 19, 2020
a1960d0
Add TODO
gussmith23 Aug 25, 2020
b30e08c
Add file header and newline
gussmith23 Aug 26, 2020
a00957c
Update docstring
gussmith23 Aug 26, 2020
c9920fc
Update file docstring
gussmith23 Aug 26, 2020
3b2fa03
Update docstrings
gussmith23 Aug 26, 2020
8aa7c7b
Delete todos
gussmith23 Aug 26, 2020
9a11027
create_min_lower_func
hypercubestart Aug 27, 2020
b3d3af3
add better debugging message
hypercubestart Aug 27, 2020
5b501c4
docs
hypercubestart Aug 27, 2020
cc3d6cc
add BYODT tutorial
hypercubestart Sep 1, 2020
f683ff6
add todo
hypercubestart Sep 1, 2020
00f87a2
Reformat some of tutorial to RST, plus code fixes
gussmith23 Sep 3, 2020
36443bd
tutorial notebook runs now
hypercubestart Sep 3, 2020
a957d4d
fix hyperlink
hypercubestart Sep 3, 2020
c940fc0
rebase
hypercubestart Sep 3, 2020
7030a81
add to tutorial
hypercubestart Sep 3, 2020
5d4b119
fix mobilenet model
hypercubestart Sep 4, 2020
1aaf723
add skip tag
hypercubestart Sep 4, 2020
ff1a87d
black lint
hypercubestart Sep 14, 2020
515746d
add compiler flag and add dummy float
hypercubestart Sep 17, 2020
33084fe
myfloat and posites2 test
hypercubestart Sep 17, 2020
d3e9168
remove universal
hypercubestart Sep 17, 2020
25850a3
lint
hypercubestart Sep 17, 2020
2c34863
lint
hypercubestart Sep 18, 2020
6998ab7
add setup
hypercubestart Sep 18, 2020
3b9fff2
build with USE_POSIT for CI/CD
hypercubestart Sep 18, 2020
e2898fe
fix posit cmake
hypercubestart Sep 18, 2020
f96c95e
add cd /
hypercubestart Sep 18, 2020
baa453b
undo docker changes
hypercubestart Sep 19, 2020
30b8b6e
change tutorial to use myfloat
hypercubestart Sep 19, 2020
142a055
move files
hypercubestart Sep 21, 2020
21b7da9
lint
hypercubestart Sep 21, 2020
eba7389
fix
hypercubestart Sep 21, 2020
47fde5e
remove filter
hypercubestart Sep 21, 2020
3967ed9
fix lint
hypercubestart Sep 22, 2020
ccdc65b
fix suggestions
hypercubestart Sep 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 0 additions & 84 deletions 3rdparty/bfloat16/bfloat16.cc

This file was deleted.

5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ tvm_option(COMPILER_RT_PATH "Path to COMPILER-RT" "3rdparty/compiler-rt")
tvm_option(PICOJSON_PATH "Path to PicoJSON" "3rdparty/picojson")

# Contrib library options
tvm_option(USE_BYOC_POSIT "Build with BYOC software emulated posit custom datatype" OFF)
tvm_option(USE_BLAS "The blas library to be linked" none)
tvm_option(USE_MKL "MKL root path when use MKL blas" OFF)
tvm_option(USE_MKLDNN "Build with MKLDNN" OFF)
Expand Down Expand Up @@ -257,6 +258,7 @@ endif(USE_VM_PROFILER)

file(GLOB DATATYPE_SRCS src/target/datatype/*.cc)
list(APPEND COMPILER_SRCS ${DATATYPE_SRCS})
list(APPEND COMPILER_SRCS "src/target/datatype/myfloat/myfloat.cc")

file(GLOB RUNTIME_SRCS
src/runtime/*.cc
Expand All @@ -279,8 +281,6 @@ if (INDEX_DEFAULT_I64)
add_definitions(-DTVM_INDEX_DEFAULT_I64=1)
endif()

list(APPEND RUNTIME_SRCS 3rdparty/bfloat16/bfloat16.cc)

if(USE_RPC)
message(STATUS "Build with RPC support...")
file(GLOB RUNTIME_RPC_SRCS src/runtime/rpc/*.cc)
Expand Down Expand Up @@ -334,6 +334,7 @@ include(cmake/modules/contrib/BLAS.cmake)
include(cmake/modules/contrib/CODEGENC.cmake)
include(cmake/modules/contrib/DNNL.cmake)
include(cmake/modules/contrib/Random.cmake)
include(cmake/modules/contrib/Posit.cmake)
include(cmake/modules/contrib/MicroStandaloneRuntime.cmake)
include(cmake/modules/contrib/Sort.cmake)
include(cmake/modules/contrib/NNPack.cmake)
Expand Down
1 change: 0 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ for text of these licenses.
Apache Software Foundation License 2.0
--------------------------------------

3rdparty/bfloat16/bfloat16.cc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3rdparty/dlpack
3rdparty/dmlc-core

Expand Down
3 changes: 3 additions & 0 deletions cmake/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ set(USE_LLVM OFF)
#---------------------------------------------
# Contrib libraries
#---------------------------------------------
# Whether to build with BYOC software emulated posit custom datatype
set(USE_BYOC_POSIT OFF)

# Whether use BLAS, choices: openblas, atlas, apple
set(USE_BLAS none)

Expand Down
1 change: 1 addition & 0 deletions cmake/modules/LibInfo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function(add_lib_info src_file)
TVM_INFO_HIDE_PRIVATE_SYMBOLS="${HIDE_PRIVATE_SYMBOLS}"
TVM_INFO_USE_TF_TVMDSOOP="${USE_TF_TVMDSOOP}"
TVM_INFO_USE_FALLBACK_STL_MAP="${USE_FALLBACK_STL_MAP}"
TVM_INFO_USE_BYOC_POSIT="${USE_BYOC_POSIT}"
TVM_INFO_USE_BLAS="${USE_BLAS}"
TVM_INFO_USE_MKL="${USE_MKL}"
TVM_INFO_USE_MKLDNN="${USE_MKLDNN}"
Expand Down
26 changes: 26 additions & 0 deletions cmake/modules/contrib/Posit.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

if(USE_BYOC_POSIT)
message(STATUS "Build with contrib.posit")
if (NOT UNIVERSAL_PATH)
message(FATAL_ERROR "Fail to get Universal path")
endif(NOT UNIVERSAL_PATH)

include_directories(${UNIVERSAL_PATH}/include)
list(APPEND COMPILER_SRCS "src/target/datatype/posit/posit-wrapper.cc")
endif(USE_BYOC_POSIT)
9 changes: 0 additions & 9 deletions licenses/LICENSE.bfloat16.txt

This file was deleted.

2 changes: 2 additions & 0 deletions python/tvm/driver/build_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ def _build_for_device(input_mod, target, target_host):
tvm.tir.transform.LowerWarpMemory(),
tvm.tir.transform.Simplify(),
tvm.tir.transform.LowerDeviceStorageAccessInfo(),
tvm.tir.transform.LowerCustomDatatypes(),
tvm.tir.transform.LowerIntrin(),
]
)
Expand All @@ -279,6 +280,7 @@ def _build_for_device(input_mod, target, target_host):
tvm.tir.transform.Apply(lambda f: f.with_attr("target", target)),
tvm.tir.transform.LowerTVMBuiltin(),
tvm.tir.transform.LowerDeviceStorageAccessInfo(),
tvm.tir.transform.LowerCustomDatatypes(),
tvm.tir.transform.LowerIntrin(),
tvm.tir.transform.CombineContextCall(),
]
Expand Down
3 changes: 3 additions & 0 deletions python/tvm/relay/backend/_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ def _tensor_value_repr(tvalue):

@tvm._ffi.register_func("relay._constant_repr")
def _tensor_constant_repr(tvalue):
dtype = tvm.runtime.DataType(tvalue.data.dtype)
if tvm.target.datatype.get_type_registered(dtype.type_code):
return "custom tensor of type " + dtype.type_code
return str(tvalue.data.asnumpy())


Expand Down
1 change: 1 addition & 0 deletions python/tvm/relay/frontend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@
from .darknet import from_darknet
from .pytorch import from_pytorch
from .caffe import from_caffe
from .change_datatype import ChangeDatatype
107 changes: 107 additions & 0 deletions python/tvm/relay/frontend/change_datatype.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=unused-argument
"""Change Datatype Pass"""
from ..function import Function
from ..expr_functor import ExprMutator
from ..transform.transform import function_pass
from ..expr import var, bind


@function_pass(opt_level=0)
class ChangeDatatype(ExprMutator):
"""Mutator for changing the datatype of Relay programs.

This pass should be useful for users of the Bring Your Own Datatypes
framework.
TODO(@gussmith23 @hypercubestart) Add link to documentation when it exists

Example:

.. code-block:: python

from tvm.relay.testing.inception_v3 import get_workload
mod, params = get_workload()

def change_dtype(mod, params, src, dst):
mod = ChangeDatatype(src, dst)(mod)
params = dict((p, tvm.nd.array(params[p].asnumpy().astype(dst))) for p in params)
return mod, params

mod, params = change_dtype(mod, params, "float32", "custom[posites2]32")

Parameters
----------
src : String
The source datatype name, e.g. "float" or "posites2" (but not "float32"
or "custom[posites2]32").
dst : String
The destination datatype name, in the same format.

Returns
-------
mod : tvm.IRModule
Module where all nodes of dtype `src` have been changed to have dtype
`dst`.
"""

def __init__(self, src, dst):
self.src = src
self.dst = dst
super().__init__()

def transform_function(self, func, mod, ctx):
return self.visit(func)

def visit_constant(self, const):
if const.data.dtype == self.src:
return const.astype(self.dst)
return const

def visit_function(self, fn):
new_params = []
binds = {}

for param in fn.params:
# Get the parameter's type annotation.
var_type = param.type_annotation

# See if we want to replace dtype.
if var_type.dtype == self.src:
dtype = self.dst
else:
dtype = var_type.dtype

# Generate new variable.
new_param = var(param.name_hint, shape=var_type.shape, dtype=dtype)

new_params.append(new_param)
binds[param] = new_param

new_body = self.visit(fn.body)
# Rewrite the body to use new parameters.
new_body = bind(new_body, binds)

# Construct the updated function and return.
return Function(
new_params,
new_body,
# You could change the return type, if you use None it will re-infer.
None,
type_params=fn.type_params,
attrs=fn.attrs,
)
Loading