Skip to content

Commit f6473e6

Browse files
authored
macos + clang build (#897)
1 parent f034ebf commit f6473e6

File tree

4 files changed

+41
-38
lines changed

4 files changed

+41
-38
lines changed

CMakeLists.txt

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -168,18 +168,6 @@ IF(BUILD_ORT)
168168
ENDIF()
169169
ENDIF()
170170

171-
#----------------------------------------------------------------------------------------------
172-
173-
IF (APPLE)
174-
FIND_LIBRARY(MKL_LIBRARIES NAMES mklml
175-
PATHS ${depsAbs}/mkl/lib)
176-
IF (NOT MKL_LIBRARIES)
177-
MESSAGE(FATAL_ERROR "Could not find MKL for Mac")
178-
ENDIF()
179-
SET(platDeps "${MKL_LIBRARIES}")
180-
ENDIF()
181-
182-
#----------------------------------------------------------------------------------------------
183171

184172
IF(BUILD_TFLITE)
185173
# Find TensorFlow Lite stuff and build our wrapper
@@ -307,14 +295,6 @@ IF(BUILD_ORT)
307295
FILES_MATCHING PATTERN ${LIB_PATTERN})
308296
ENDIF()
309297

310-
#----------------------------------------------------------------------------------------------
311-
312-
IF (APPLE)
313-
INSTALL(DIRECTORY ${depsAbs}/mkl/lib DESTINATION ${installAbs}/backends/redisai_torch
314-
FILES_MATCHING PATTERN ${LIB_PATTERN})
315-
ENDIF()
316-
317-
#----------------------------------------------------------------------------------------------
318298

319299
IF (NOT ${installAbs} STREQUAL ${CMAKE_SOURCE_DIR}/install-${DEVICE})
320300
INSTALL_SYMLINK(${installAbs} ${CMAKE_SOURCE_DIR}/install-${DEVICE})

get_deps.sh

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,16 @@ if [[ $OS == linux ]]; then
144144
else
145145
echo "Only x64 is supported currently"
146146
fi
147-
else
148-
echo "Only Linux OS is supported currently"
147+
elif [[ $OS == macos ]]; then
148+
TF_OS=darwin
149+
TF_BUILD=cpu
150+
TF_ARCH=x86_64
151+
if [[ $WITH_TF == S3 ]]; then
152+
LIBTF_URL_BASE=https://s3.amazonaws.com/redismodules/tensorflow
153+
else
154+
LIBTF_URL_BASE=https://storage.googleapis.com/tensorflow/libtensorflow
155+
fi
156+
149157
fi
150158

151159
LIBTF_ARCHIVE=libtensorflow-${TF_BUILD}-${TF_OS}-${TF_ARCH}-${TF_VERSION}.tar.gz
@@ -163,11 +171,11 @@ if [[ $OS == linux ]]; then
163171
TFLITE_OS="linux"
164172
if [[ $ARCH == x64 ]]; then
165173
TFLITE_ARCH=x86_64
166-
else
167-
echo "Only x64 is supported currently"
168174
fi
169-
else
170-
echo "Only Linux OS is supported currently"
175+
elif [[ $OS == macos ]]; then
176+
TFLITE_OS=darwin
177+
# TFLITE_BUILD=cpu
178+
TFLITE_ARCH=x86_64
171179
fi
172180

173181
LIBTFLITE_ARCHIVE=libtensorflowlite-${TFLITE_OS}-${TFLITE_ARCH}-${TFLITE_VERSION}.tar.gz
@@ -191,15 +199,17 @@ if [[ $OS == linux ]]; then
191199
else
192200
echo "Only x64 is supported currently"
193201
fi
194-
else
195-
echo "Only Linux OS is supported currently"
202+
LIBTORCH_ARCHIVE=libtorch-cxx11-abi-shared-with-deps-${PT_VERSION}%2B${PT_BUILD}.zip
203+
204+
elif [[ $OS == macos ]]; then
205+
PT_OS=macos
206+
PT_ARCH=x86_64
207+
PT_BUILD=cpu
208+
PT_REPACK=1
209+
LIBTORCH_ARCHIVE=libtorch-macos-${PT_VERSION}.zip
196210
fi
197211

198-
if [[ $GPU != 1 ]]; then
199-
LIBTORCH_ARCHIVE=libtorch-cxx11-abi-shared-with-deps-${PT_VERSION}%2B${PT_BUILD}.zip
200-
else
201-
LIBTORCH_ARCHIVE=libtorch-cxx11-abi-shared-with-deps-${PT_VERSION}%2B${PT_BUILD}.zip
202-
fi
212+
203213
LIBTORCH_URL=https://download.pytorch.org/libtorch/$PT_BUILD/$LIBTORCH_ARCHIVE
204214

205215
if [[ $WITH_PT != 0 ]]; then
@@ -222,8 +232,11 @@ if [[ $OS == linux ]]; then
222232
else
223233
echo "Only x64 is supported currently"
224234
fi
225-
else
226-
echo "Only Linux OS is supported currently"
235+
elif [[ $OS == macos ]]; then
236+
ORT_OS=osx
237+
ORT_ARCH=x64
238+
ORT_BUILD=""
239+
ORT_URL_BASE=https://github.com/microsoft/onnxruntime/releases/download/v${ORT_VERSION}
227240
fi
228241

229242
ORT_ARCHIVE=onnxruntime-${ORT_OS}-${ORT_ARCH}${ORT_BUILD}-${ORT_VERSION}.tgz

opt/redis_valgrind.sup

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,11 @@
184184
...
185185
fun:_dl_catch_exception
186186
...
187-
}
187+
}
188+
189+
{
190+
<ignore_torch_cond_jump>
191+
Memcheck:Cond
192+
...
193+
obj:*/libtorch_cpu.so*
194+
}

src/redisai.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -736,10 +736,11 @@ int RedisAI_ScriptStore_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **ar
736736
ctx, "ERR Insufficient arguments, missing script entry points");
737737
}
738738

739-
array_new_on_stack(const char *, nEntryPoints, entryPoints);
739+
const char **entryPoints = array_new(const char *, nEntryPoints);
740740
for (size_t i = 0; i < nEntryPoints; i++) {
741741
const char *entryPoint;
742742
if (AC_GetString(&ac, &entryPoint, NULL, 0) != AC_OK) {
743+
array_free(entryPoints);
743744
return RedisModule_ReplyWithError(
744745
ctx, "ERR Insufficient arguments, missing script entry points");
745746
}
@@ -754,6 +755,7 @@ int RedisAI_ScriptStore_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **ar
754755
}
755756

756757
if (scriptdef == NULL) {
758+
array_free(entryPoints);
757759
return RedisModule_ReplyWithError(ctx, "ERR Insufficient arguments, missing script SOURCE");
758760
}
759761

@@ -767,6 +769,7 @@ int RedisAI_ScriptStore_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **ar
767769
"Backend TORCH not loaded, will try loading default backend");
768770
int ret = RAI_LoadDefaultBackend(ctx, RAI_BACKEND_TORCH);
769771
if (ret == REDISMODULE_ERR) {
772+
array_free(entryPoints);
770773
RedisModule_Log(ctx, "warning", "Could not load TORCH default backend");
771774
int ret = RedisModule_ReplyWithError(ctx, "ERR Could not load backend");
772775
RAI_ClearError(&err);
@@ -776,7 +779,7 @@ int RedisAI_ScriptStore_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **ar
776779
script =
777780
RAI_ScriptCompile(devicestr, tag, scriptdef, entryPoints, (size_t)nEntryPoints, &err);
778781
}
779-
782+
array_free(entryPoints);
780783
if (err.code != RAI_OK) {
781784
int ret = RedisModule_ReplyWithError(ctx, err.detail_oneline);
782785
RAI_ClearError(&err);

0 commit comments

Comments
 (0)