This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import islice | |
from pathlib import Path | |
from torch.nn import * | |
from torch.nn.functional import cross_entropy, mse_loss, one_hot | |
from torch.nn.init import constant_, kaiming_normal_, normal_ | |
from torch.optim import SGD | |
from torch.optim.lr_scheduler import CosineAnnealingLR | |
from torch.utils.data import DataLoader | |
from torchinfo import summary | |
from torchtoolbox.transform import Cutout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
#include <xmmintrin.h> | |
#include <mmintrin.h> | |
#include "matrix.h" | |
#include "z_order.h" | |
using namespace nda; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static uint32_t * | |
fast_bsearch_u32(uint32_t *base, size_t nmemb, uint32_t key) { | |
while (nmemb) { | |
size_t half = nmemb >> 1; | |
if (base[half] < key) { | |
base += nmemb - half; | |
} | |
nmemb = half; | |
} | |
return base; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Compile and run with: | |
// | |
// gcc -O3 -march=native fast-strlen.c -lpthread -o fast-strlen | |
// && ./fast-strlen | |
// | |
// Use gcc because clang is too smart and optimizes away parts of the | |
// benchmark. Results on Xeon(R) CPU E5-2650 v4 @ 2.20GHz with gcc | |
// 9.4.0: | |
// | |
// Scanning 10 times over 4.00GB... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Notes: | |
// | |
// * unsigned int vs. int: makes a small difference for clang but | |
// probably not for gcc. | |
// * best tiling appears to be 256x256x256. | |
// | |
// 12.31 for two 8192 matrices | |
// | |
// | |
#include <assert.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Notes: | |
// | |
// * unsigned int vs. int: makes a small difference for clang but | |
// probably not for gcc. | |
// * best tiling appears to be 256x256x256. | |
// | |
// 12.31 for two 8192 matrices | |
#include <assert.h> | |
#include <math.h> | |
#include <pthread.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: | |
# python cas.py simplify "(x+y)**30*(2*x)+123*z**8" | |
# python cas.py solve "3*x**2 == -x**2 + 5*x" | |
import math, sys | |
from ast import * | |
from functools import reduce | |
from collections import Counter, defaultdict | |
def parse_mv(mv): | |
def pow(n, e): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ast import * | |
from pygraphviz import AGraph | |
from re import sub | |
COLOR_KWD = '#a020f0' | |
COLOR_VAR = '#6c71c4' | |
COLOR_STR = '#8b2252' | |
def colorize(s, col): | |
return '<font color="%s">%s</font>' % (col, s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<nav class="navbar navbar-default navbar-fixed-top navbar-inverse"> | |
<div class="container-fluid"> | |
<!-- Brand and toggle get grouped for better mobile display --> | |
<div class="navbar-header"> | |
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> | |
<span class="sr-only">Toggle navigation</span> | |
<span class="icon-bar"></span> | |
<span class="icon-bar"></span> | |
<span class="icon-bar"></span> | |
</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from observations import ptb | |
from time import sleep, time | |
from torch.nn import * | |
from torch.optim import * | |
from torch.utils.data import DataLoader | |
from torch.utils.data.distributed import DistributedSampler | |
from torch_xla.core.xla_model import (get_ordinal, | |
is_master_ordinal, | |
master_print, | |
xla_device, |
NewerOlder