Skip to content

Instantly share code, notes, and snippets.

View ksopyla's full-sized avatar

Krzysztof Sopyła ksopyla

View GitHub Profile
@jmikola
jmikola / foo.php
Created March 20, 2013 22:00
Benchmarking findOne() vs. find()->limit(1)->count(true)
<?php
$m = new MongoClient();
$c = $m->test->foo;
$c->drop();
$c->insert(['_id' => 1, 'x' => str_repeat('z', 1024*1024*4)]);
$c->insert(['_id' => 2, 'x' => str_repeat('z', 1024*1024*4)]);
$c->insert(['_id' => 3, 'x' => str_repeat('z', 1024*1024*4)]);
$c->insert(['_id' => 4, 'x' => str_repeat('z', 1024*1024*4)]);
$c->insert(['_id' => 5, 'x' => str_repeat('z', 1024*1024*4)]);
@michilu
michilu / functools_timeit.py
Created October 12, 2012 00:04 — forked from kumagi/lru.py
python lru benchmarks
#!/usr/bin/env python
from functools32 import lru_cache
from time import time
import random
import sys
def benchtime(fn):
oldtime = time()
fn()
return time() - oldtime
@vinhkhuc
vinhkhuc / min-char-rnn-tensorflow.py
Last active May 17, 2019 02:48
Vanilla Char-RNN using TensorFlow
"""
Vanilla Char-RNN using TensorFlow by Vinh Khuc (@knvinh).
Adapted from Karpathy's min-char-rnn.py
https://gist.github.com/karpathy/d4dee566867f8291f086
Requires tensorflow>=1.0
BSD License
"""
import random
import numpy as np
import tensorflow as tf
@gmr
gmr / consul.lua
Created July 14, 2014 17:03
Dynamic Nginx upstream nodes using Consul
module("resty.consul", package.seeall)
_VERSION = '0.1.0'
function service_nodes(service)
local http = require "resty.http"
local json = require "cjson"
local hc = http:new()
local upstream = ""
@jmp84
jmp84 / export.py
Created September 16, 2020 06:11
TorchScript MT model
import argparse
import logging
import torch
from fairseq.checkpoint_utils import load_model_ensemble_and_task
from fairseq.sequence_generator import SequenceGenerator
def get_args():
parser = argparse.ArgumentParser(
# Htop
sudo apt install -y htop
# Byobu
sudo apt install -y byobu
# Gdebi
sudo apt install -y gdebi-core
# GIT
@Reddine
Reddine / install.sh
Last active January 10, 2022 10:12
Install Theano on Ubuntu 14.04
sudo apt-get install build-essential
sudo apt-get update
# BLAS → LAPACK → ATLAS → numpy → scipy → Theano
# remove numpy and scipy
sudo apt-get remove python-numpy
sudo apt-get remove python-scipy
# Instalation commands
sudo apt-get install gfortran
sudo apt-get install libopenblas-dev
sudo apt-get install liblapack-dev
@mingfeima
mingfeima / bert_optimization.md
Last active July 8, 2022 06:13
BERT Optimization

benchmark

Based on huggingface repo for performance evaluation, actual benchmark run script placed at repo. How to reproduce performance:

  1. prepare dataset according to link.
  2. update GLUE_DIR to actual dataset path in run_inference.sh.
  3. change env settings, the default setting is using 20 cores;

MKL v.s. MKLDNN

Inference performance result on Xeon 6148 (2x20 cores), single socket and single thread.

@wphicks
wphicks / Fraud_Detection_Example.ipynb
Last active January 28, 2023 12:44
Notebook example for fraud detection with the Triton FIL Backend
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import itertools
import torch
from torchtext.experimental.datasets.translation import DATASETS, TranslationDataset
from torchtext.vocab import build_vocab_from_iterator
from torchtext.experimental.functional import (
vocab_func,
totensor,
sequential_transforms,
)
from torchtext.data.utils import get_tokenizer