Skip to content

Commit

Permalink
Merge branch 'main' into single_module_during_build_pr_14985
Browse files Browse the repository at this point in the history
  • Loading branch information
Lunderberg committed May 7, 2024
2 parents 136a459 + 819b002 commit 25a5de0
Show file tree
Hide file tree
Showing 313 changed files with 13,698 additions and 3,809 deletions.
12 changes: 6 additions & 6 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
runs:
using: "composite"
steps:
- uses: actions/cache@v1
- uses: actions/cache@v3
env:
CACHE_NUMBER: 0
CACHE_NUMBER: 1
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('conda/build-environment.yaml') }}
- uses: conda-incubator/setup-miniconda@v2
- uses: conda-incubator/setup-miniconda@v3
continue-on-error: true
id: conda1
with:
Expand All @@ -16,17 +16,17 @@ runs:
environment-file: conda/build-environment.yaml
auto-activate-base: false
use-only-tar-bz2: true
python-version: 3.7
python-version: 3.9
condarc-file: conda/condarc
- uses: conda-incubator/setup-miniconda@v2
- uses: conda-incubator/setup-miniconda@v3
if: steps.conda1.outcome == 'failure'
with:
activate-environment: tvm-build
channel-priority: strict
environment-file: conda/build-environment.yaml
auto-activate-base: false
use-only-tar-bz2: true
python-version: 3.7
python-version: 3.9
condarc-file: conda/condarc
- name: Conda info
shell: pwsh
Expand Down
18 changes: 10 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,17 @@ jobs:
- name: Minimal Metal Compile-and-Run
shell: bash -l {0}
run: >-
python -m pytest -v -s 'tests/python/codegen/test_target_codegen_metal.py'
python -m pytest -v -s 'tests/python/codegen/test_target_codegen_gpu_common.py'
python -m pytest -v -s 'tests/python/codegen/test_gpu_codegen_allreduce.py::test_allreduce_sum[dims0-metal]'
- name: Test iOS RPC
shell: bash -l {0}
run: >-
python -m pip install tornado psutil cloudpickle &&
export PYTHONPATH=tests/python/contrib:${PYTHONPATH} &&
export BUNDLE_ID=org.apache.tvmrpc &&
export BUNDLE_PATH=build-ios-simulator/apps/ios_rpc/ios_rpc/src/ios_rpc-build/Release-iphonesimulator/tvmrpc.app &&
python -m pytest -v tests/python/contrib/test_rpc_server_device.py
# - name: Test iOS RPC
# shell: bash -l {0}
# run: >-
# python -m pip install tornado psutil cloudpickle &&
# export PYTHONPATH=tests/python/contrib:${PYTHONPATH} &&
# export BUNDLE_ID=org.apache.tvmrpc &&
# export BUNDLE_PATH=build-ios-simulator/apps/ios_rpc/ios_rpc/src/ios_rpc-build/Release-iphonesimulator/tvmrpc.app &&
# python -m pytest -v tests/python/contrib/test_rpc_server_device.py

Windows:
if: ${{ github.repository == 'apache/tvm' }}
Expand Down
102 changes: 102 additions & 0 deletions 3rdparty/picojson/picojson.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,21 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once

#ifndef PICOJSON_USE_INT64
#define PICOJSON_USE_INT64
#define __STDC_FORMAT_MACROS 1
#endif

// If PICOJSON_USE_ORDERED_OBJECT is set, picojson uses object_with_ordered_keys, which maintains
// the insertion order of keys, i.e. the order of keys in the json string.
// This macro is set by default.
#ifndef PICOJSON_USE_ORDERED_OBJECT
#define PICOJSON_USE_ORDERED_OBJECT 1
#endif

#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
Expand Down Expand Up @@ -137,10 +146,17 @@ enum { INDENT_WIDTH = 2 };

struct null {};

class object_with_ordered_keys;

class value {
public:
typedef std::vector<value> array;
#ifdef PICOJSON_USE_ORDERED_OBJECT
typedef object_with_ordered_keys object;
#else
typedef std::unordered_map<std::string, value> object;
#endif

union _storage {
bool boolean_;
double number_;
Expand Down Expand Up @@ -220,6 +236,92 @@ class value {
void clear();
};

// The ordered version of hashmap. It has the same interface as std::unordered_map, but provides
// ordered_keys() to return the keys in the order they were inserted.
class object_with_ordered_keys : private std::unordered_map<std::string, value> {
public:
using typename std::unordered_map<std::string, value>::value_type;
using typename std::unordered_map<std::string, value>::iterator;
using typename std::unordered_map<std::string, value>::const_iterator;

object_with_ordered_keys() = default;
object_with_ordered_keys(const object_with_ordered_keys&) = default;
object_with_ordered_keys(object_with_ordered_keys&&) = default;
object_with_ordered_keys(std::initializer_list<value_type> init)
: std::unordered_map<std::string, value>(init) {
for (const auto& pair : init) {
ordered_keys_.push_back(pair.first);
}
}
object_with_ordered_keys& operator=(const object_with_ordered_keys&) = default;
object_with_ordered_keys& operator=(object_with_ordered_keys&&) = default;

using std::unordered_map<std::string, value>::begin;
using std::unordered_map<std::string, value>::end;
using std::unordered_map<std::string, value>::cbegin;
using std::unordered_map<std::string, value>::cend;
using std::unordered_map<std::string, value>::empty;
using std::unordered_map<std::string, value>::size;
using std::unordered_map<std::string, value>::at;
using std::unordered_map<std::string, value>::count;
using std::unordered_map<std::string, value>::find;

value& operator[](const std::string& key) {
if (count(key) == 0) {
ordered_keys_.push_back(key);
}
return std::unordered_map<std::string, value>::operator[](key);
}

void clear() {
std::unordered_map<std::string, value>::clear();
ordered_keys_.clear();
}

std::pair<iterator, bool> insert(const value_type& kv) {
if (!count(kv.first)) {
ordered_keys_.push_back(kv.first);
}
return std::unordered_map<std::string, value>::insert(kv);
}

template <class... Args>
std::pair<iterator, bool> emplace(Args&&... args) {
return insert(value_type(std::forward<Args>(args)...));
}

iterator erase(const_iterator it) {
ordered_keys_.erase(std::find(ordered_keys_.begin(), ordered_keys_.end(), it->first));
return std::unordered_map<std::string, value>::erase(it);
}

iterator erase(iterator it) {
ordered_keys_.erase(std::find(ordered_keys_.begin(), ordered_keys_.end(), it->first));
return std::unordered_map<std::string, value>::erase(it);
}

size_t erase(const std::string& key) {
if (std::unordered_map<std::string, value>::erase(key)) {
ordered_keys_.erase(std::find(ordered_keys_.begin(), ordered_keys_.end(), key));
return 1;
} else {
return 0;
}
}

const std::vector<std::string>& ordered_keys() const { return ordered_keys_; }

friend bool operator==(const object_with_ordered_keys& lhs, const object_with_ordered_keys& rhs);

private:
std::vector<std::string> ordered_keys_;
};

inline bool operator==(const object_with_ordered_keys& lhs, const object_with_ordered_keys& rhs) {
return static_cast<const std::unordered_map<std::string, value>&>(lhs) ==
static_cast<const std::unordered_map<std::string, value>&>(rhs);
}

typedef value::array array;
typedef value::object object;

Expand Down
65 changes: 65 additions & 0 deletions 3rdparty/picojson/test_picojson.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* 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.
*/
#include <cassert>
#include <sstream>

#include "picojson.h"

using picojson::object_with_ordered_keys;

void test_constructor() {
object_with_ordered_keys obj;
obj["foo"] = picojson::value(true);
assert((obj.ordered_keys() == std::vector<std::string>{"foo"}));

object_with_ordered_keys obj1{{"foo", picojson::value(true)}, {"bar", picojson::value(false)}};
assert((obj1.ordered_keys() == std::vector<std::string>{"foo", "bar"}));

object_with_ordered_keys obj2(obj1);
assert((obj2.ordered_keys() == std::vector<std::string>{"foo", "bar"}));

object_with_ordered_keys obj3(std::move(obj2));
assert((obj3.ordered_keys() == std::vector<std::string>{"foo", "bar"}));

obj = obj3;
assert((obj.ordered_keys() == std::vector<std::string>{"foo", "bar"}));
}

void test_modifier() {
object_with_ordered_keys obj{{"foo", picojson::value(true)}, {"bar", picojson::value(false)}};
obj.insert({"abc", picojson::value(false)});
assert((obj.ordered_keys() == std::vector<std::string>{"foo", "bar", "abc"}));
obj.emplace("def", picojson::value(true));
assert((obj.ordered_keys() == std::vector<std::string>{"foo", "bar", "abc", "def"}));
obj.insert({"abc", picojson::value(true)});
assert((obj.ordered_keys() == std::vector<std::string>{"foo", "bar", "abc", "def"}));
auto it = obj.find("abc");
it = obj.erase(it);
assert((obj.ordered_keys() == std::vector<std::string>{"foo", "bar", "def"}));
obj.erase("foo");
assert((obj.ordered_keys() == std::vector<std::string>{"bar", "def"}));
obj.clear();
assert((obj.ordered_keys() == std::vector<std::string>{}));
}

int main() {
test_constructor();
test_modifier();
return 0;
}
16 changes: 11 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ endif()
# Alernatively, use cmake -DOPTION=VALUE through command-line.
tvm_option(USE_CUDA "Build with CUDA" OFF)
tvm_option(USE_NCCL "Build with NCCL" OFF)
tvm_option(USE_MSCCL "Build with MSCCL" OFF)
tvm_option(USE_OPENCL "Build with OpenCL" OFF)
tvm_option(USE_OPENCL_ENABLE_HOST_PTR "Enable OpenCL memory object access to host" OFF)
tvm_option(USE_OPENCL_GTEST "Path to OpenCL specific gtest version for runtime cpp tests." /path/to/opencl/gtest)
Expand Down Expand Up @@ -63,6 +64,7 @@ tvm_option(USE_PROFILER "Build profiler for the VM and graph executor" ON)
tvm_option(USE_OPENMP "Build with OpenMP thread pool implementation" OFF)
tvm_option(USE_RELAY_DEBUG "Building Relay in debug mode..." OFF)
tvm_option(TVM_DEBUG_WITH_ABI_CHANGE "Enable debug code that may cause ABI changes" OFF)
tvm_option(TVM_LOG_BEFORE_THROW "Whether log before throw, for debugging purposes" OFF)
tvm_option(USE_RTTI "Build with RTTI" ON)
tvm_option(USE_MSVC_MT "Build with MT" OFF)
tvm_option(USE_MICRO "Build with Micro TVM support" OFF)
Expand Down Expand Up @@ -154,16 +156,20 @@ if(NOT IS_SUBPROJECT AND NOT DEFINED "${CMAKE_EXPORT_COMPILE_COMMANDS}")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
endif()

if(TVM_LOG_BEFORE_THROW)
# log error before throw as
# when system have issues with stack trace
add_definitions(-DDMLC_LOG_BEFORE_THROW=1)
endif()

# Generic compilation options
if(MSVC)
add_definitions(-DWIN32_LEAN_AND_MEAN)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
add_definitions(-D_ENABLE_EXTENDED_ALIGNED_STORAGE)
add_definitions(-DNOMINMAX)
# log error before throw as usually windows
# may have issues with stack trace
add_definitions(-DDMLC_LOG_BEFORE_THROW=1)

# regeneration does not work well with msbuild custom rules.
set(CMAKE_SUPPRESS_REGENERATION ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
Expand Down Expand Up @@ -940,8 +946,8 @@ endif()

if(USE_CUDA AND USE_NCCL)
find_library(LIBRT rt)
target_link_libraries(tvm PRIVATE nccl msccl ${LIBRT})
target_link_libraries(tvm_runtime PRIVATE nccl msccl ${LIBRT})
target_link_libraries(tvm PRIVATE nccl ${LIBRT})
target_link_libraries(tvm_runtime PRIVATE nccl ${LIBRT})
endif()

if(USE_ROCM AND USE_RCCL)
Expand Down
3 changes: 1 addition & 2 deletions apps/ios_rpc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ if (NOT XCBUILD_AVAILABLE EQUAL 0)
return()
endif()


# External project with custom mach-o dynamic loader
# It is required to load unsigned shared modules on real iOS devices
ExternalProject_Add(custom_dso_loader
GIT_REPOSITORY https://github.com/octoml/macho-dyld.git
GIT_TAG 0742b8129de7df1130be355b74faa8c036265bfc
GIT_TAG d1f7032e7882bc060b49a4fb058f50a23668b074
PREFIX custom_dso_loader
LOG_DOWNLOAD TRUE
LOG_CONFIGURE TRUE
Expand Down
20 changes: 10 additions & 10 deletions ci/jenkins/docker-images.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

# This data file is read during when Jenkins runs job to determine docker images.
[jenkins]
ci_arm: tlcpack/ci-arm:20240126-070121-8ade9c30e
ci_cortexm: tlcpack/ci-cortexm:20240126-070121-8ade9c30e
ci_cpu: tlcpack/ci_cpu:20240322-060059-89cd74c07
ci_gpu: tlcpack/ci-gpu:20240126-070121-8ade9c30e
ci_hexagon: tlcpack/ci-hexagon:20240126-070121-8ade9c30e
ci_i386: tlcpack/ci-i386:20240126-070121-8ade9c30e
ci_lint: tlcpack/ci-lint:20240126-070121-8ade9c30e
ci_minimal: tlcpack/ci-minimal:20240126-070121-8ade9c30e
ci_riscv: tlcpack/ci-riscv:20240126-070121-8ade9c30e
ci_wasm: tlcpack/ci-wasm:20240126-070121-8ade9c30e
ci_arm: tlcpack/ci-arm:20240428-060115-0b09ed018
ci_cortexm: tlcpack/ci-cortexm:20240428-060115-0b09ed018
ci_cpu: tlcpack/ci_cpu:20240428-060115-0b09ed018
ci_gpu: tlcpack/ci-gpu:20240428-060115-0b09ed018
ci_hexagon: tlcpack/ci-hexagon:20240428-060115-0b09ed018
ci_i386: tlcpack/ci-i386:20240428-060115-0b09ed018
ci_lint: tlcpack/ci-lint:20240428-060115-0b09ed018
ci_minimal: tlcpack/ci-minimal:20240428-060115-0b09ed018
ci_riscv: tlcpack/ci-riscv:20240428-060115-0b09ed018
ci_wasm: tlcpack/ci-wasm:20240428-060115-0b09ed018
5 changes: 5 additions & 0 deletions cmake/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ set(USE_CUDA OFF)
# - /path/to/nccl: use specific path to nccl
set(USE_NCCL OFF)

# Whether to enable MSCCL support:
# - ON: enable MSCCL
# - OFF: disable MSCCL
set(USE_MSCCL OFF)

# Whether to enable NVTX support (must have USE_CUDA enabled):
# - ON: enable NCCL with cmake's auto search
# - OFF: disable NCCL
Expand Down
1 change: 1 addition & 0 deletions cmake/modules/LLVM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ if(NOT ${USE_LLVM} MATCHES ${IS_FALSE_PATTERN})
if (${TVM_MLIR_VERSION})
add_definitions(-DTVM_MLIR_VERSION=${TVM_MLIR_VERSION})
endif()
add_definitions(-DTVM_LLVM_HAS_AARCH64_TARGET=${TVM_LLVM_HAS_AARCH64_TARGET})
tvm_file_glob(GLOB COMPILER_LLVM_SRCS src/target/llvm/*.cc)
list(APPEND TVM_LINKER_LIBS ${LLVM_LIBS})
list(APPEND COMPILER_SRCS ${COMPILER_LLVM_SRCS})
Expand Down
2 changes: 2 additions & 0 deletions cmake/modules/LibInfo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ function(add_lib_info src_file)
TVM_INFO_USE_CUDA="${USE_CUDA}"
TVM_INFO_USE_NVTX="${USE_NVTX}"
TVM_INFO_USE_NCCL="${USE_NCCL}"
TVM_INFO_USE_MSCCL="${USE_MSCCL}"
TVM_INFO_USE_CUDNN="${USE_CUDNN}"
TVM_INFO_USE_CUSTOM_LOGGING="${USE_CUSTOM_LOGGING}"
TVM_INFO_USE_CUTLASS="${USE_CUTLASS}"
Expand Down Expand Up @@ -113,6 +114,7 @@ function(add_lib_info src_file)
TVM_INFO_USE_RANDOM="${USE_RANDOM}"
TVM_INFO_USE_RELAY_DEBUG="${USE_RELAY_DEBUG}"
TVM_INFO_TVM_DEBUG_WITH_ABI_CHANGE="${TVM_DEBUG_WITH_ABI_CHANGE}"
TVM_INFO_TVM_LOG_BEFORE_THROW="${TVM_LOG_BEFORE_THROW}"
TVM_INFO_USE_ROCBLAS="${USE_ROCBLAS}"
TVM_INFO_USE_ROCM="${USE_ROCM}"
TVM_INFO_USE_RCCL="${USE_RCCL}"
Expand Down
Loading

0 comments on commit 25a5de0

Please sign in to comment.