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
import torch | |
from torch import nn | |
# import torch_mlir | |
from torch_mlir.passmanager import PassManager | |
from torch_mlir.dialects.torch.importer.jit_ir import ClassAnnotator, ModuleBuilder | |
torch.manual_seed(42) |
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
import torch | |
from torch import nn | |
import numpy as np | |
# https://github.com/arasdar/DL/blob/master/uri-dl/uri-dl-hw-2/assignment2/cs231n/layers.py | |
# https://github.com/brandontrabucco/conv-python/blob/master/main.py | |
def get_output_shape(x, kernel, stride): | |
(_, _, ih, iw), (kh, kw) = x.shape, kernel | |
oh = (ih - kh) // stride + 1 |
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 <algorithm> | |
#include <cassert> | |
#include <random> | |
#include <vector> | |
constexpr unsigned int bit_floor(unsigned int num) { | |
return num == 0 ? 0 : 1 << (31 - __builtin_clz(num)); | |
} | |
template <typename It, typename T, typename Cmp> |
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 <algorithm> | |
#include <iostream> | |
#include <sstream> | |
#include <string> | |
#include <vector> | |
#include <optional> | |
#include <iomanip> | |
enum class Type { | |
PositionalArgument, |
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
enum Entry<T> { | |
Vacant(usize), | |
Occupied(T), | |
} | |
pub struct Slab<T> { | |
entries: Vec<Entry<T>>, | |
next: usize, | |
} |
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 <algorithm> | |
#include <cassert> | |
#include <cstdint> | |
#include <cstdio> | |
#include <random> | |
#include <vector> | |
enum Color { Black, Red }; | |
enum Leaf { Left, Right }; |
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 <iostream> | |
struct ListNode { | |
void *m_prev = nullptr; | |
void *m_next = nullptr; | |
}; | |
template <typename T> struct List { | |
private: | |
T *m_head = nullptr; |
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
# ubuntu/debian | |
# sudo apt install libjansson-dev texinfo gnutls-bin | |
# homebrew | |
brew install jansson texinfo | |
# build | |
CFLAGS="-O2 -DNDEBUG" ./configure \ | |
--without-all --without-x --without-ns --without-libgmp \ | |
--with-json --with-modules --with-threads \ |
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
#!/bin/bash | |
# xrandr # to see infos | |
# arandr # gui | |
echo -n "builtin(1) external(2) sidebyside(3) mirror(4): " | |
read choice | |
BUI=`xrandr | grep ' connected' | awk 'NR==1 {print $1}'` | |
BUIMODE=`xrandr | grep $BUI -A1 | awk 'FNR==2 {print $1}'` |
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 datetime import datetime | |
t = datetime.now() | |
H, M = t.hour % 12, t.minute | |
HL, DK = '\033[0m', '\033[2m' | |
RESET = HL | |
MM = lambda *rgs: HL if any(a <= M < b for a, b in rgs) else DK | |
HH = lambda h: HL if (M < 35 and H == h) or (M >= 35 and H + 1 == h) else DK | |
print(f'''\ | |
{HL}I T{DK} L {HL}I S{DK} A S T I M E | |
{MM((15, 20), (45, 50))}A{DK} C {MM((15, 20), (45, 50))}Q U A R T E R{DK} D C |