Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions scripts/extract_nomic_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,12 @@ def write_vectors_h(path: str, token_count: int, dim: int, incbin_path: str):


def write_blob_s(path: str, incbin_path: str):
"""Write assembler .incbin directive."""
"""Write the cross-platform assembler .incbin wrapper."""
with open(path, "w") as f:
f.write(f"""/* nomic-embed-code vector blob embedded via assembler. */
f.write(f"""/* nomic-embed-code vector blob embedded via assembler.
* Cross-platform: macOS (Mach-O) vs Linux (ELF) vs Windows (COFF). */

#if defined(__APPLE__)
.section __DATA,__const
.globl _PRETRAINED_VECTOR_BLOB
.globl _PRETRAINED_VECTOR_BLOB_LEN
Expand All @@ -347,6 +350,37 @@ def write_blob_s(path: str, incbin_path: str):
.p2align 2
_PRETRAINED_VECTOR_BLOB_LEN:
.long _PRETRAINED_VECTOR_BLOB_END - _PRETRAINED_VECTOR_BLOB

#elif defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
.section .rdata,"dr"
.globl PRETRAINED_VECTOR_BLOB
.globl PRETRAINED_VECTOR_BLOB_LEN
.p2align 4
PRETRAINED_VECTOR_BLOB:
.incbin "{incbin_path}"
PRETRAINED_VECTOR_BLOB_END:

.section .rdata,"dr"
.p2align 2
PRETRAINED_VECTOR_BLOB_LEN:
.long PRETRAINED_VECTOR_BLOB_END - PRETRAINED_VECTOR_BLOB

#else
.section .rodata,"a",@progbits
.globl PRETRAINED_VECTOR_BLOB
.globl PRETRAINED_VECTOR_BLOB_LEN
.p2align 4
PRETRAINED_VECTOR_BLOB:
.incbin "{incbin_path}"
PRETRAINED_VECTOR_BLOB_END:

.section .rodata,"a",@progbits
.p2align 2
PRETRAINED_VECTOR_BLOB_LEN:
.long PRETRAINED_VECTOR_BLOB_END - PRETRAINED_VECTOR_BLOB

.section .note.GNU-stack,"",@progbits
#endif
""")
print(f" {path}: written")

Expand Down
2 changes: 2 additions & 0 deletions vendored/nomic/code_vectors_blob.S
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,6 @@ PRETRAINED_VECTOR_BLOB_END:
.p2align 2
PRETRAINED_VECTOR_BLOB_LEN:
.long PRETRAINED_VECTOR_BLOB_END - PRETRAINED_VECTOR_BLOB

.section .note.GNU-stack,"",@progbits
#endif
Loading