File tree Expand file tree Collapse file tree 3 files changed +15
-2
lines changed
Filter options
Expand file tree Collapse file tree 3 files changed +15
-2
lines changed
Original file line number Diff line number Diff line change @@ -218,6 +218,9 @@ if (LLAMA_METAL)
218
218
219
219
# copy ggml-metal.metal to bin directory
220
220
configure_file (ggml-metal.metal bin/ggml-metal.metal COPYONLY )
221
+ if (LLAMA_METAL )
222
+ set_target_properties (llama PROPERTIES RESOURCE "${CMAKE_CURRENT_SOURCE_DIR} /ggml-metal.metal" )
223
+ endif ()
221
224
222
225
set (LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS}
223
226
${FOUNDATION_LIBRARY}
@@ -432,6 +435,9 @@ target_link_libraries(llama PRIVATE
432
435
if (BUILD_SHARED_LIBS )
433
436
set_target_properties (llama PROPERTIES POSITION_INDEPENDENT_CODE ON )
434
437
target_compile_definitions (llama PRIVATE LLAMA_SHARED LLAMA_BUILD )
438
+ if (LLAMA_METAL )
439
+ set_target_properties (llama PROPERTIES RESOURCE "${CMAKE_CURRENT_SOURCE_DIR} /ggml-metal.metal" )
440
+ endif ()
435
441
endif ()
436
442
437
443
if (GGML_SOURCES_CUDA )
Original file line number Diff line number Diff line change 28
28
postPatch =
29
29
if isM1 then ''
30
30
substituteInPlace ./ggml-metal.m \
31
- --replace '[[NSBundle mainBundle] pathForResource:@"ggml-metal" ofType:@"metal"];' "@\"$out/ggml-metal.metal\";"
31
+ --replace '[bundle pathForResource:@"ggml-metal" ofType:@"metal"];' "@\"$out/ggml-metal.metal\";"
32
32
'' else "" ;
33
33
nativeBuildInputs = with pkgs ; [ cmake ] ;
34
34
buildInputs = osSpecific ;
Original file line number Diff line number Diff line change 73
73
// for now it is easier to work in a separate file
74
74
static NSString * const msl_library_source = @" see metal.metal" ;
75
75
76
+ // Here to assist with NSBundle Path Hack
77
+ @interface GGMLMetalClass : NSObject
78
+ @end
79
+ @implementation GGMLMetalClass
80
+ @end
81
+
76
82
struct ggml_metal_context * ggml_metal_init (void ) {
77
83
fprintf (stderr, " %s : allocating\n " , __func__);
78
84
108
114
NSError * error = nil ;
109
115
110
116
// NSString * path = [[NSBundle mainBundle] pathForResource:@"../../examples/metal/metal" ofType:@"metal"];
111
- NSString * path = [[NSBundle mainBundle ] pathForResource: @" ggml-metal" ofType: @" metal" ];
117
+ NSBundle * bundle = [NSBundle bundleForClass: [GGMLMetalClass class ]];
118
+ NSString * path = [bundle pathForResource: @" ggml-metal" ofType: @" metal" ];
112
119
fprintf (stderr, " %s : loading '%s '\n " , __func__, [path UTF8String ]);
113
120
114
121
NSString * src = [NSString stringWithContentsOfFile: path encoding: NSUTF8StringEncoding error: &error];
You can’t perform that action at this time.
0 commit comments