Add smoke test for cross platform

master
agibsonccc 2021-03-10 13:45:45 +09:00
parent 0b1d650c61
commit 46c3de2382
11 changed files with 142 additions and 1 deletions

View File

@ -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

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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

View File

@ -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

View File

@ -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);
}
}
}