2024-02-08 05:15:59 +08:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# This script generates a C++ function that provides the Metal unary and binary
|
|
|
|
# ops at runtime for use with kernel generation.
|
|
|
|
#
|
|
|
|
# Copyright © 2023-24 Apple Inc.
|
|
|
|
|
|
|
|
|
|
|
|
OUTPUT_FILE=$1
|
|
|
|
CC=$2
|
|
|
|
SRCDIR=$3
|
|
|
|
|
|
|
|
CONTENT=$($CC -I $SRCDIR -E $SRCDIR/mlx/backend/metal/kernels/compiled_preamble.h 2>/dev/null)
|
|
|
|
|
2024-02-12 02:33:30 +08:00
|
|
|
cat << EOF > "$OUTPUT_FILE"
|
2024-02-08 05:15:59 +08:00
|
|
|
// Copyright © 2023-24 Apple Inc.
|
|
|
|
|
|
|
|
namespace mlx::core::metal {
|
|
|
|
|
|
|
|
const char* get_kernel_preamble() {
|
|
|
|
return R"preamble(
|
|
|
|
$CONTENT
|
|
|
|
)preamble";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace mlx::core::metal
|
|
|
|
EOF
|