Skip to content

Commit

Permalink
[CI] Recover Windows Mac Build CI via Github Actions (#4662)
Browse files Browse the repository at this point in the history
* [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.
  • Loading branch information
tqchen authored Jan 9, 2020
1 parent b873e03 commit 2077cd5
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 13 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# 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
22 changes: 11 additions & 11 deletions include/tvm/runtime/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ class Module : public ObjectRef {
class TVM_DLL ModuleNode : public Object {
public:
/*! \brief virtual destructor */
TVM_DLL virtual ~ModuleNode() {}
virtual ~ModuleNode() {}
/*!
* \return The per module type key.
* \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.
*
Expand All @@ -137,30 +137,30 @@ class TVM_DLL ModuleNode : public Object {
* If the function need resource from the module(e.g. late linking),
* it should capture sptr_to_self.
*/
TVM_DLL virtual PackedFunc GetFunction(
virtual PackedFunc GetFunction(
const std::string& name,
const ObjectPtr<Object>& sptr_to_self) = 0;
/*!
* \brief Save the module to file.
* \param file_name The file to be saved to.
* \param format The format of the file.
*/
TVM_DLL virtual void SaveToFile(const std::string& file_name,
const std::string& format);
virtual void SaveToFile(const std::string& file_name,
const std::string& format);
/*!
* \brief Save the module to binary stream.
* \param stream The binary stream to save to.
* \note It is recommended to implement this for device modules,
* but not necessarily host modules.
* 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.
* \param format Format of the source code, can be empty by default.
* \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.
*
Expand All @@ -170,23 +170,23 @@ class TVM_DLL ModuleNode : public Object {
* This function will return PackedFunc(nullptr) if function do not exist.
* \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.
* \param other The module to be imported.
*
* \note Cyclic dependency is not allowed among modules,
* 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
* The environment includes all the imports as well as Global functions.
*
* \param name name of the 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 */
const std::vector<Module>& imports() const {
return imports_;
Expand All @@ -208,7 +208,7 @@ class TVM_DLL ModuleNode : public Object {
private:
/*! \brief Cache used by GetImport */
std::unordered_map<std::string,
std::unique_ptr<PackedFunc> > import_cache_;
std::shared_ptr<PackedFunc> > import_cache_;
};

/*! \brief namespace for constant symbols */
Expand Down
3 changes: 1 addition & 2 deletions src/runtime/module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ const PackedFunc* ModuleNode::GetFuncFromEnv(const std::string& name) {
<< " in the imported modules or global registry";
return f;
} else {
std::unique_ptr<PackedFunc> f(new PackedFunc(pf));
import_cache_[name] = std::move(f);
import_cache_.insert(std::make_pair(name, std::make_shared<PackedFunc>(pf)));
return import_cache_.at(name).get();
}
}
Expand Down

0 comments on commit 2077cd5

Please sign in to comment.