Skip to content

Instantly share code, notes, and snippets.

View giuliacassara's full-sized avatar
🎯
Training

Giulia Cassarà giuliacassara

🎯
Training
View GitHub Profile
@giuliacassara
giuliacassara / gpt2tosa.py
Created May 15, 2023 20:59 — forked from AmosLewis/gpt2tosa.py
gpt2tosa.py
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
from torch.fx.experimental.proxy_tensor import make_fx
from torch._decomp import get_decompositions
import tempfile
import torch_mlir
def prepare_sentence_tokens(hf_model: str, sentence: str):
module attributes {torch.debug_module_name = "GraphModule"} {
func private @__torch__.torch.fx.graph_module.___torch_mangle_0.GraphModule.forward(%arg0: !torch.nn.Module<"__torch__.torch.fx.graph_module.___torch_mangle_0.GraphModule">, %arg1: !torch.tensor {torch.type_bound = !torch.vtensor<[50257,768],f32>}, %arg2: !torch.tensor {torch.type_bound = !torch.vtensor<[2304],f32>}, %arg3: !torch.tensor {torch.type_bound = !torch.vtensor<[768,2304],f32>}, %arg4: !torch.tensor {torch.type_bound = !torch.vtensor<[768],f32>}, %arg5: !torch.tensor {torch.type_bound = !torch.vtensor<[768,768],f32>}, %arg6: !torch.tensor {torch.type_bound = !torch.vtensor<[768],f32>}, %arg7: !torch.tensor {torch.type_bound = !torch.vtensor<[768],f32>}, %arg8: !torch.tensor {torch.type_bound = !torch.vtensor<[768],f32>}, %arg9: !torch.tensor {torch.type_bound = !torch.vtensor<[768],f32>}, %arg10: !torch.tensor {torch.type_bound = !torch.vtensor<[3072],f32>}, %arg11: !torch.tensor {torch.type_bound = !torch.vtensor<[768,3072],f32>}, %ar
@giuliacassara
giuliacassara / building_tensorflow.md
Created October 1, 2022 14:13 — forked from kmhofmann/building_tensorflow.md
Building TensorFlow from source

Building TensorFlow from source (TF 2.3.0, Ubuntu 20.04)

Why build from source?

The official instructions on installing TensorFlow are here: https://www.tensorflow.org/install. If you want to install TensorFlow just using pip, you are running a supported Ubuntu LTS distribution, and you're happy to install the respective tested CUDA versions (which often are outdated), by all means go ahead. A good alternative may be to run a Docker image.

I am usually unhappy with installing what in effect are pre-built binaries. These binaries are often not compatible with the Ubuntu version I am running, the CUDA version that I have installed, and so on. Furthermore, they may be slower than binaries optimized for the target architecture, since certain instructions are not being used (e.g. AVX2, FMA).

So installing TensorFlow from source becomes a necessity. The official instructions on building TensorFlow from source are here: ht

@giuliacassara
giuliacassara / app.py
Created June 27, 2020 16:20 — forked from DeNeutoy/app.py
scispacy demo
import streamlit as st
import spacy
from spacy import displacy
import pandas as pd
from scispacy.umls_linking import UmlsEntityLinker
from scispacy.abbreviation import AbbreviationDetector
SPACY_MODEL_NAMES = ["en_core_sci_sm", "en_core_sci_md", "en_core_sci_lg"]
@giuliacassara
giuliacassara / yocto_pathtrace.cpp
Last active April 9, 2020 23:11
yocto pathtrace
//
// Implementation for Yocto/RayTrace.
//
//
// LICENSE:
//
// Copyright (c) 2016 -- 2020 Fabio Pellacini
//
// Permission is hereby granted, free of charge, to any person obtaining a copy