Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

1 (#6) #7

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 21 additions & 0 deletions .azurepipeline/ci-track_github_tvm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
schedules:
- cron: "0 0 * * *"
displayName: Daily midnight check
branches:
include:
- main

pool:
vmImage: ubuntu-latest

steps:
- script: |
git config --global user.email "nnfusion_team@microsoft.com"
git config --global user.name "NNFusion team"
git config pull.rebase false
git checkout origin main
git checkout main
git remote add tvm https://github.com/apache/tvm.git
git pull tvm main
git push https://${PAT}:PAT@dev.azure.com/TensorStar/TensorStar/_git/tvm main
displayName: 'Add apache/tvm as new origin'
20 changes: 20 additions & 0 deletions .azurepipeline/ci-windows_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
trigger:
- develop

pool: Default

steps:
- checkout: self
submodules: true
persistCredentials: true
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
F:\tool\vcpkg\vcpkg.exe install gtest:x64-windows
- task: CMake@1
inputs:
cmakeArgs: '.. -DUSE_DIRECTX=ON -DCMAKE_TOOLCHAIN_FILE="F:/tool/vcpkg/scripts/buildsystems/vcpkg.cmake"'
- task: CMake@1
inputs:
cmakeArgs: '--build . -j'
52 changes: 52 additions & 0 deletions .github/workflows/directx_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Build TVM with DirectX support

on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
VCPKG_EXE_PATH: F:\tool\vcpkg\vcpkg.exe
VCPKG_CMAKE_PATH: "F:/tool/vcpkg/scripts/buildsystems/vcpkg.cmake"
VSDEVCMD: C:/\"Program Files\"/\"Microsoft Visual Studio\"/2022/Enterprise/Common7/Tools/VsDevCmd.bat

jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: [self-hosted, Windows, X64]

steps:
- uses: actions/checkout@v2
with:
submodules: 'true'

- name: VCPKG install Gtest
shell: cmd
run: ${{env.VCPKG_EXE_PATH}} install gtest:x64-windows

- name: Configure CMake
shell: cmd
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >-
${{env.VSDEVCMD}} &&
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DUSE_DIRECTX=ON -DCMAKE_TOOLCHAIN_FILE=${{env.VCPKG_CMAKE_PATH}}

- name: Build
shell: cmd
# Build your program with the given configuration
run: >-
${{env.VSDEVCMD}} &&
cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- name: Test
shell: cmd
# Build your program with the given configuration
run: >-
${{env.VSDEVCMD}} &&
${{github.workspace}}/build/${{env.BUILD_TYPE}}/dx_test.exe
37 changes: 37 additions & 0 deletions .github/workflows/track_tvm_github.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Track latest TVM commit from Github

on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]
schedule:
- cron: '36 6 * * *'

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: git-mirror-action
# You may pin to the exact commit or the version.
# uses: mathisve/git-mirror-action@0e26d87bd1420836e3b68767929c997565c7028f
uses: mathisve/git-mirror-action@v1.2
with:
# url of the repository you want to mirror
originalURL: https://github.com/apache/tvm.git
# branch in the original repository you want to mirror. Defaults to `master`
originalBranch: main
# url of the repository you want the mirror to go in
mirrorURL: https://github.com/nnfusion/tvm.git
# branch that will be created or pushed into. Defaults to `mirror`
mirrorBranch: main
# Base64 encoded Personal Access Token
pat: ${{ secrets.NNFUSION_PAT }}
# whether to use the `--force` argument when pushing to the mirror repository. Defaults to false
force: false
# whether or not you want the output to be verbose. Defaults to false
verbose: false
# whether or not you want to transfer tags. Defaults to false
tags: false

9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,12 @@
[submodule "3rdparty/cutlass"]
path = 3rdparty/cutlass
url = https://github.com/NVIDIA/cutlass
[submodule "3rdparty/DirectXShaderCompiler"]
path = 3rdparty/DirectXShaderCompiler
url = https://github.com/nnfusion/DirectXShaderCompiler
[submodule "3rdparty/DirectX-Headers"]
path = 3rdparty/DirectX-Headers
url = https://github.com/microsoft/DirectX-Headers.git
[submodule "3rdparty/DirectXTK12"]
path = 3rdparty/DirectXTK12
url = https://github.com/microsoft/DirectXTK12.git
1 change: 1 addition & 0 deletions 3rdparty/DirectX-Headers
Submodule DirectX-Headers added at 0644e7
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ tvm_option(USE_OPENCL "Build with OpenCL" OFF)
tvm_option(USE_VULKAN "Build with Vulkan" OFF)
tvm_option(USE_METAL "Build with Metal" OFF)
tvm_option(USE_ROCM "Build with ROCM" OFF)
tvm_option(USE_DIRECTX "Build with DIRECTX" ON)
tvm_option(ROCM_PATH "The path to rocm" /opt/rocm)
tvm_option(USE_HEXAGON_DEVICE "Build with Hexagon device support in TVM runtime" OFF)
tvm_option(USE_HEXAGON_SDK "Path to the Hexagon SDK root (required for Hexagon support in TVM runtime or for building TVM runtime for Hexagon)" /path/to/sdk)
Expand Down Expand Up @@ -64,6 +65,7 @@ tvm_option(DMLC_PATH "Path to DMLC" "3rdparty/dmlc-core/include")
tvm_option(RANG_PATH "Path to RANG" "3rdparty/rang/include")
tvm_option(COMPILER_RT_PATH "Path to COMPILER-RT" "3rdparty/compiler-rt")
tvm_option(PICOJSON_PATH "Path to PicoJSON" "3rdparty/picojson")
tvm_option(DIRECTX_HEADER_PATH "Path to DirectX headers" "3rdparty/DirectX-Headers/include")

# Contrib library options
tvm_option(USE_BYODT_POSIT "Build with BYODT software emulated posit custom datatype" OFF)
Expand Down Expand Up @@ -104,6 +106,7 @@ include_directories(SYSTEM ${DMLC_PATH})
include_directories(SYSTEM ${RANG_PATH})
include_directories(SYSTEM ${COMPILER_RT_PATH})
include_directories(SYSTEM ${PICOJSON_PATH})
include_directories(SYSTEM ${DIRECTX_HEADER_PATH})

# initial variables
set(TVM_LINKER_LIBS "")
Expand Down Expand Up @@ -268,6 +271,7 @@ tvm_file_glob(GLOB_RECURSE COMPILER_SRCS
tvm_file_glob(GLOB CODEGEN_SRCS
src/target/*.cc
src/target/source/*.cc
src/target/directx/*.cc
)

list(APPEND COMPILER_SRCS ${CODEGEN_SRCS})
Expand Down Expand Up @@ -436,6 +440,7 @@ include(cmake/modules/Arduino.cmake)
include(cmake/modules/CUDA.cmake)
include(cmake/modules/Hexagon.cmake)
include(cmake/modules/OpenCL.cmake)
include(cmake/modules/DirectX.cmake)
include(cmake/modules/OpenMP.cmake)
include(cmake/modules/Vulkan.cmake)
include(cmake/modules/Metal.cmake)
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
[Community](https://tvm.apache.org/community) |
[Release Notes](NEWS.md)

[![Build Status](https://ci.tlcpack.ai/buildStatus/icon?job=tvm/main)](https://ci.tlcpack.ai/job/tvm/job/main/)
[![WinMacBuild](https://github.com/apache/tvm/workflows/WinMacBuild/badge.svg)](https://github.com/apache/tvm/actions?query=workflow%3AWinMacBuild)
[![Build TVM with DirectX support](https://github.com/nnfusion/tvm/actions/workflows/directx_build.yml/badge.svg)](https://github.com/nnfusion/tvm/actions/workflows/directx_build.yml)
[![Track latest TVM commit from Github](https://github.com/nnfusion/tvm/actions/workflows/track_tvm_github.yml/badge.svg)](https://github.com/nnfusion/tvm/actions/workflows/track_tvm_github.yml)
[![WinMacBuild](https://github.com/nnfusion/tvm/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/nnfusion/tvm/actions/workflows/main.yml)

Apache TVM is a compiler stack for deep learning systems. It is designed to close the gap between the
productivity-focused deep learning frameworks, and the performance- and efficiency-focused hardware backends.
Expand Down
5 changes: 4 additions & 1 deletion cmake/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ set(USE_OPENCL OFF)
# Whether enable Metal runtime
set(USE_METAL OFF)

# Whether enable DirectX runtime
set(USE_DIRECTX OFF)

# Whether enable Vulkan runtime
#
# Possible values:
Expand All @@ -99,7 +102,7 @@ set(USE_IOS_RPC OFF)
# Whether embed stackvm into the runtime
set(USE_STACKVM_RUNTIME OFF)

# Whether enable tiny embedded graph executor.
# Whether enable tiny embedded graph executor.
set(USE_GRAPH_EXECUTOR ON)

# Whether enable tiny graph executor with CUDA Graph
Expand Down
32 changes: 32 additions & 0 deletions cmake/modules/DirectX.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# 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.

# DirectX Module

if(USE_DIRECTX)
message(STATUS "Build with DirectX support")
file(GLOB RUNTIME_DIRECTX_SRCS src/runtime/directx/*.cc)
list(APPEND RUNTIME_SRCS ${RUNTIME_DIRECTX_SRCS})
if(GTEST_FOUND)
file(GLOB RUNTIME_TEST_DIRECTX_SRCS src/runtime/directx/test/*.cc)
add_executable(dx_test ${RUNTIME_TEST_DIRECTX_SRCS})
target_link_libraries(dx_test tvm_libinfo_objs tvm_objs tvm_runtime_objs GTest::GTest GTest::Main)
gtest_discover_tests(dx_test)
endif()
else()
list(APPEND COMPILER_SRCS src/target/opt/build_directx_off.cc)
endif(USE_DIRECTX)
6 changes: 5 additions & 1 deletion include/tvm/runtime/c_runtime_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ typedef enum {
kOpenGL = 11,
kDLMicroDev = 13,
kDLHexagon = 14,
kDLWebGPU = 15
kDLWebGPU = 15,
kDLDirectX = 20,
kDLDirectXHost = 21,
kDLDirectXUpload = 22,
kDLDirectXReadback = 23,
// AddExtraTVMType which is not in DLPack here
} TVMDeviceExtType;

Expand Down
8 changes: 8 additions & 0 deletions include/tvm/runtime/device_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,14 @@ inline const char* DeviceName(int type) {
return "webgpu";
case kDLHexagon:
return "hexagon";
case kDLDirectXUpload:
return "directx_upload";
case kDLDirectX:
return "directx";
case kDLDirectXReadback:
return "directx_readback";
case kDLDirectXHost:
return "directx_host";
default:
LOG(FATAL) << "unknown type =" << type;
return "Unknown";
Expand Down
8 changes: 8 additions & 0 deletions python/tvm/_ffi/runtime_ctypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ class Device(ctypes.Structure):
12: "ext_dev",
14: "hexagon",
15: "webgpu",
20: "directx",
21: "directx_host",
22: "directx_upload",
23: "directx_readback",
}
STR2MASK = {
"llvm": 1,
Expand All @@ -232,6 +236,10 @@ class Device(ctypes.Structure):
"ext_dev": 12,
"hexagon": 14,
"webgpu": 15,
"directx": 20,
"directx_host": 21,
"directx_upload": 22,
"directx_readback": 23,
}

def __init__(self, device_type, device_id):
Expand Down
Loading