2023-07-21 12:29:50 +08:00
|
|
|
.PHONY : build clean format install-python test-cpp test-onnx
|
2023-02-12 08:23:49 +08:00
|
|
|
|
2023-08-18 12:17:47 +08:00
|
|
|
TYPE ?= Release
|
2023-04-18 15:10:33 +08:00
|
|
|
CUDA ?= OFF
|
|
|
|
BANG ?= OFF
|
2023-10-16 10:57:08 +08:00
|
|
|
KUNLUN ?= OFF
|
2023-10-20 14:08:39 +08:00
|
|
|
ASCEND ?= OFF
|
2023-04-17 12:15:23 +08:00
|
|
|
INTELCPU ?= off
|
2023-04-18 15:10:33 +08:00
|
|
|
BACKTRACE ?= ON
|
|
|
|
TEST ?= ON
|
2024-02-01 15:02:02 +08:00
|
|
|
DIST ?= OFF
|
2023-11-03 13:21:49 +08:00
|
|
|
NNET ?= OFF
|
2024-02-29 11:48:35 +08:00
|
|
|
DIST ?= OFF
|
2023-07-21 12:29:50 +08:00
|
|
|
FORMAT_ORIGIN ?=
|
2023-08-26 21:02:57 +08:00
|
|
|
# Docker build options
|
|
|
|
DOCKER_NAME ?= infinitensor
|
|
|
|
DOCKER_IMAGE_NAME ?= infinitensor
|
|
|
|
DOCKER_FILE ?= infinitensor_ubuntu_22.04.dockerfile
|
2023-11-03 13:21:49 +08:00
|
|
|
DOCKER_RUN_OPTION ?=
|
2023-08-26 21:02:57 +08:00
|
|
|
|
|
|
|
# CUDA option.
|
|
|
|
ifeq ($(CUDA), ON)
|
|
|
|
DOCKER_IMAGE_NAME = infinitensor_cuda
|
|
|
|
DOCKER_NAME = infinitensor_cuda
|
|
|
|
DOCKER_FILE = infinitensor_ubuntu_22.04_CUDA.dockerfile
|
|
|
|
DOCKER_RUN_OPTION += --gpus all -it --ipc=host --ulimit memlock=-1 --ulimit stack=67108864 -v `pwd`:`pwd` -w `pwd`
|
|
|
|
endif
|
|
|
|
|
2023-04-18 15:10:33 +08:00
|
|
|
CMAKE_OPT = -DCMAKE_BUILD_TYPE=$(TYPE)
|
|
|
|
CMAKE_OPT += -DUSE_CUDA=$(CUDA)
|
|
|
|
CMAKE_OPT += -DUSE_BANG=$(BANG)
|
2023-10-16 10:57:08 +08:00
|
|
|
CMAKE_OPT += -DUSE_KUNLUN=$(KUNLUN)
|
2023-10-20 14:08:39 +08:00
|
|
|
CMAKE_OPT += -DUSE_ASCEND=$(ASCEND)
|
2023-04-18 15:10:33 +08:00
|
|
|
CMAKE_OPT += -DUSE_BACKTRACE=$(BACKTRACE)
|
|
|
|
CMAKE_OPT += -DBUILD_TEST=$(TEST)
|
2024-02-01 15:02:02 +08:00
|
|
|
CMAKE_OPT += -DBUILD_DIST=$(DIST)
|
2023-11-03 13:21:49 +08:00
|
|
|
CMAKE_OPT += -DBUILD_NNET=$(NNET)
|
2023-02-12 08:23:49 +08:00
|
|
|
|
2023-04-17 12:15:23 +08:00
|
|
|
ifeq ($(INTELCPU), ON)
|
|
|
|
CMAKE_OPT += -DUSE_INTELCPU=ON -DCMAKE_CXX_COMPILER=dpcpp
|
|
|
|
endif
|
|
|
|
|
2023-02-12 08:23:49 +08:00
|
|
|
build:
|
|
|
|
mkdir -p build/$(TYPE)
|
2023-04-18 00:26:36 +08:00
|
|
|
cd build/$(TYPE) && cmake $(CMAKE_OPT) ../.. && make -j8
|
2023-02-12 08:23:49 +08:00
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -rf build
|
|
|
|
|
2023-07-21 12:29:50 +08:00
|
|
|
format:
|
|
|
|
@python3 scripts/format.py $(FORMAT_ORIGIN)
|
|
|
|
|
2023-02-12 08:23:49 +08:00
|
|
|
install-python: build
|
|
|
|
cp build/$(TYPE)/backend*.so pyinfinitensor/src/pyinfinitensor
|
2023-08-18 12:17:47 +08:00
|
|
|
pip install -e pyinfinitensor/
|
2023-02-12 08:23:49 +08:00
|
|
|
|
2023-07-06 16:57:10 +08:00
|
|
|
test-cpp:
|
2023-02-12 08:23:49 +08:00
|
|
|
@echo
|
|
|
|
cd build/$(TYPE) && make test
|
|
|
|
|
|
|
|
test-onnx:
|
|
|
|
@echo
|
|
|
|
python3 pyinfinitensor/tests/test_onnx.py
|
2023-08-26 21:02:57 +08:00
|
|
|
|
2023-09-15 16:40:44 +08:00
|
|
|
test-api:
|
|
|
|
@echo
|
|
|
|
python3 pyinfinitensor/tests/test_api.py
|
|
|
|
|
2023-11-03 13:21:49 +08:00
|
|
|
docker-build:
|
2023-08-26 21:02:57 +08:00
|
|
|
docker build -f scripts/dockerfile/$(DOCKER_FILE) -t $(DOCKER_NAME) .
|
|
|
|
|
|
|
|
docker-run:
|
|
|
|
docker run -t --name $(DOCKER_IMAGE_NAME) -d $(DOCKER_NAME) $(DOCKER_RUN_OPTION)
|
|
|
|
|
|
|
|
docker-start:
|
|
|
|
docker start $(DOCKER_IMAGE_NAME)
|
|
|
|
|
|
|
|
docker-exec:
|
|
|
|
docker exec -it $(DOCKER_IMAGE_NAME) bash
|