2019-12-22 13:25:02 +08:00
|
|
|
from __future__ import absolute_import
|
|
|
|
from __future__ import division
|
|
|
|
from __future__ import print_function
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
import os
|
2020-01-21 01:30:08 +08:00
|
|
|
import sys
|
2019-12-22 13:25:02 +08:00
|
|
|
import unittest
|
Compiling Models with Large Constant Arrays (#146)
* PoC works.
* MNist works.
* Clean up.
* Fix test.
* Make Linux work.
* Use consistent symbol name.
* Fix variable name.
* Fix array addr access.
* Bug fix.
* Bug fix.
* install before running e2e tests.
* Fix build config.
* Use sudo when installing.
* Make embeddedDataLoader position independent.
* Enable ResNet50.
* Format code.
* Format MainUtil.
* Try not using sudo to install.
* Supply runtime dir via environment variable.
* Dump problematic operation.
* Dump entire function.
* Debug.
* Dump input.
* Dump constant op.
* Debug.
* Debug.
* Debug.
* Print to stderr.
* take care of endianness.
* Use endianness-aware execution session.
* Fix ZLinux error.
* Include warning when desired output endianness can't be deduced.
* Remove debug code.
* Remove debug code in shape inference.
* Support binary-decoder for testing constants packing.
* Support filename, move-to-file, elision-threshold configurations in constant packing pass for easy testing.
* Add lit test, fix lit test type mismatch.
* Add more consts packing tests.
* Ensure intermediate files are properly cleaned up.
* No need for constant elimination.
* Link with threading libraries.
* Remove debug code.
* Format code.
* More tests.
* test nit.
* Remove debug code.
* Reduce hard-coded constants.
* Use temporary and unique working directory for hosting model parameters.
* Test if it works.
* Try to find objcopy.
* Rename symbols using objcopy.
* Move sanitized name to linux section.
* Use verbose mode for debugging.
* Disambiguate pass constructor.
* Fix symbol name.
* Use Command API to build and execute commands.
* Move linux to use Command API.
* Fix reset args.
* Execute redefine sym.
* Format code.
* Do not use verbose mode for CircleCI.
* Remove debug code.
* Prettify code, add comments.
* getSegmentData -> getEmbeddedConstPool
* vector -> std::vector.
* Make sure we properly clean up intermediate files.
* Fix test cases.
* Add runtime directory.
* Trigger rebuild.
* [Merge with master] fix debug script.
* Diable affine fusion pass for now.
* Support generic fallback const packing mechanism.
* Remove debug code.
* Handle the case where objcopy is not available.
* Fix Windows missing types.
* Support int64.
* Copy packed constant to a local directory for non-Linux/Mac platforms.
* Nit: remove debug code, refactor const pack preprocessing out as a separate function.
* Cannot make preprocessConstPack a standalone function because file removers are stack-allocated, and they are deallocated prematurely when function stack gets popped, deleteing intermediate files too early.
* Don't require executable filename.
* Import ONNX data types directly.
* Fix LIT test.
* Bug fix, use moved string value.
* Remove redundant filenames.
* Fix CMake script.
* Embed endianness information as a symbol, and check during runtime.
* More comments, update lit tests.
* Fix lit test on BE machine.
* Copyright notices.
2020-06-12 10:27:05 +08:00
|
|
|
import warnings
|
2019-12-22 13:25:02 +08:00
|
|
|
import onnx.backend.base
|
|
|
|
import onnx.backend.test
|
|
|
|
|
|
|
|
from onnx.backend.base import Device, DeviceType
|
|
|
|
import subprocess
|
2020-01-21 01:30:08 +08:00
|
|
|
import test_config
|
|
|
|
|
|
|
|
VERBOSE = bool(os.environ.get("VERBOSE"))
|
|
|
|
|
|
|
|
CXX = test_config.CXX_PATH
|
2020-03-17 21:16:33 +08:00
|
|
|
ONNX_MLIR = os.path.join(test_config.ONNX_MLIR_BUILD_PATH, "bin/onnx-mlir")
|
2020-01-21 01:30:08 +08:00
|
|
|
LLC = os.path.join(test_config.LLVM_PROJ_BUILD_PATH, "bin/llc")
|
|
|
|
|
|
|
|
# Make lib folder under build directory visible in PYTHONPATH
|
|
|
|
doc_check_base_dir = os.path.dirname(os.path.realpath(__file__))
|
2020-03-17 21:16:33 +08:00
|
|
|
RUNTIME_DIR = os.path.join(test_config.ONNX_MLIR_BUILD_PATH, "lib")
|
2020-01-21 01:30:08 +08:00
|
|
|
sys.path.append(RUNTIME_DIR)
|
2020-06-08 10:18:55 +08:00
|
|
|
from PyRuntime import ExecutionSession
|
2019-12-22 13:25:02 +08:00
|
|
|
|
2020-01-21 01:30:08 +08:00
|
|
|
|
|
|
|
def execute_commands(cmds):
|
|
|
|
if (VERBOSE):
|
|
|
|
print(" ".join(cmds))
|
Compiling Models with Large Constant Arrays (#146)
* PoC works.
* MNist works.
* Clean up.
* Fix test.
* Make Linux work.
* Use consistent symbol name.
* Fix variable name.
* Fix array addr access.
* Bug fix.
* Bug fix.
* install before running e2e tests.
* Fix build config.
* Use sudo when installing.
* Make embeddedDataLoader position independent.
* Enable ResNet50.
* Format code.
* Format MainUtil.
* Try not using sudo to install.
* Supply runtime dir via environment variable.
* Dump problematic operation.
* Dump entire function.
* Debug.
* Dump input.
* Dump constant op.
* Debug.
* Debug.
* Debug.
* Print to stderr.
* take care of endianness.
* Use endianness-aware execution session.
* Fix ZLinux error.
* Include warning when desired output endianness can't be deduced.
* Remove debug code.
* Remove debug code in shape inference.
* Support binary-decoder for testing constants packing.
* Support filename, move-to-file, elision-threshold configurations in constant packing pass for easy testing.
* Add lit test, fix lit test type mismatch.
* Add more consts packing tests.
* Ensure intermediate files are properly cleaned up.
* No need for constant elimination.
* Link with threading libraries.
* Remove debug code.
* Format code.
* More tests.
* test nit.
* Remove debug code.
* Reduce hard-coded constants.
* Use temporary and unique working directory for hosting model parameters.
* Test if it works.
* Try to find objcopy.
* Rename symbols using objcopy.
* Move sanitized name to linux section.
* Use verbose mode for debugging.
* Disambiguate pass constructor.
* Fix symbol name.
* Use Command API to build and execute commands.
* Move linux to use Command API.
* Fix reset args.
* Execute redefine sym.
* Format code.
* Do not use verbose mode for CircleCI.
* Remove debug code.
* Prettify code, add comments.
* getSegmentData -> getEmbeddedConstPool
* vector -> std::vector.
* Make sure we properly clean up intermediate files.
* Fix test cases.
* Add runtime directory.
* Trigger rebuild.
* [Merge with master] fix debug script.
* Diable affine fusion pass for now.
* Support generic fallback const packing mechanism.
* Remove debug code.
* Handle the case where objcopy is not available.
* Fix Windows missing types.
* Support int64.
* Copy packed constant to a local directory for non-Linux/Mac platforms.
* Nit: remove debug code, refactor const pack preprocessing out as a separate function.
* Cannot make preprocessConstPack a standalone function because file removers are stack-allocated, and they are deallocated prematurely when function stack gets popped, deleteing intermediate files too early.
* Don't require executable filename.
* Import ONNX data types directly.
* Fix LIT test.
* Bug fix, use moved string value.
* Remove redundant filenames.
* Fix CMake script.
* Embed endianness information as a symbol, and check during runtime.
* More comments, update lit tests.
* Fix lit test on BE machine.
* Copyright notices.
2020-06-12 10:27:05 +08:00
|
|
|
subprocess.run(cmds)
|
|
|
|
|
|
|
|
|
|
|
|
# There are two issues, which necessitates the adoption of this endianness
|
|
|
|
# aware wrapper around Execution Session:
|
|
|
|
# 1. Input arrays are given sometimes in native byte order, sometime in
|
|
|
|
# LE byte order, and as soon as the python array enters into py::array
|
|
|
|
# C++ objects through pybind, we will no longer be able to query their
|
|
|
|
# endianness. So we must intercept the inputs and convert them into
|
|
|
|
# native endianness.
|
|
|
|
# 2. Output arrays are compared with reference outputs, the comparison
|
|
|
|
# unfortunately includes checking that our outputs and reference outputs
|
|
|
|
# share the same endianness. So we try to figure out what is the desired
|
|
|
|
# reference output endianness, and convert our outputs to this desired
|
|
|
|
# endianness.
|
|
|
|
class EndiannessAwareExecutionSession(ExecutionSession):
|
|
|
|
def __init__(self, path, entry_point):
|
|
|
|
super().__init__(path, entry_point)
|
|
|
|
|
|
|
|
def is_input_le(self, inputs):
|
|
|
|
inputs_endianness = list(map(lambda x: x.dtype.byteorder, inputs))
|
|
|
|
endianness_is_consistent = len(set(inputs_endianness)) <= 1
|
|
|
|
assert endianness_is_consistent, \
|
|
|
|
"Input arrays contain a mixture of endianness configuration."
|
|
|
|
|
|
|
|
sys_is_le = sys.byteorder == 'little'
|
|
|
|
# To interpret character symbols indicating endianness:
|
|
|
|
# https://numpy.org/doc/stable/reference/generated/numpy.dtype.byteorder.html
|
|
|
|
explicitly_le = inputs_endianness[0] == "<"
|
|
|
|
implicitly_le = (inputs_endianness[0] == "=" and sys_is_le)
|
|
|
|
return explicitly_le or implicitly_le
|
|
|
|
|
|
|
|
def run(self, inputs, **kwargs):
|
|
|
|
if len(inputs):
|
|
|
|
# Deduce desired endianness of output from inputs.
|
|
|
|
sys_is_le = sys.byteorder == 'little'
|
|
|
|
inp_is_le = self.is_input_le(inputs)
|
|
|
|
if (sys_is_le != inp_is_le):
|
|
|
|
inputs = list(
|
|
|
|
map(lambda x: x.byteswap().newbyteorder(), inputs))
|
|
|
|
outputs = super().run(inputs)
|
|
|
|
if (sys_is_le != inp_is_le):
|
|
|
|
outputs = list(
|
|
|
|
map(lambda x: x.byteswap().newbyteorder(), outputs))
|
|
|
|
return outputs
|
|
|
|
else:
|
|
|
|
# Can't deduce desired output endianess, fingers crossed.
|
|
|
|
warnings.warn(
|
|
|
|
"Cannot deduce desired output endianness, using native endianness by default."
|
|
|
|
)
|
|
|
|
return super().run(inputs)
|
2020-01-21 01:30:08 +08:00
|
|
|
|
2019-12-22 13:25:02 +08:00
|
|
|
|
|
|
|
class DummyBackend(onnx.backend.base.Backend):
|
|
|
|
@classmethod
|
2020-01-21 01:30:08 +08:00
|
|
|
def prepare(cls, model, device='CPU', **kwargs):
|
2019-12-22 13:25:02 +08:00
|
|
|
super(DummyBackend, cls).prepare(model, device, **kwargs)
|
|
|
|
# Save model to disk as temp_model.onnx.
|
|
|
|
onnx.save(model, "temp_model.onnx")
|
|
|
|
# Call frontend to process temp_model.onnx, bit code will be generated.
|
2020-03-17 21:16:33 +08:00
|
|
|
execute_commands([ONNX_MLIR, "temp_model.onnx"])
|
Compiling Models with Large Constant Arrays (#146)
* PoC works.
* MNist works.
* Clean up.
* Fix test.
* Make Linux work.
* Use consistent symbol name.
* Fix variable name.
* Fix array addr access.
* Bug fix.
* Bug fix.
* install before running e2e tests.
* Fix build config.
* Use sudo when installing.
* Make embeddedDataLoader position independent.
* Enable ResNet50.
* Format code.
* Format MainUtil.
* Try not using sudo to install.
* Supply runtime dir via environment variable.
* Dump problematic operation.
* Dump entire function.
* Debug.
* Dump input.
* Dump constant op.
* Debug.
* Debug.
* Debug.
* Print to stderr.
* take care of endianness.
* Use endianness-aware execution session.
* Fix ZLinux error.
* Include warning when desired output endianness can't be deduced.
* Remove debug code.
* Remove debug code in shape inference.
* Support binary-decoder for testing constants packing.
* Support filename, move-to-file, elision-threshold configurations in constant packing pass for easy testing.
* Add lit test, fix lit test type mismatch.
* Add more consts packing tests.
* Ensure intermediate files are properly cleaned up.
* No need for constant elimination.
* Link with threading libraries.
* Remove debug code.
* Format code.
* More tests.
* test nit.
* Remove debug code.
* Reduce hard-coded constants.
* Use temporary and unique working directory for hosting model parameters.
* Test if it works.
* Try to find objcopy.
* Rename symbols using objcopy.
* Move sanitized name to linux section.
* Use verbose mode for debugging.
* Disambiguate pass constructor.
* Fix symbol name.
* Use Command API to build and execute commands.
* Move linux to use Command API.
* Fix reset args.
* Execute redefine sym.
* Format code.
* Do not use verbose mode for CircleCI.
* Remove debug code.
* Prettify code, add comments.
* getSegmentData -> getEmbeddedConstPool
* vector -> std::vector.
* Make sure we properly clean up intermediate files.
* Fix test cases.
* Add runtime directory.
* Trigger rebuild.
* [Merge with master] fix debug script.
* Diable affine fusion pass for now.
* Support generic fallback const packing mechanism.
* Remove debug code.
* Handle the case where objcopy is not available.
* Fix Windows missing types.
* Support int64.
* Copy packed constant to a local directory for non-Linux/Mac platforms.
* Nit: remove debug code, refactor const pack preprocessing out as a separate function.
* Cannot make preprocessConstPack a standalone function because file removers are stack-allocated, and they are deallocated prematurely when function stack gets popped, deleteing intermediate files too early.
* Don't require executable filename.
* Import ONNX data types directly.
* Fix LIT test.
* Bug fix, use moved string value.
* Remove redundant filenames.
* Fix CMake script.
* Embed endianness information as a symbol, and check during runtime.
* More comments, update lit tests.
* Fix lit test on BE machine.
* Copyright notices.
2020-06-12 10:27:05 +08:00
|
|
|
return EndiannessAwareExecutionSession("./temp_model.so",
|
|
|
|
"_dyn_entry_point_main_graph")
|
2019-12-22 13:25:02 +08:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def supports_device(cls, device):
|
|
|
|
d = Device(device)
|
|
|
|
if d.type == DeviceType.CPU:
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
backend_test = onnx.backend.test.BackendTest(DummyBackend, __name__)
|
|
|
|
|
|
|
|
# Test directories:
|
|
|
|
# https://github.com/onnx/onnx/tree/master/onnx/backend/test/data/node
|
|
|
|
test_to_enable = [
|
2020-03-17 23:12:45 +08:00
|
|
|
# Abs Op:
|
|
|
|
"test_abs_cpu",
|
|
|
|
|
2019-12-22 13:25:02 +08:00
|
|
|
# Add Op:
|
|
|
|
"test_add_cpu",
|
|
|
|
"test_add_bcast_cpu",
|
|
|
|
|
|
|
|
# And Op:
|
|
|
|
|
|
|
|
# Sub Op:
|
|
|
|
"test_sub_cpu",
|
|
|
|
"test_sub_bcast_cpu",
|
|
|
|
"test_sub_example_cpu",
|
|
|
|
|
|
|
|
# Cosh Op:
|
|
|
|
"test_cosh_cpu",
|
|
|
|
"test_cosh_example_cpu",
|
|
|
|
|
2020-04-13 23:40:39 +08:00
|
|
|
# Concat
|
|
|
|
"test_concat_1d_axis_0_cpu",
|
|
|
|
"test_concat_2d_axis_0_cpu",
|
|
|
|
"test_concat_2d_axis_1_cpu",
|
|
|
|
"test_concat_3d_axis_0_cpu",
|
|
|
|
"test_concat_3d_axis_1_cpu",
|
|
|
|
"test_concat_3d_axis_2_cpu",
|
|
|
|
"test_concat_1d_axis_negative_1_cpu",
|
|
|
|
"test_concat_2d_axis_negative_1_cpu",
|
|
|
|
"test_concat_2d_axis_negative_2_cpu",
|
|
|
|
"test_concat_3d_axis_negative_1_cpu",
|
|
|
|
"test_concat_3d_axis_negative_2_cpu",
|
|
|
|
"test_concat_3d_axis_negative_3_cpu",
|
|
|
|
|
2020-04-09 14:22:36 +08:00
|
|
|
# Tanh:
|
|
|
|
"test_tanh_cpu",
|
|
|
|
"test_tanh_example_cpu",
|
|
|
|
|
2019-12-22 13:25:02 +08:00
|
|
|
# Div Op:
|
|
|
|
"test_div_cpu",
|
|
|
|
"test_div_bcast_cpu",
|
|
|
|
"test_div_example_cpu",
|
|
|
|
|
|
|
|
# Elu Op:
|
|
|
|
"test_elu_cpu",
|
|
|
|
"test_elu_default_cpu",
|
|
|
|
"test_elu_example_cpu",
|
|
|
|
|
|
|
|
# Exp Op:
|
|
|
|
"test_exp_cpu",
|
|
|
|
"test_exp_example_cpu",
|
|
|
|
|
2020-01-30 00:11:49 +08:00
|
|
|
# Gemm Op:
|
|
|
|
"test_gemm_all_attributes_cpu",
|
|
|
|
"test_gemm_alpha_cpu",
|
|
|
|
"test_gemm_beta_cpu",
|
|
|
|
"test_gemm_default_matrix_bias_cpu",
|
2020-02-20 23:55:24 +08:00
|
|
|
"test_gemm_default_no_bias_cpu",
|
2020-02-13 13:50:05 +08:00
|
|
|
"test_gemm_default_scalar_bias_cpu",
|
2020-01-30 00:11:49 +08:00
|
|
|
"test_gemm_default_single_elem_vector_bias_cpu",
|
|
|
|
"test_gemm_default_vector_bias_cpu",
|
|
|
|
"test_gemm_default_zero_bias_cpu",
|
|
|
|
"test_gemm_transposeA_cpu",
|
|
|
|
"test_gemm_transposeB_cpu",
|
|
|
|
|
2019-12-22 13:25:02 +08:00
|
|
|
# Hard Sigmoid Op:
|
|
|
|
"test_hardsigmoid_cpu",
|
|
|
|
"test_hardsigmoid_default_cpu",
|
|
|
|
"test_hardsigmoid_example_cpu",
|
|
|
|
|
|
|
|
# Leaky Relu Op:
|
|
|
|
"test_leakyrelu_cpu",
|
|
|
|
"test_leakyrelu_default_cpu",
|
|
|
|
"test_leakyrelu_example_cpu",
|
|
|
|
|
|
|
|
# Max Op:
|
2020-01-28 21:48:11 +08:00
|
|
|
"test_max_example_cpu",
|
2019-12-22 13:25:02 +08:00
|
|
|
"test_max_one_input_cpu",
|
2020-01-28 21:48:11 +08:00
|
|
|
"test_max_two_inputs_cpu",
|
2019-12-22 13:25:02 +08:00
|
|
|
|
|
|
|
# Min Op:
|
2020-01-28 21:48:11 +08:00
|
|
|
"test_min_example_cpu",
|
2019-12-22 13:25:02 +08:00
|
|
|
"test_min_one_input_cpu",
|
2020-01-28 21:48:11 +08:00
|
|
|
"test_min_two_inputs_cpu",
|
2019-12-22 13:25:02 +08:00
|
|
|
|
|
|
|
# Mul Op:
|
|
|
|
"test_mul_cpu",
|
|
|
|
"test_mul_bcast_cpu",
|
|
|
|
"test_mul_example_cpu",
|
|
|
|
|
|
|
|
# Relu Op:
|
|
|
|
"test_relu_cpu",
|
|
|
|
|
2020-02-10 21:38:19 +08:00
|
|
|
# ReduceMax Op:
|
|
|
|
"test_reduce_max_default_axes_keepdim_example_cpu",
|
|
|
|
"test_reduce_max_default_axes_keepdims_random_cpu",
|
|
|
|
"test_reduce_max_do_not_keepdims_example_cpu",
|
|
|
|
"test_reduce_max_do_not_keepdims_random_cpu",
|
|
|
|
"test_reduce_max_keepdims_example_cpu",
|
|
|
|
"test_reduce_max_keepdims_random_cpu",
|
|
|
|
"test_reduce_max_negative_axes_keepdims_example_cpu",
|
|
|
|
"test_reduce_max_negative_axes_keepdims_random_cpu",
|
|
|
|
|
|
|
|
# ReduceMin Op:
|
|
|
|
"test_reduce_min_default_axes_keepdims_example_cpu",
|
|
|
|
"test_reduce_min_default_axes_keepdims_random_cpu",
|
|
|
|
"test_reduce_min_do_not_keepdims_example_cpu",
|
|
|
|
"test_reduce_min_do_not_keepdims_random_cpu",
|
|
|
|
"test_reduce_min_keepdims_example_cpu",
|
|
|
|
"test_reduce_min_keepdims_random_cpu",
|
|
|
|
"test_reduce_min_negative_axes_keepdims_example_cpu",
|
|
|
|
"test_reduce_min_negative_axes_keepdims_random_cpu",
|
|
|
|
|
|
|
|
# ReduceProd Op:
|
|
|
|
"test_reduce_prod_default_axes_keepdims_example_cpu",
|
|
|
|
"test_reduce_prod_default_axes_keepdims_random_cpu",
|
|
|
|
"test_reduce_prod_do_not_keepdims_example_cpu",
|
|
|
|
"test_reduce_prod_do_not_keepdims_random_cpu",
|
|
|
|
"test_reduce_prod_keepdims_example_cpu",
|
|
|
|
"test_reduce_prod_keepdims_random_cpu",
|
|
|
|
"test_reduce_prod_negative_axes_keepdims_example_cpu",
|
|
|
|
"test_reduce_prod_negative_axes_keepdims_random_cpu",
|
|
|
|
|
|
|
|
# ReduceSum Op:
|
|
|
|
"test_reduce_sum_default_axes_keepdims_example_cpu",
|
|
|
|
"test_reduce_sum_default_axes_keepdims_random_cpu",
|
|
|
|
"test_reduce_sum_do_not_keepdims_example_cpu",
|
|
|
|
"test_reduce_sum_do_not_keepdims_random_cpu",
|
|
|
|
"test_reduce_sum_keepdims_example_cpu",
|
|
|
|
"test_reduce_sum_keepdims_random_cpu",
|
|
|
|
"test_reduce_sum_negative_axes_keepdims_example_cpu",
|
|
|
|
"test_reduce_sum_negative_axes_keepdims_random_cpu",
|
|
|
|
|
2020-03-17 23:12:45 +08:00
|
|
|
# ReduceL1
|
|
|
|
"test_reduce_l1_default_axes_keepdims_example_cpu",
|
|
|
|
"test_reduce_l1_default_axes_keepdims_random_cpu",
|
|
|
|
"test_reduce_l1_do_not_keepdims_example_cpu",
|
|
|
|
"test_reduce_l1_do_not_keepdims_random_cpu",
|
|
|
|
"test_reduce_l1_keep_dims_example_cpu",
|
|
|
|
"test_reduce_l1_keep_dims_random_cpu",
|
|
|
|
"test_reduce_l1_negative_axes_keep_dims_example_cpu",
|
|
|
|
"test_reduce_l1_negative_axes_keep_dims_random_cpu",
|
2020-02-12 16:40:32 +08:00
|
|
|
|
|
|
|
# ReduceL2
|
|
|
|
"test_reduce_l2_default_axes_keepdims_example_cpu",
|
|
|
|
"test_reduce_l2_default_axes_keepdims_random_cpu",
|
|
|
|
"test_reduce_l2_do_not_keepdims_example_cpu",
|
|
|
|
"test_reduce_l2_do_not_keepdims_random_cpu",
|
|
|
|
"test_reduce_l2_keep_dims_example_cpu",
|
|
|
|
"test_reduce_l2_keep_dims_random_cpu",
|
|
|
|
"test_reduce_l2_negative_axes_keep_dims_example_cpu",
|
|
|
|
"test_reduce_l2_negative_axes_keep_dims_random_cpu",
|
|
|
|
|
|
|
|
# ReduceLogSum
|
|
|
|
"test_reduce_log_sum_asc_axes_cpu",
|
|
|
|
"test_reduce_log_sum_cpu",
|
|
|
|
"test_reduce_log_sum_default_cpu",
|
|
|
|
"test_reduce_log_sum_desc_axes_cpu",
|
|
|
|
|
|
|
|
# ReduceLogSumExp
|
|
|
|
"test_reduce_log_sum_exp_default_axes_keepdims_example_cpu",
|
|
|
|
"test_reduce_log_sum_exp_default_axes_keepdims_random_cpu",
|
|
|
|
"test_reduce_log_sum_exp_do_not_keepdims_example_cpu",
|
|
|
|
"test_reduce_log_sum_exp_do_not_keepdims_random_cpu",
|
|
|
|
"test_reduce_log_sum_exp_keepdims_example_cpu",
|
|
|
|
"test_reduce_log_sum_exp_keepdims_random_cpu",
|
|
|
|
"test_reduce_log_sum_exp_negative_axes_keepdims_example_cpu",
|
|
|
|
"test_reduce_log_sum_exp_negative_axes_keepdims_random_cpu",
|
|
|
|
"test_reduce_log_sum_negative_axes_cpu",
|
|
|
|
|
|
|
|
# ReduceSumSquare
|
|
|
|
"test_reduce_sum_square_default_axes_keepdims_example_cpu",
|
|
|
|
"test_reduce_sum_square_default_axes_keepdims_random_cpu",
|
|
|
|
"test_reduce_sum_square_do_not_keepdims_example_cpu",
|
|
|
|
"test_reduce_sum_square_do_not_keepdims_random_cpu",
|
|
|
|
"test_reduce_sum_square_keepdims_example_cpu",
|
|
|
|
"test_reduce_sum_square_keepdims_random_cpu",
|
|
|
|
"test_reduce_sum_square_negative_axes_keepdims_example_cpu",
|
|
|
|
"test_reduce_sum_square_negative_axes_keepdims_random_cpu",
|
|
|
|
|
2019-12-22 13:25:02 +08:00
|
|
|
# Selu Op:
|
|
|
|
"test_selu_cpu",
|
|
|
|
"test_selu_default_cpu",
|
|
|
|
"test_selu_example_cpu",
|
|
|
|
|
|
|
|
# Sigmoid Op:
|
|
|
|
"test_sigmoid_cpu",
|
|
|
|
"test_sigmoid_example_cpu",
|
2020-01-21 01:30:08 +08:00
|
|
|
|
2020-01-21 10:57:32 +08:00
|
|
|
# Softmax Op:
|
|
|
|
"test_softmax_axis_0_cpu",
|
|
|
|
"test_softmax_axis_1_cpu",
|
|
|
|
"test_softmax_axis_2_cpu",
|
|
|
|
"test_softmax_default_axis_cpu",
|
|
|
|
"test_softmax_example_cpu",
|
|
|
|
"test_softmax_large_number_cpu",
|
|
|
|
|
2020-01-29 00:10:47 +08:00
|
|
|
# Sqrt Op:
|
|
|
|
"test_sqrt_cpu",
|
|
|
|
"test_sqrt_example_cpu",
|
|
|
|
|
2019-12-22 13:25:02 +08:00
|
|
|
# Sum Op:
|
2020-01-28 21:48:11 +08:00
|
|
|
"test_sum_example_cpu",
|
2019-12-22 13:25:02 +08:00
|
|
|
"test_sum_one_input_cpu",
|
2020-01-28 21:48:11 +08:00
|
|
|
"test_sum_two_inputs_cpu",
|
2019-12-22 13:25:02 +08:00
|
|
|
|
2020-01-29 23:46:02 +08:00
|
|
|
# Unsqueeze Op:
|
|
|
|
"test_unsqueeze_axis_0_cpu",
|
|
|
|
"test_unsqueeze_axis_1_cpu",
|
|
|
|
"test_unsqueeze_axis_2_cpu",
|
|
|
|
"test_unsqueeze_axis_3_cpu",
|
|
|
|
"test_unsqueeze_negative_axes_cpu",
|
|
|
|
"test_unsqueeze_three_axes_cpu",
|
|
|
|
"test_unsqueeze_two_axes_cpu",
|
2020-01-31 00:44:56 +08:00
|
|
|
# "test_unsqueeze_unsorted_axes_cpu",
|
2020-01-29 23:46:02 +08:00
|
|
|
|
2019-12-22 13:25:02 +08:00
|
|
|
# Reciprocal Op:
|
2020-01-22 10:41:22 +08:00
|
|
|
"test_reciprocal_cpu",
|
|
|
|
"test_reciprocal_example_cpu",
|
2020-01-24 12:18:38 +08:00
|
|
|
|
|
|
|
# SoftplusOp:
|
|
|
|
"test_softplus_cpu",
|
|
|
|
"test_softplus_example_cpu",
|
|
|
|
|
|
|
|
# SoftsignOp:
|
|
|
|
"test_softsign_cpu",
|
|
|
|
"test_softsign_example_cpu",
|
2020-01-28 23:21:08 +08:00
|
|
|
|
|
|
|
# ReshapeOp:
|
2020-01-29 23:41:09 +08:00
|
|
|
"test_reshape_extended_dims_cpu",
|
2020-02-11 23:37:47 +08:00
|
|
|
"test_reshape_negative_dim_cpu",
|
|
|
|
"test_reshape_negative_extended_dims_cpu",
|
2020-01-29 23:41:09 +08:00
|
|
|
"test_reshape_one_dim_cpu",
|
|
|
|
"test_reshape_reduced_dims_cpu",
|
2020-01-28 23:21:08 +08:00
|
|
|
"test_reshape_reordered_all_dims_cpu",
|
2020-01-29 23:41:09 +08:00
|
|
|
"test_reshape_reordered_last_dims_cpu",
|
2020-02-11 23:37:47 +08:00
|
|
|
"test_reshape_zero_and_negative_dim_cpu",
|
2020-01-29 23:41:09 +08:00
|
|
|
"test_reshape_zero_dim_cpu",
|
2020-01-31 00:44:56 +08:00
|
|
|
|
|
|
|
# Transpose
|
|
|
|
"test_transpose_default_cpu",
|
|
|
|
"test_transpose_all_permutations_0_cpu",
|
|
|
|
"test_transpose_all_permutations_1_cpu",
|
|
|
|
"test_transpose_all_permutations_2_cpu",
|
|
|
|
"test_transpose_all_permutations_3_cpu",
|
|
|
|
"test_transpose_all_permutations_4_cpu",
|
|
|
|
"test_transpose_all_permutations_5_cpu",
|
2020-02-04 22:27:17 +08:00
|
|
|
|
2020-02-08 05:51:32 +08:00
|
|
|
# Conv
|
|
|
|
"test_basic_conv_without_padding_cpu",
|
2020-02-12 00:53:13 +08:00
|
|
|
"test_conv_with_strides_no_padding_cpu",
|
2020-02-08 05:51:32 +08:00
|
|
|
|
2020-02-04 22:27:17 +08:00
|
|
|
# Sign Op:
|
|
|
|
"test_sign_cpu",
|
2020-02-14 23:43:17 +08:00
|
|
|
|
|
|
|
# MatmulOp
|
|
|
|
"test_matmul_2d_cpu",
|
|
|
|
"test_matmul_3d_cpu",
|
|
|
|
"test_matmul_4d_cpu",
|
|
|
|
|
2020-02-21 00:45:40 +08:00
|
|
|
# BatchNormalization (test mode)
|
|
|
|
"test_batchnorm_epsilon_cpu",
|
|
|
|
"test_batchnorm_example_cpu",
|
|
|
|
|
2020-04-19 21:39:34 +08:00
|
|
|
# MaxPoolSingleOut
|
2020-03-05 03:27:21 +08:00
|
|
|
"test_maxpool_1d_default_cpu",
|
|
|
|
"test_maxpool_2d_ceil_cpu",
|
|
|
|
"test_maxpool_2d_default_cpu",
|
2020-03-18 21:55:50 +08:00
|
|
|
"test_maxpool_2d_dilations_cpu",
|
|
|
|
"test_maxpool_2d_pads_cpu",
|
|
|
|
"test_maxpool_2d_precomputed_pads_cpu",
|
|
|
|
"test_maxpool_2d_precomputed_same_upper_cpu",
|
|
|
|
"test_maxpool_2d_precomputed_strides_cpu",
|
|
|
|
"test_maxpool_2d_same_lower_cpu",
|
|
|
|
"test_maxpool_2d_same_upper_cpu",
|
2020-03-05 03:27:21 +08:00
|
|
|
"test_maxpool_2d_strides_cpu",
|
|
|
|
"test_maxpool_3d_default_cpu",
|
|
|
|
|
2020-04-19 21:39:34 +08:00
|
|
|
# AveragePool
|
|
|
|
"test_averagepool_1d_default_cpu",
|
|
|
|
"test_averagepool_2d_ceil_cpu",
|
|
|
|
"test_averagepool_2d_default_cpu",
|
|
|
|
"test_averagepool_2d_pads_count_include_pad_cpu",
|
|
|
|
"test_averagepool_2d_pads_cpu",
|
|
|
|
"test_averagepool_2d_precomputed_pads_count_include_pad_cpu",
|
|
|
|
"test_averagepool_2d_precomputed_pads_cpu",
|
|
|
|
"test_averagepool_2d_precomputed_same_upper_cpu",
|
|
|
|
"test_averagepool_2d_precomputed_strides_cpu",
|
|
|
|
"test_averagepool_2d_same_lower_cpu",
|
|
|
|
"test_averagepool_2d_same_upper_cpu",
|
|
|
|
"test_averagepool_2d_strides_cpu",
|
|
|
|
"test_averagepool_3d_default_cpu",
|
|
|
|
|
2020-05-13 21:08:06 +08:00
|
|
|
# LSTM
|
|
|
|
"test_lstm_defaults_cpu",
|
|
|
|
"test_lstm_with_initial_bias_cpu",
|
|
|
|
"test_lstm_with_peepholes_cpu",
|
|
|
|
|
2020-06-11 10:57:20 +08:00
|
|
|
# Split
|
|
|
|
"test_split_equal_parts_1d_cpu",
|
|
|
|
"test_split_equal_parts_2d_cpu",
|
|
|
|
"test_split_equal_parts_default_axis_cpu",
|
|
|
|
"test_split_variable_parts_1d_cpu",
|
|
|
|
"test_split_variable_parts_2d_cpu",
|
|
|
|
"test_split_variable_parts_default_axis_cpu",
|
Compiling Models with Large Constant Arrays (#146)
* PoC works.
* MNist works.
* Clean up.
* Fix test.
* Make Linux work.
* Use consistent symbol name.
* Fix variable name.
* Fix array addr access.
* Bug fix.
* Bug fix.
* install before running e2e tests.
* Fix build config.
* Use sudo when installing.
* Make embeddedDataLoader position independent.
* Enable ResNet50.
* Format code.
* Format MainUtil.
* Try not using sudo to install.
* Supply runtime dir via environment variable.
* Dump problematic operation.
* Dump entire function.
* Debug.
* Dump input.
* Dump constant op.
* Debug.
* Debug.
* Debug.
* Print to stderr.
* take care of endianness.
* Use endianness-aware execution session.
* Fix ZLinux error.
* Include warning when desired output endianness can't be deduced.
* Remove debug code.
* Remove debug code in shape inference.
* Support binary-decoder for testing constants packing.
* Support filename, move-to-file, elision-threshold configurations in constant packing pass for easy testing.
* Add lit test, fix lit test type mismatch.
* Add more consts packing tests.
* Ensure intermediate files are properly cleaned up.
* No need for constant elimination.
* Link with threading libraries.
* Remove debug code.
* Format code.
* More tests.
* test nit.
* Remove debug code.
* Reduce hard-coded constants.
* Use temporary and unique working directory for hosting model parameters.
* Test if it works.
* Try to find objcopy.
* Rename symbols using objcopy.
* Move sanitized name to linux section.
* Use verbose mode for debugging.
* Disambiguate pass constructor.
* Fix symbol name.
* Use Command API to build and execute commands.
* Move linux to use Command API.
* Fix reset args.
* Execute redefine sym.
* Format code.
* Do not use verbose mode for CircleCI.
* Remove debug code.
* Prettify code, add comments.
* getSegmentData -> getEmbeddedConstPool
* vector -> std::vector.
* Make sure we properly clean up intermediate files.
* Fix test cases.
* Add runtime directory.
* Trigger rebuild.
* [Merge with master] fix debug script.
* Diable affine fusion pass for now.
* Support generic fallback const packing mechanism.
* Remove debug code.
* Handle the case where objcopy is not available.
* Fix Windows missing types.
* Support int64.
* Copy packed constant to a local directory for non-Linux/Mac platforms.
* Nit: remove debug code, refactor const pack preprocessing out as a separate function.
* Cannot make preprocessConstPack a standalone function because file removers are stack-allocated, and they are deallocated prematurely when function stack gets popped, deleteing intermediate files too early.
* Don't require executable filename.
* Import ONNX data types directly.
* Fix LIT test.
* Bug fix, use moved string value.
* Remove redundant filenames.
* Fix CMake script.
* Embed endianness information as a symbol, and check during runtime.
* More comments, update lit tests.
* Fix lit test on BE machine.
* Copyright notices.
2020-06-12 10:27:05 +08:00
|
|
|
|
|
|
|
# ResNet
|
|
|
|
"test_resnet50_cpu",
|
2019-12-22 13:25:02 +08:00
|
|
|
]
|
|
|
|
|
2020-06-11 10:57:20 +08:00
|
|
|
|
2019-12-22 13:25:02 +08:00
|
|
|
# Extract name of all test cases.
|
|
|
|
import inspect
|
Compiling Models with Large Constant Arrays (#146)
* PoC works.
* MNist works.
* Clean up.
* Fix test.
* Make Linux work.
* Use consistent symbol name.
* Fix variable name.
* Fix array addr access.
* Bug fix.
* Bug fix.
* install before running e2e tests.
* Fix build config.
* Use sudo when installing.
* Make embeddedDataLoader position independent.
* Enable ResNet50.
* Format code.
* Format MainUtil.
* Try not using sudo to install.
* Supply runtime dir via environment variable.
* Dump problematic operation.
* Dump entire function.
* Debug.
* Dump input.
* Dump constant op.
* Debug.
* Debug.
* Debug.
* Print to stderr.
* take care of endianness.
* Use endianness-aware execution session.
* Fix ZLinux error.
* Include warning when desired output endianness can't be deduced.
* Remove debug code.
* Remove debug code in shape inference.
* Support binary-decoder for testing constants packing.
* Support filename, move-to-file, elision-threshold configurations in constant packing pass for easy testing.
* Add lit test, fix lit test type mismatch.
* Add more consts packing tests.
* Ensure intermediate files are properly cleaned up.
* No need for constant elimination.
* Link with threading libraries.
* Remove debug code.
* Format code.
* More tests.
* test nit.
* Remove debug code.
* Reduce hard-coded constants.
* Use temporary and unique working directory for hosting model parameters.
* Test if it works.
* Try to find objcopy.
* Rename symbols using objcopy.
* Move sanitized name to linux section.
* Use verbose mode for debugging.
* Disambiguate pass constructor.
* Fix symbol name.
* Use Command API to build and execute commands.
* Move linux to use Command API.
* Fix reset args.
* Execute redefine sym.
* Format code.
* Do not use verbose mode for CircleCI.
* Remove debug code.
* Prettify code, add comments.
* getSegmentData -> getEmbeddedConstPool
* vector -> std::vector.
* Make sure we properly clean up intermediate files.
* Fix test cases.
* Add runtime directory.
* Trigger rebuild.
* [Merge with master] fix debug script.
* Diable affine fusion pass for now.
* Support generic fallback const packing mechanism.
* Remove debug code.
* Handle the case where objcopy is not available.
* Fix Windows missing types.
* Support int64.
* Copy packed constant to a local directory for non-Linux/Mac platforms.
* Nit: remove debug code, refactor const pack preprocessing out as a separate function.
* Cannot make preprocessConstPack a standalone function because file removers are stack-allocated, and they are deallocated prematurely when function stack gets popped, deleteing intermediate files too early.
* Don't require executable filename.
* Import ONNX data types directly.
* Fix LIT test.
* Bug fix, use moved string value.
* Remove redundant filenames.
* Fix CMake script.
* Embed endianness information as a symbol, and check during runtime.
* More comments, update lit tests.
* Fix lit test on BE machine.
* Copyright notices.
2020-06-12 10:27:05 +08:00
|
|
|
all_tests = []
|
|
|
|
all_tests += inspect.getmembers(
|
|
|
|
backend_test.test_cases["OnnxBackendRealModelTest"])
|
|
|
|
all_tests += inspect.getmembers(
|
2019-12-22 13:25:02 +08:00
|
|
|
backend_test.test_cases["OnnxBackendNodeModelTest"])
|
|
|
|
all_test_names = list(map(lambda x: x[0], all_tests))
|
2020-01-21 01:30:08 +08:00
|
|
|
|
|
|
|
# Ensure that test names specified in test_to_enable actually exist.
|
2019-12-22 13:25:02 +08:00
|
|
|
for test_name in test_to_enable:
|
2020-01-31 00:44:56 +08:00
|
|
|
assert test_name in all_test_names, """test name {} not found, it is likely
|
|
|
|
that you may have misspelled the test name or the specified test does not
|
Compiling Models with Large Constant Arrays (#146)
* PoC works.
* MNist works.
* Clean up.
* Fix test.
* Make Linux work.
* Use consistent symbol name.
* Fix variable name.
* Fix array addr access.
* Bug fix.
* Bug fix.
* install before running e2e tests.
* Fix build config.
* Use sudo when installing.
* Make embeddedDataLoader position independent.
* Enable ResNet50.
* Format code.
* Format MainUtil.
* Try not using sudo to install.
* Supply runtime dir via environment variable.
* Dump problematic operation.
* Dump entire function.
* Debug.
* Dump input.
* Dump constant op.
* Debug.
* Debug.
* Debug.
* Print to stderr.
* take care of endianness.
* Use endianness-aware execution session.
* Fix ZLinux error.
* Include warning when desired output endianness can't be deduced.
* Remove debug code.
* Remove debug code in shape inference.
* Support binary-decoder for testing constants packing.
* Support filename, move-to-file, elision-threshold configurations in constant packing pass for easy testing.
* Add lit test, fix lit test type mismatch.
* Add more consts packing tests.
* Ensure intermediate files are properly cleaned up.
* No need for constant elimination.
* Link with threading libraries.
* Remove debug code.
* Format code.
* More tests.
* test nit.
* Remove debug code.
* Reduce hard-coded constants.
* Use temporary and unique working directory for hosting model parameters.
* Test if it works.
* Try to find objcopy.
* Rename symbols using objcopy.
* Move sanitized name to linux section.
* Use verbose mode for debugging.
* Disambiguate pass constructor.
* Fix symbol name.
* Use Command API to build and execute commands.
* Move linux to use Command API.
* Fix reset args.
* Execute redefine sym.
* Format code.
* Do not use verbose mode for CircleCI.
* Remove debug code.
* Prettify code, add comments.
* getSegmentData -> getEmbeddedConstPool
* vector -> std::vector.
* Make sure we properly clean up intermediate files.
* Fix test cases.
* Add runtime directory.
* Trigger rebuild.
* [Merge with master] fix debug script.
* Diable affine fusion pass for now.
* Support generic fallback const packing mechanism.
* Remove debug code.
* Handle the case where objcopy is not available.
* Fix Windows missing types.
* Support int64.
* Copy packed constant to a local directory for non-Linux/Mac platforms.
* Nit: remove debug code, refactor const pack preprocessing out as a separate function.
* Cannot make preprocessConstPack a standalone function because file removers are stack-allocated, and they are deallocated prematurely when function stack gets popped, deleteing intermediate files too early.
* Don't require executable filename.
* Import ONNX data types directly.
* Fix LIT test.
* Bug fix, use moved string value.
* Remove redundant filenames.
* Fix CMake script.
* Embed endianness information as a symbol, and check during runtime.
* More comments, update lit tests.
* Fix lit test on BE machine.
* Copyright notices.
2020-06-12 10:27:05 +08:00
|
|
|
exist in the version of onnx package you installed.""".format(test_name)
|
2019-12-22 13:25:02 +08:00
|
|
|
backend_test.include(r"^{}$".format(test_name))
|
|
|
|
|
|
|
|
# import all test cases at global scope to make them visible to python.unittest
|
|
|
|
globals().update(backend_test.test_cases)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|