-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CONTRIB] Allow customized initializer in PopenPool (#8789)
- Loading branch information
Yuanjing Shi
authored
Aug 20, 2021
1 parent
e691c7f
commit d722c10
Showing
5 changed files
with
143 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# 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. | ||
# pylint: disable=invalid-name, missing-function-docstring | ||
"""Common functions for popen_pool test cases""" | ||
import tvm | ||
|
||
TEST_GLOBAL_STATE_1 = 0 | ||
TEST_GLOBAL_STATE_2 = 0 | ||
TEST_GLOBAL_STATE_3 = 0 | ||
|
||
|
||
def initializer(test_global_state_1, test_global_state_2, test_global_state_3): | ||
global TEST_GLOBAL_STATE_1, TEST_GLOBAL_STATE_2, TEST_GLOBAL_STATE_3 | ||
TEST_GLOBAL_STATE_1 = test_global_state_1 | ||
TEST_GLOBAL_STATE_2 = test_global_state_2 | ||
TEST_GLOBAL_STATE_3 = test_global_state_3 | ||
|
||
|
||
def after_initializer(): | ||
global TEST_GLOBAL_STATE_1, TEST_GLOBAL_STATE_2, TEST_GLOBAL_STATE_3 | ||
return TEST_GLOBAL_STATE_1, TEST_GLOBAL_STATE_2, TEST_GLOBAL_STATE_3 | ||
|
||
|
||
@tvm._ffi.register_func("testing.identity_py") | ||
def identity_py(arg): | ||
return arg | ||
|
||
|
||
def register_ffi(): | ||
@tvm._ffi.register_func("testing.nested_identity_py") | ||
def _identity_py(arg): # pylint: disable=unused-variable | ||
return arg | ||
|
||
|
||
def call_py_ffi(arg): | ||
_identity_py = tvm._ffi.get_global_func("testing.nested_identity_py") | ||
return _identity_py(arg) | ||
|
||
|
||
def call_cpp_ffi(arg): | ||
return tvm.testing.echo(arg) | ||
|
||
|
||
def call_cpp_py_ffi(arg): | ||
return tvm.testing.identity_cpp(arg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters