Unverified Commit 2077cd57 by Tianqi Chen Committed by GitHub

[CI] Recover Windows Mac Build CI via Github Actions (#4662)

* [RUNTIME] Fix windows build after the latest dso module change.

Switch to shared_ptr to get around a problem in latest MSVC.

* [CI] Add github action for win mac build.
parent b873e030
# 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.
# GH actions.
# We use it to cover windows and mac build
# Jenkins is still the primary CI
name: WinMacBuild
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
Build:
strategy:
matrix:
os: [windows-latest, macOS-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v1
- name: Initialize submodules
run: git submodule update --recursive --init
- name: Make Build Directory
run: cmake -E make_directory build.common
# configuration for Windows
- name: CMake@Win
if: matrix.os == 'windows-latest'
working-directory: build.common
run: >-
cmake
"-DUSE_SORT=ON"
"-DUSE_RPC=ON"
"-DUSE_GRAPH_RUNTIME=ON"
..
# configuration for Mac
- name: CMake@MacOS
if: matrix.os == 'macOS-latest'
working-directory: build.common
run: >-
cmake
"-DUSE_SORT=ON"
"-DUSE_RPC=ON"
"-DUSE_GRAPH_RUNTIME=ON"
"-DUSE_METAL=ON"
..
- name: Build
run: cmake --build build.common -j3
...@@ -114,12 +114,12 @@ class Module : public ObjectRef { ...@@ -114,12 +114,12 @@ class Module : public ObjectRef {
class TVM_DLL ModuleNode : public Object { class TVM_DLL ModuleNode : public Object {
public: public:
/*! \brief virtual destructor */ /*! \brief virtual destructor */
TVM_DLL virtual ~ModuleNode() {} virtual ~ModuleNode() {}
/*! /*!
* \return The per module type key. * \return The per module type key.
* \note This key is used to for serializing custom modules. * \note This key is used to for serializing custom modules.
*/ */
TVM_DLL virtual const char* type_key() const = 0; virtual const char* type_key() const = 0;
/*! /*!
* \brief Get a PackedFunc from module. * \brief Get a PackedFunc from module.
* *
...@@ -137,7 +137,7 @@ class TVM_DLL ModuleNode : public Object { ...@@ -137,7 +137,7 @@ class TVM_DLL ModuleNode : public Object {
* If the function need resource from the module(e.g. late linking), * If the function need resource from the module(e.g. late linking),
* it should capture sptr_to_self. * it should capture sptr_to_self.
*/ */
TVM_DLL virtual PackedFunc GetFunction( virtual PackedFunc GetFunction(
const std::string& name, const std::string& name,
const ObjectPtr<Object>& sptr_to_self) = 0; const ObjectPtr<Object>& sptr_to_self) = 0;
/*! /*!
...@@ -145,8 +145,8 @@ class TVM_DLL ModuleNode : public Object { ...@@ -145,8 +145,8 @@ class TVM_DLL ModuleNode : public Object {
* \param file_name The file to be saved to. * \param file_name The file to be saved to.
* \param format The format of the file. * \param format The format of the file.
*/ */
TVM_DLL virtual void SaveToFile(const std::string& file_name, virtual void SaveToFile(const std::string& file_name,
const std::string& format); const std::string& format);
/*! /*!
* \brief Save the module to binary stream. * \brief Save the module to binary stream.
* \param stream The binary stream to save to. * \param stream The binary stream to save to.
...@@ -154,13 +154,13 @@ class TVM_DLL ModuleNode : public Object { ...@@ -154,13 +154,13 @@ class TVM_DLL ModuleNode : public Object {
* but not necessarily host modules. * but not necessarily host modules.
* We can use this to do AOT loading of bundled device functions. * We can use this to do AOT loading of bundled device functions.
*/ */
TVM_DLL virtual void SaveToBinary(dmlc::Stream* stream); virtual void SaveToBinary(dmlc::Stream* stream);
/*! /*!
* \brief Get the source code of module, when available. * \brief Get the source code of module, when available.
* \param format Format of the source code, can be empty by default. * \param format Format of the source code, can be empty by default.
* \return Possible source code when available. * \return Possible source code when available.
*/ */
TVM_DLL virtual std::string GetSource(const std::string& format = ""); virtual std::string GetSource(const std::string& format = "");
/*! /*!
* \brief Get packed function from current module by name. * \brief Get packed function from current module by name.
* *
...@@ -170,7 +170,7 @@ class TVM_DLL ModuleNode : public Object { ...@@ -170,7 +170,7 @@ class TVM_DLL ModuleNode : public Object {
* This function will return PackedFunc(nullptr) if function do not exist. * This function will return PackedFunc(nullptr) if function do not exist.
* \note Implemented in packed_func.cc * \note Implemented in packed_func.cc
*/ */
TVM_DLL PackedFunc GetFunction(const std::string& name, bool query_imports = false); PackedFunc GetFunction(const std::string& name, bool query_imports = false);
/*! /*!
* \brief Import another module into this module. * \brief Import another module into this module.
* \param other The module to be imported. * \param other The module to be imported.
...@@ -178,7 +178,7 @@ class TVM_DLL ModuleNode : public Object { ...@@ -178,7 +178,7 @@ class TVM_DLL ModuleNode : public Object {
* \note Cyclic dependency is not allowed among modules, * \note Cyclic dependency is not allowed among modules,
* An error will be thrown when cyclic dependency is detected. * An error will be thrown when cyclic dependency is detected.
*/ */
TVM_DLL void Import(Module other); void Import(Module other);
/*! /*!
* \brief Get a function from current environment * \brief Get a function from current environment
* The environment includes all the imports as well as Global functions. * The environment includes all the imports as well as Global functions.
...@@ -186,7 +186,7 @@ class TVM_DLL ModuleNode : public Object { ...@@ -186,7 +186,7 @@ class TVM_DLL ModuleNode : public Object {
* \param name name of the function. * \param name name of the function.
* \return The corresponding function. * \return The corresponding function.
*/ */
TVM_DLL const PackedFunc* GetFuncFromEnv(const std::string& name); const PackedFunc* GetFuncFromEnv(const std::string& name);
/*! \return The module it imports from */ /*! \return The module it imports from */
const std::vector<Module>& imports() const { const std::vector<Module>& imports() const {
return imports_; return imports_;
...@@ -208,7 +208,7 @@ class TVM_DLL ModuleNode : public Object { ...@@ -208,7 +208,7 @@ class TVM_DLL ModuleNode : public Object {
private: private:
/*! \brief Cache used by GetImport */ /*! \brief Cache used by GetImport */
std::unordered_map<std::string, std::unordered_map<std::string,
std::unique_ptr<PackedFunc> > import_cache_; std::shared_ptr<PackedFunc> > import_cache_;
}; };
/*! \brief namespace for constant symbols */ /*! \brief namespace for constant symbols */
......
...@@ -125,8 +125,7 @@ const PackedFunc* ModuleNode::GetFuncFromEnv(const std::string& name) { ...@@ -125,8 +125,7 @@ const PackedFunc* ModuleNode::GetFuncFromEnv(const std::string& name) {
<< " in the imported modules or global registry"; << " in the imported modules or global registry";
return f; return f;
} else { } else {
std::unique_ptr<PackedFunc> f(new PackedFunc(pf)); import_cache_.insert(std::make_pair(name, std::make_shared<PackedFunc>(pf)));
import_cache_[name] = std::move(f);
return import_cache_.at(name).get(); return import_cache_.at(name).get();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment