Skip to content

Commit

Permalink
[fasttext] Adds maxOS M1 supports
Browse files Browse the repository at this point in the history
  • Loading branch information
frankfliu committed Jun 7, 2023
1 parent 1e7684b commit 4ea8891
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 9 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/native_s3_fasttext.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,35 @@ jobs:
run: |
FASTTEXT_VERSION="$(cat gradle.properties | awk -F '=' '/fasttext_version/ {print $2}')"
aws s3 sync extensions/fasttext/jnilib s3://djl-ai/publish/fasttext-${FASTTEXT_VERSION}/jnilib/
build-fasttext-jni-arm64-osx:
if: ${{ github.repository == 'deepjavalibrary/djl' && always() }}
runs-on: [ self-hosted, ARM64, macOS ]
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: 11
distribution: corretto
architecture: aarch64
- uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Release JNI prep
run: |
./gradlew :extensions:fasttext:compileJNI
./gradlew -Pjni :extensions:fasttext:test
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- name: Copy files to S3 with the AWS CLI
run: |
FASTTEXT_VERSION="$(cat gradle.properties | awk -F '=' '/fasttext_version/ {print $2}')"
aws s3 sync extensions/fasttext/jnilib s3://djl-ai/publish/fasttext-${FASTTEXT_VERSION}/jnilib/
25 changes: 17 additions & 8 deletions extensions/fasttext/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,26 @@ set -e
WORK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
NUM_PROC=1
if [[ -n $(command -v nproc) ]]; then
NUM_PROC=$(nproc)
NUM_PROC=$(nproc)
elif [[ -n $(command -v sysctl) ]]; then
NUM_PROC=$(sysctl -n hw.ncpu)
NUM_PROC=$(sysctl -n hw.ncpu)
fi
PLATFORM=$(uname | tr '[:upper:]' '[:lower:]')

VERSION=v0.9.2

pushd "$WORK_DIR"
if [ ! -d "fastText" ];
then
if [ ! -d "fastText" ]; then
git clone https://github.com/facebookresearch/fastText.git -b $VERSION

if [[ $PLATFORM == 'darwin' ]]; then
if [[ $(uname -m) == 'arm64' ]]; then
sed -i '' -E "s/-march=native/-mcpu=apple-m1/g" fastText/CMakeLists.txt
fi
fi
fi

if [ ! -d "build" ];
then
if [ ! -d "build" ]; then
mkdir build
fi
cd build
Expand All @@ -33,8 +37,13 @@ popd

# for nightly ci
if [[ $PLATFORM == 'darwin' ]]; then
mkdir -p build/jnilib/osx-x86_64
cp -f build/libjni_fasttext.dylib build/jnilib/osx-x86_64/
if [[ $(uname -m) == 'arm64' ]]; then
mkdir -p build/jnilib/osx-aarch64
cp -f build/libjni_fasttext.dylib build/jnilib/osx-aarch64/
else
mkdir -p build/jnilib/osx-x86_64
cp -f build/libjni_fasttext.dylib build/jnilib/osx-x86_64/
fi
elif [[ $PLATFORM == 'linux' ]]; then
mkdir -p build/jnilib/linux-x86_64
cp -f build/libjni_fasttext.so build/jnilib/linux-x86_64/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public class CookingStackExchangeTest {
@BeforeClass
public void setUp() {
TestRequirements.notWindows(); // fastText is not supported on windows
TestRequirements.notArm();
}

@Test
Expand Down

0 comments on commit 4ea8891

Please sign in to comment.