If it helps, I have the same transformer implemented in python (with numpy) and in Fortran. See https://github.com/rbitr/llama2.ipynb/blob/master/llama2.ipynb and https://github.com/rbitr/llama2.f90/blob/original_master/llama2.f90 the transformer function in each. They should be pretty close translations, but it really depends on what you’re stuck on.
1 Like