Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve tests #15

Merged
merged 3 commits into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,16 @@ jobs:
run: |
docker buildx build --platform ${{ matrix.platform }} -f scripts/docker/${{ matrix.dockerfile }} -t ${{ matrix.tag }} . --load
if [ "${{ matrix.test }}" == "arm-neon" ]; then
docker run --platform ${{ matrix.platform }} ${{ matrix.tag }} /nn/build/tests/arch/arm/neon/neuron
TESTS=arch/arm/neon/dot_product_perf,arch/arm/neon/neuron,arch/arm/neon/neuron_perf
elif [ "${{ matrix.test }}" == "arm-cmsis-dsp" ]; then
docker run --platform ${{ matrix.platform }} ${{ matrix.tag }} /nn/build/tests/arch/arm/cmsis-dsp/neuron
TESTS=arch/arm/cmsis-dsp/dot_product_perf,arch/arm/cmsis-dsp/neuron,arch/arm/cmsis-dsp/neuron_perf
elif [ "${{ matrix.test }}" == "generic" ]; then
docker run --platform ${{ matrix.platform }} ${{ matrix.tag }} /nn/build/tests/arch/generic/neuron
TESTS=arch/generic/dot_product,arch/generic/dot_product_perf,arch/generic/layer,arch/generic/neuron,arch/generic/neuron_perf
else
echo "unknown test"
exit 1
fi
IFS=',' read -ra TESTS <<< "$TESTS"
for TEST in "${TESTS[@]}"; do
docker run --platform ${{ matrix.platform }} ${{ matrix.tag }} "/nn/build/tests/${TEST}"
done
28 changes: 20 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,34 @@ clean:
echo "build directory does not exist, skipping"; \
fi

## run-test Run a test (e.g., make run-test ARCH=generic TEST=arch/generic/neuron)
run-test:
## test Run tests (e.g., make test ARCH=generic)
test:
@$(MAKE) build-tests ARCH=$(ARCH) TECH=$(TECH)
@echo " "
@$(eval TESTS := $(shell find tests/arch/$(ARCH) -type f -name 'main.c' | grep -E "$(TECH_FILTER)" | sed 's|/main.c||' | sed 's|tests/||'))
@for test in $(TESTS); do \
$(MAKE) run-test ARCH=$(ARCH) TECH=$(TECH) TEST=$$test || exit 1; \
done

## build-test Build a test (e.g., make build-test ARCH=generic TEST=arch/generic/neuron)
build-test:
@echo building $(TEST)
@ARCH=$(ARCH) TECH=$(TECH) ARTIFACT=tests/$(TEST) scripts/shell/build_artifact.sh
@echo running $(TEST)
@ARCH=$(ARCH) TECH=$(TECH) ARTIFACT=tests/$(TEST) ARGS="$(ARGS)" scripts/shell/run_artifact.sh
@echo " "

## test Run tests (e.g., make test ARCH=generic)
test:
## build-tests Build tests (e.g., make build-tests ARCH=generic)
build-tests:
@$(eval TECH_FILTER := $(if $(TECH),$(shell echo $(TECH) | tr ',' '|'),.*))
@$(eval TESTS := $(shell find tests/arch/$(ARCH) -type f -name 'main.c' | grep -E "$(TECH_FILTER)" | sed 's|/main.c||' | sed 's|tests/||'))
@for test in $(TESTS); do \
$(MAKE) run-test ARCH=$(ARCH) TECH=$(TECH) TEST=$$test || exit 1; \
$(MAKE) build-test ARCH=$(ARCH) TECH=$(TECH) TEST=$$test || exit 1; \
done

## run-test Run a test (e.g., make run-test ARCH=generic TEST=arch/generic/neuron)
run-test:
@echo running $(TEST)
@ARCH=$(ARCH) TECH=$(TECH) ARTIFACT=tests/$(TEST) ARGS="$(ARGS)" scripts/shell/run_artifact.sh
@echo " "

## build-example Build an example (e.g., make build-example ARCH=generic EXAMPLE=arch/generic/neuron)
build-example:
@echo building $(EXAMPLE)
Expand Down
2 changes: 1 addition & 1 deletion scripts/docker/Dockerfile.arm-cmsis-dsp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
COPY . /nn
WORKDIR /nn
RUN make build-examples ARCH=arm TECH=cmsis-dsp LDFLAGS="-lm"
RUN make test ARCH=arm TECH=cmsis-dsp LDFLAGS="-lm"
RUN make build-tests ARCH=arm TECH=cmsis-dsp LDFLAGS="-lm"

# Runtime
FROM ubuntu:latest
Expand Down
2 changes: 1 addition & 1 deletion scripts/docker/Dockerfile.arm-neon
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
COPY . /nn
WORKDIR /nn
RUN make build-examples ARCH=arm TECH=neon LDFLAGS="-lm"
RUN make test ARCH=arm TECH=neon LDFLAGS="-lm"
RUN make build-tests ARCH=arm TECH=neon LDFLAGS="-lm"

# Runtime
FROM ubuntu:latest
Expand Down
2 changes: 1 addition & 1 deletion scripts/docker/Dockerfile.armv7-neon
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
COPY . /nn
WORKDIR /nn
RUN make build-examples ARCH=arm TECH=neon LDFLAGS="-lm" CFLAGS="-mfpu=neon-vfpv4"
RUN make test ARCH=arm TECH=neon LDFLAGS="-lm" CFLAGS="-mfpu=neon-vfpv4"
RUN make build-tests ARCH=arm TECH=neon LDFLAGS="-lm" CFLAGS="-mfpu=neon-vfpv4"

# Runtime
FROM arm32v7/ubuntu:latest
Expand Down
2 changes: 1 addition & 1 deletion scripts/docker/Dockerfile.armv8-neon
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
COPY . /nn
WORKDIR /nn
RUN make build-examples ARCH=arm TECH=neon LDFLAGS="-lm"
RUN make test ARCH=arm TECH=neon LDFLAGS="-lm"
RUN make build-tests ARCH=arm TECH=neon LDFLAGS="-lm"

# Runtime
FROM arm64v8/ubuntu:latest
Expand Down
2 changes: 1 addition & 1 deletion scripts/docker/Dockerfile.generic
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
COPY . /nn
WORKDIR /nn
RUN make build-examples ARCH=generic LDFLAGS="-lm"
RUN make test ARCH=generic LDFLAGS="-lm"
RUN make build-tests ARCH=generic LDFLAGS="-lm"

# Runtime
FROM ubuntu:latest
Expand Down
2 changes: 1 addition & 1 deletion tests/arch/arm/cmsis-dsp/neuron/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,6 @@ int main() {
.expected_output = 0.000012f,
},
};
run_test_cases(test_cases, N_TEST_CASES, "nn_dot_product_cmsis", nn_dot_product_cmsis);
run_test_cases(test_cases, N_TEST_CASES, "nn_neuron", nn_dot_product_cmsis);
return 0;
}
2 changes: 1 addition & 1 deletion tests/arch/arm/neon/neuron/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,6 @@ int main() {
.expected_output = 0.000012f,
},
};
run_test_cases(test_cases, N_TEST_CASES, "nn_dot_product_neon", nn_dot_product_neon);
run_test_cases(test_cases, N_TEST_CASES, "nn_neuron", nn_dot_product_neon);
return 0;
}
2 changes: 1 addition & 1 deletion tests/arch/generic/neuron/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,6 @@ int main() {
.expected_output = 0.000012f,
},
};
run_test_cases(test_cases, N_TEST_CASES, "nn_dot_product", nn_dot_product);
run_test_cases(test_cases, N_TEST_CASES, "nn_neuron", nn_dot_product);
return 0;
}
Loading