Skip to content

Instantly share code, notes, and snippets.

View yuanzhi-zhu's full-sized avatar
🎯
Focusing

Yuanzhi Zhu yuanzhi-zhu

🎯
Focusing
View GitHub Profile
@yuanzhi-zhu
yuanzhi-zhu / self_attention.py
Created June 12, 2024 20:57
self attention with RoPE
"""
This code was originally obtained from:
https://github.com/meta-llama/codellama/blob/main/llama/model.py
adapted from https://github.com/naver-ai/rope-vit/blob/main/self-attn/rope_self_attn.py
"""
import torch
import torch.nn as nn
from functools import partial
import einops