__init__.py 2.18 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
# 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.
17
# pylint: disable=redefined-builtin, wildcard-import
18
"""TVM: Open Deep Learning Compiler Stack."""
19 20 21 22
import multiprocessing
import sys
import traceback

23 24
# top-level alias
# tvm._ffi
25
from ._ffi.base import TVMError, __version__
26
from ._ffi.runtime_ctypes import TypeCode, DataType
27
from ._ffi import register_object, register_func, register_extension, get_global_func
28

29 30 31 32 33 34 35
# top-level alias
# tvm.runtime
from .runtime.object import Object
from .runtime.ndarray import context, cpu, gpu, opencl, cl, vulkan, metal, mtl
from .runtime.ndarray import vpi, rocm, opengl, ext_dev, micro_dev
from .runtime import ndarray as nd

36 37 38
# tvm.error
from . import error

39 40 41 42 43 44
# tvm.ir
from .ir import IRModule
from .ir import transform
from .ir import container
from . import ir

45 46 47 48 49 50
# tvm.tir
from . import tir

# tvm.target
from . import target

51
# tvm.te
52
from . import te
53 54

# tvm.testing
55
from . import testing
56

57 58 59 60 61 62 63 64
# tvm.driver
from .driver import build, lower

# tvm.hybrid
from . import hybrid

# others
from . import arith
65 66

# Contrib initializers
67
from .contrib import rocm as _rocm, nvcc as _nvcc, sdaccel as _sdaccel
68 69 70 71 72 73 74 75 76 77

# Clean subprocesses when TVM is interrupted
def tvm_excepthook(exctype, value, trbk):
    print('\n'.join(traceback.format_exception(exctype, value, trbk)))
    if hasattr(multiprocessing, 'active_children'):
        # pylint: disable=not-callable
        for p in multiprocessing.active_children():
            p.terminate()

sys.excepthook = tvm_excepthook