diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e624f1..c993e7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,25 +35,25 @@ option(SD_BUILD_SHARED_LIBS "sd: build shared libs" OFF) #option(SD_BUILD_SERVER "sd: build server example" ON) if(SD_CUBLAS) - message("Use CUBLAS as backend stable-diffusion") + message("-- Use CUBLAS as backend stable-diffusion") set(GGML_CUDA ON) add_definitions(-DSD_USE_CUBLAS) endif() if(SD_METAL) - message("Use Metal as backend stable-diffusion") + message("-- Use Metal as backend stable-diffusion") set(GGML_METAL ON) add_definitions(-DSD_USE_METAL) endif() if (SD_VULKAN) - message("Use Vulkan as backend stable-diffusion") + message("-- Use Vulkan as backend stable-diffusion") set(GGML_VULKAN ON) add_definitions(-DSD_USE_VULKAN) endif () if (SD_HIPBLAS) - message("Use HIPBLAS as backend stable-diffusion") + message("-- Use HIPBLAS as backend stable-diffusion") set(GGML_HIPBLAS ON) add_definitions(-DSD_USE_CUBLAS) if(SD_FAST_SOFTMAX) @@ -61,14 +61,8 @@ if (SD_HIPBLAS) endif() endif () -if(SD_SYCL) - message("Use SYCL as backend stable-diffusion") - set(GGML_SYCL ON) - add_definitions(-DSD_USE_SYCL) -endif() - if(SD_FLASH_ATTN) - message("Use Flash Attention for memory optimization") + message("-- Use Flash Attention for memory optimization") add_definitions(-DSD_USE_FLASH_ATTENTION) endif() @@ -82,7 +76,7 @@ file(GLOB SD_LIB_SOURCES # we can get only one share lib if(SD_BUILD_SHARED_LIBS) - message("Build shared library") + message("-- Build shared library") message(${SD_LIB_SOURCES}) set(BUILD_SHARED_LIBS OFF) add_library(${SD_LIB} SHARED ${SD_LIB_SOURCES}) @@ -90,11 +84,25 @@ if(SD_BUILD_SHARED_LIBS) target_compile_definitions(${SD_LIB} PRIVATE -DSD_BUILD_DLL) set(CMAKE_POSITION_INDEPENDENT_CODE ON) else() - message("Build static library") + message("-- Build static library") set(BUILD_SHARED_LIBS OFF) add_library(${SD_LIB} STATIC ${SD_LIB_SOURCES}) endif() +if(SD_SYCL) + message("-- Use SYCL as backend stable-diffusion") + set(GGML_SYCL ON) + add_definitions(-DSD_USE_SYCL) + # disable fast-math on host, see: + # https://www.intel.com/content/www/us/en/docs/cpp-compiler/developer-guide-reference/2021-10/fp-model-fp.html + if (WIN32) + set(SYCL_COMPILE_OPTIONS /fp:precise) + else() + set(SYCL_COMPILE_OPTIONS -fp-model=precise) + endif() + message("-- Turn off fast-math for host in SYCL backend") + target_compile_options(${SD_LIB} PRIVATE ${SYCL_COMPILE_OPTIONS}) +endif() set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) diff --git a/README.md b/README.md index 7a42ccc..0fe607e 100644 --- a/README.md +++ b/README.md @@ -172,14 +172,12 @@ Example of text2img by using SYCL backend: - download `stable-diffusion` model weight, refer to [download-weight](#download-weights). -- run `./bin/sd -m ../models/sd3_medium_incl_clips_t5xxlfp16.safetensors --cfg-scale 5 --steps 30 --sampling-method euler -H 512 -W 512 --seed 42 -p "fantasy medieval village world inside a glass sphere , high detail, fantasy, realistic, light effect, hyper detail, volumetric lighting, cinematic, macro, depth of field, blur, red light and clouds from the back, highly detailed epic cinematic concept art cg render made in maya, blender and photoshop, octane render, excellent composition, dynamic dramatic cinematic lighting, aesthetic, very inspirational, world inside a glass sphere by james gurney by artgerm with james jean, joe fenton and tristan eaton by ross tran, fine details, 4k resolution"` +- run `./bin/sd -m ../models/sd3_medium_incl_clips_t5xxlfp16.safetensors --cfg-scale 5 --steps 30 --sampling-method euler -H 1024 -W 1024 --seed 42 -p "fantasy medieval village world inside a glass sphere , high detail, fantasy, realistic, light effect, hyper detail, volumetric lighting, cinematic, macro, depth of field, blur, red light and clouds from the back, highly detailed epic cinematic concept art cg render made in maya, blender and photoshop, octane render, excellent composition, dynamic dramatic cinematic lighting, aesthetic, very inspirational, world inside a glass sphere by james gurney by artgerm with james jean, joe fenton and tristan eaton by ross tran, fine details, 4k resolution"`