Skip to content

Commit

Permalink
Fix extension when looking for mlir_c_runner library (#649)
Browse files Browse the repository at this point in the history
**Context:** When merging callbacks, something that was an oversight was
the extension of shared libraries in different operating systems. In
Darwin, the extension is `.dylib`. In unix, it is `.so`.

**Description of the Change:** This commit selects the correct extension
based on the operating system that the code is being run.

**Benefits:** No errors on tests.
  • Loading branch information
erick-xanadu authored Apr 10, 2024
1 parent a3562a4 commit 3f155a2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
[(#596)](https://github.com/PennyLaneAI/catalyst/pull/596)
[(#610)](https://github.com/PennyLaneAI/catalyst/pull/610)
[(#650)](https://github.com/PennyLaneAI/catalyst/pull/650)
[(#649)](https://github.com/PennyLaneAI/catalyst/pull/649)

Catalyst now supports callbacks with parameters and return values.
The following is now possible:
Expand Down
15 changes: 14 additions & 1 deletion runtime/lib/registry/Registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,19 @@ class LibraryManager {
}
};

inline const char *ext()
{
#ifdef __APPLE__
return ".dylib";
#elif __linux__
return ".so";
#else
#error "Only apple and linux are currently supported";
#endif
}

std::string library_name(std::string name) { return name + ext(); }

void convertResult(py::handle tuple)
{
py::object unrankedMemrefPtrSizeTuple = tuple.attr("__getitem__")(0);
Expand All @@ -91,7 +104,7 @@ void convertResult(py::handle tuple)
UnrankedMemrefType *src = (UnrankedMemrefType *)unranked_memref_ptr;
UnrankedMemrefType destMemref = {src->rank, destAsPtr};

std::string libpath = libmlirpath + "/libmlir_c_runner_utils.so";
std::string libpath = libmlirpath + library_name("/libmlir_c_runner_utils");
LibraryManager memrefCopy(libpath);
memrefCopy(e_size, src, &destMemref);
}
Expand Down

0 comments on commit 3f155a2

Please sign in to comment.