Misc fixes for MacOS. (#255)

* Change aligned_alloc -> malloc. It can fail (and does on MacOS) and is a bit over-aggressive optimization for a reference backend.
* Fixed a fragile test that prints -0.0 on MacOS.
* Fail the test (not the framework) on failure to trace (Torch on MacOS is missing features).
* Fix .so -> .dylib for compiler runtime.
pull/256/head
Stella Laurenzo 2021-07-27 17:48:47 -07:00 committed by GitHub
parent 2dbab50444
commit ec611c1e6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 35 deletions

View File

@ -227,9 +227,9 @@ def run_tests(tests: List[Test], config: TestConfig) -> List[TestResult]:
"""Invoke the given `Test`'s with the provided `TestConfig`.""" """Invoke the given `Test`'s with the provided `TestConfig`."""
results = [] results = []
for test in tests: for test in tests:
golden_trace = _generate_golden_trace(test)
# TODO: Precompile everything in parallel. # TODO: Precompile everything in parallel.
try: try:
golden_trace = _generate_golden_trace(test)
compiled = config.compile(test.program_factory()) compiled = config.compile(test.program_factory())
except Exception as e: except Exception as e:
results.append( results.append(

View File

@ -488,7 +488,8 @@ RtValue refbackrt::createRtValueFromOutputArgInfo(const OutputArgInfo &info) {
switch (info.elementType) { switch (info.elementType) {
case ElementType::F32: { case ElementType::F32: {
auto byteSize = numel * sizeof(float); auto byteSize = numel * sizeof(float);
data = static_cast<void *>(aligned_alloc(32, byteSize)); data = static_cast<void *>(malloc(byteSize));
assert(data && "could not allocate tensor");
memset(data, 0, byteSize); memset(data, 0, byteSize);
return RtValue(Tensor::create(shape, ElementType::F32, data)); return RtValue(Tensor::create(shape, ElementType::F32, data));
break; break;

View File

@ -3,6 +3,7 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
import os import os
import platform
_refjit = None _refjit = None
@ -40,7 +41,11 @@ def is_enabled() -> bool:
def get_runtime_libs(): def get_runtime_libs():
# The _refjit_resources directory is at the npcomp.compiler level. # The _refjit_resources directory is at the npcomp.compiler level.
resources_dir = os.path.join(os.path.dirname(__file__)) resources_dir = os.path.join(os.path.dirname(__file__))
return [os.path.join(resources_dir, "libNPCOMPCompilerRuntimeShlib.so")] suffix = ".so"
if platform.system() == "Darwin":
suffix = ".dylib"
shlib_name = f"libNPCOMPCompilerRuntimeShlib{suffix}"
return [os.path.join(resources_dir, shlib_name)]
class JitModuleInvoker: class JitModuleInvoker:

View File

@ -465,7 +465,7 @@ class ArrayParams:
Traceback (most recent call last): Traceback (most recent call last):
... ...
ValueError: ArrayParams(dtype=Unspec) is not concrete ValueError: ArrayParams(dtype=Unspec) is not concrete
>>> ArrayParams(np.float32, (1, 2)).new_ndarray() * 0.0 >>> (ArrayParams(np.float32, (1, 2)).new_ndarray() * 0.0 + 1.0) * 0.0
array([[0., 0.]], dtype=float32) array([[0., 0.]], dtype=float32)
""" """
if not self.is_concrete: if not self.is_concrete: