Skip to content

Commit

Permalink
Added install instructions in README
Browse files Browse the repository at this point in the history
  • Loading branch information
fredyshox committed Apr 22, 2022
1 parent 5d5ea4f commit d5b82af
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ Currently only compatible with Apple Silicon macs - M1 series is equivalent to A

CoreML runtime partitions neural network computation graph based on operations and complexity with focus on performance. Segments of a model with operations which are not supported by the neural engine will be assigned to be run on other compute unit. Switching between compute units can be expensive, that's why tuning a model to be fully ane-friendly is one of ways to maximize performance.

## Install

Program can be installed via [Homebrew](https://brew.sh/):
```sh
brew tap fredyshox/tools
brew install anecompat
```

Optional python bindings can be installed by downloading repository sources and running [setup.py](./setup.py) script:
```sh
# if anecompat was installed via homebrew, use python3 distribution from there too
python3 setup.py install
```

## Usage

Tool supports models with multiple inputs or outputs. Supported feature types for input: multi-array, image, int64, float, string.
Expand Down Expand Up @@ -74,4 +88,10 @@ Clone repository, then from project directory execute:
make
```

`build/` directory will be created with artifacts: `anecompat` executable and `libANECompat.dylib` shared library.
`build/` directory will be created with artifacts: `anecompat` executable and `libANECompat.dylib` shared library.

To install compiled artifacts execute:

```
make install
```
10 changes: 7 additions & 3 deletions python/anecompat.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@


def _load_ane_compat_dylib():
dylib_path = ctypes.util.find_library("ANECompat")
if dylib_path is None:
def _alternative_dylib_lookup():
# search local directories first
repo_root_dir = os.path.dirname(os.path.dirname(__file__))
local_paths = glob(os.path.join(repo_root_dir, "**", "libANECompat.dylib"))
if len(local_paths) != 0:
dylib_path = local_paths[0]
return local_paths[0]

return None

dylib_path = ctypes.util.find_library("ANECompat") or _alternative_dylib_lookup()

if dylib_path is not None:
return ctypes.CDLL(dylib_path)
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
license="MIT",
py_modules=["anecompat"],
package_dir={"": "python"},
classifiers=(
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: MacOS",
)
]
)

0 comments on commit d5b82af

Please sign in to comment.