diff --git a/.github/actions/install-cmake-linux/action.yml b/.github/actions/install-cmake-linux/action.yml new file mode 100644 index 000000000..50d43583f --- /dev/null +++ b/.github/actions/install-cmake-linux/action.yml @@ -0,0 +1,11 @@ +name: Install protobuf linux +runs: + using: composite + steps: + - name: Install protobuf linux + shell: bash + run: | + apt-get -yq update && apt-get install -y build-essential unzip libssl-dev + curl -fsSL http://cmake.org/files/v3.19/cmake-3.19.0.tar.gz | tar xz && cd cmake-3.19.0 + ./configure --prefix=/opt/cmake && make -j2 && make install && cd .. && rm -r cmake-3.19.0 + echo "/opt/cmake/bin" >> $GITHUB_PATH \ No newline at end of file diff --git a/.github/workflows/build-android-x86_64.yml b/.github/workflows/build-android-x86_64.yml index 31a01bed7..4f02dbf4f 100644 --- a/.github/workflows/build-android-x86_64.yml +++ b/.github/workflows/build-android-x86_64.yml @@ -18,6 +18,7 @@ jobs: ndk-version: r18b - uses: actions/checkout@v2 - uses: ./.github/actions/install-protobuf-linux + - uses: ./.github/actions/install-cmake-linux - name: Set up Java for publishing to GitHub Packages uses: actions/setup-java@v1 with: diff --git a/.github/workflows/build-deploy-android-arm32.yml b/.github/workflows/build-deploy-android-arm32.yml index 2977bb4c6..edd06604b 100644 --- a/.github/workflows/build-deploy-android-arm32.yml +++ b/.github/workflows/build-deploy-android-arm32.yml @@ -15,6 +15,7 @@ jobs: access_token: ${{ github.token }} - uses: actions/checkout@v2 - uses: ./.github/actions/install-protobuf-linux + - uses: ./.github/actions/install-cmake-linux - name: Set up Java for publishing to GitHub Packages uses: actions/setup-java@v1 with: diff --git a/.github/workflows/build-deploy-android-arm64.yml b/.github/workflows/build-deploy-android-arm64.yml index 42a7b8bd1..972cbb190 100644 --- a/.github/workflows/build-deploy-android-arm64.yml +++ b/.github/workflows/build-deploy-android-arm64.yml @@ -15,6 +15,7 @@ jobs: access_token: ${{ github.token }} - uses: actions/checkout@v2 - uses: ./.github/actions/install-protobuf-linux + - uses: ./.github/actions/install-cmake-linux - name: Set up Java for publishing to GitHub Packages uses: actions/setup-java@v1 with: diff --git a/.github/workflows/build-deploy-linux-arm32.yml b/.github/workflows/build-deploy-linux-arm32.yml index aa1e4d044..32921fbce 100644 --- a/.github/workflows/build-deploy-linux-arm32.yml +++ b/.github/workflows/build-deploy-linux-arm32.yml @@ -15,6 +15,7 @@ jobs: access_token: ${{ github.token }} - uses: actions/checkout@v2 - uses: ./.github/actions/install-protobuf-linux + - uses: ./.github/actions/install-cmake-linux - name: Set up Java for publishing to GitHub Packages uses: actions/setup-java@v1 with: diff --git a/.github/workflows/build-deploy-linux-arm64.yml b/.github/workflows/build-deploy-linux-arm64.yml index 57ae23b86..0b1a5f7c0 100644 --- a/.github/workflows/build-deploy-linux-arm64.yml +++ b/.github/workflows/build-deploy-linux-arm64.yml @@ -15,6 +15,7 @@ jobs: access_token: ${{ github.token }} - uses: actions/checkout@v2 - uses: ./.github/actions/install-protobuf-linux + - uses: ./.github/actions/install-cmake-linux - name: Set up Java for publishing to GitHub Packages uses: actions/setup-java@v1 with: diff --git a/.github/workflows/build-deploy-linux-cuda-11.0.yml b/.github/workflows/build-deploy-linux-cuda-11.0.yml index 63d5c2d46..b88743d09 100644 --- a/.github/workflows/build-deploy-linux-cuda-11.0.yml +++ b/.github/workflows/build-deploy-linux-cuda-11.0.yml @@ -25,6 +25,7 @@ jobs: cuda: 11.0.167 GCC: 9 - uses: ./.github/actions/install-protobuf-linux + - uses: ./.github/actions/install-cmake-linux - name: Set up Java for publishing to GitHub Packages uses: actions/setup-java@v1 with: diff --git a/.github/workflows/build-deploy-linux-cuda-11.2.yml b/.github/workflows/build-deploy-linux-cuda-11.2.yml index 96a8a7ccc..b4039a89a 100644 --- a/.github/workflows/build-deploy-linux-cuda-11.2.yml +++ b/.github/workflows/build-deploy-linux-cuda-11.2.yml @@ -24,6 +24,7 @@ jobs: cuda: 11.2.1_461 GCC: 9 - uses: ./.github/actions/install-protobuf-linux + - uses: ./.github/actions/install-cmake-linux - name: Set up Java for publishing to GitHub Packages uses: actions/setup-java@v1 with: diff --git a/.github/workflows/build-deploy-linux-x86_64.yml b/.github/workflows/build-deploy-linux-x86_64.yml index 35528f500..20100df1f 100644 --- a/.github/workflows/build-deploy-linux-x86_64.yml +++ b/.github/workflows/build-deploy-linux-x86_64.yml @@ -14,6 +14,7 @@ jobs: access_token: ${{ github.token }} - uses: actions/checkout@v2 - uses: ./.github/actions/install-protobuf-linux + - uses: ./.github/actions/install-cmake-linux - name: Set up Java for publishing to GitHub Packages uses: actions/setup-java@v1 with: @@ -38,6 +39,6 @@ jobs: protoc --version sudo apt-get autoremove sudo apt-get clean - mvn -X -Possrh -Djavacpp.platform=linux-x86_64 -Dlibnd4j.chip=cpu -Pcpu --batch-mode deploy -DskipTests + mvn -X -Possrh -pl :nd4j-tests -Djavacpp.platform=linux-x86_64 -Dlibnd4j.chip=cpu -Pcpu --batch-mode clean test -Dtest=org.nd4j.smoketests.SmokeTest diff --git a/.github/workflows/test_multiple_arch.yaml b/.github/workflows/test_multiple_arch.yaml new file mode 100644 index 000000000..3e66ba9df --- /dev/null +++ b/.github/workflows/test_multiple_arch.yaml @@ -0,0 +1,63 @@ +on: + push: +jobs: + build_and_test_cross_platform: + # The host should always be linux + runs-on: ubuntu-16.04 + name: Build on ${{ matrix.distro }} ${{ matrix.arch }} + + # Run steps on a matrix of 2 arch/distro combinations + strategy: + fail-fast: false + matrix: + include: + - arch: aarch64 + distro: ubuntu16.04 + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.8.0 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v2 + - uses: ./.github/actions/download-dl4j-test-resources-linux + - uses: ./.github/actions/install-protobuf-linux + - uses: ./.github/actions/install-cmake-linux + - uses: uraimo/run-on-arch-action@v2.0.8 + name: Build and test with ${{ matrix.arch }} ${{ matrix.distro }} + id: build + with: + arch: ${{ matrix.arch }} + distro: ${{ matrix.distro }} + # Pass some environment variables to the container + env: | # YAML, but pipe character is necessary + DEBIAN_FRONTEND: noninteractive + M2_HOME: /opt/maven + + # The shell to run commands with in the container + shell: /bin/sh + run: | + echo "Running install on architecture ${{ matrix.arch }}" + apt-get -yq update && apt-get install -y build-essential unzip libssl-dev + echo "After install on architecture ${{ matrix.arch }}" + export PATH="/opt/maven/bin:$PATH" + echo "RUNNING ARCH ${{ matrix.arch }}" + case "${{ matrix.arch }}" in + armv7) + export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-armhf/jre + ;; + aarch64) + export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-arm64/jre" + ;; + ppc64le) + export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-ppc64el/jre + ;; + esac + mvn --version + export PATH="/opt/cmake/bin:/opt/maven/bin:/opt/protobuf/bin:$PATH" + cmake --version + echo "Running build in ${pwd}" + mvn -Ptestresources -Ptest-nd4j-native -Dlibnd4j.chip=cpu clean test + + + + diff --git a/nd4j/nd4j-backends/nd4j-tests/src/test/java/org/nd4j/smoketests/SmokeTest.java b/nd4j/nd4j-backends/nd4j-tests/src/test/java/org/nd4j/smoketests/SmokeTest.java new file mode 100644 index 000000000..91419ebef --- /dev/null +++ b/nd4j/nd4j-backends/nd4j-tests/src/test/java/org/nd4j/smoketests/SmokeTest.java @@ -0,0 +1,59 @@ +/* + * + * * ****************************************************************************** + * * * + * * * + * * * This program and the accompanying materials are made available under the + * * * terms of the Apache License, Version 2.0 which is available at + * * * https://www.apache.org/licenses/LICENSE-2.0. + * * * + * * * See the NOTICE file distributed with this work for additional + * * * information regarding copyright ownership. + * * * Unless required by applicable law or agreed to in writing, software + * * * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * * * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * * * License for the specific language governing permissions and limitations + * * * under the License. + * * * + * * * SPDX-License-Identifier: Apache-2.0 + * * ***************************************************************************** + * + * + */ + +package org.nd4j.smoketests; + +import lombok.extern.slf4j.Slf4j; +import org.junit.Test; +import org.nd4j.linalg.api.buffer.DataType; +import org.nd4j.linalg.api.ndarray.INDArray; +import org.nd4j.linalg.factory.Nd4j; +import org.nd4j.linalg.profiler.ProfilerConfig; + +@Slf4j +public class SmokeTest { + + + @Test + public void testBasic() { + Nd4j.getEnvironment().setDebug(true); + Nd4j.getExecutioner().setProfilingConfig(ProfilerConfig.builder() + .checkForNAN(true) + .checkForINF(true) + .checkLocality(true) + .checkElapsedTime(true) + .checkWorkspaces(true) + .build()); + INDArray arr = Nd4j.randn(2,2); + INDArray arr2 = Nd4j.randn(2,2); + for(DataType dataType : DataType.values()) { + log.info("Testing matrix multiply on data type {}",dataType); + INDArray casted = arr.castTo(dataType); + INDArray casted2 = arr2.castTo(dataType); + INDArray result = casted.mmul(casted2); + log.info("Result for data type {} was {}",dataType,result); + + } + } + +}