Skip to content

Instantly share code, notes, and snippets.

View leimao's full-sized avatar
🦤
Hello Underworld. Hello 人工稚能.

Lei Mao leimao

🦤
Hello Underworld. Hello 人工稚能.
View GitHub Profile
@leimao
leimao / mm.cu
Last active October 25, 2023 04:25
Matrix Multiplication and Batched Matrix Multiplication Implementations Using C++ and CUDA.
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <random>
#include <stdexcept>
#include <vector>
#define BLOCK_DIM 32
@leimao
leimao / jpeg2pdf.sh
Last active November 20, 2022 13:57
JPEG to PDF Conversion
# MIT License
# Copyright (c) 2021 Lei Mao <https://leimao.github.io/>
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@leimao
leimao / extract_ILSVRC.sh
Last active July 8, 2021 17:50 — forked from BIGBALLON/extract_ILSVRC.sh
script for ImageNet data extract.
#!/bin/bash
#
# script to extract ImageNet dataset
# ILSVRC2012_img_train.tar (about 138 GB)
# ILSVRC2012_img_val.tar (about 6.3 GB)
# make sure ILSVRC2012_img_train.tar & ILSVRC2012_img_val.tar in your current directory
#
# https://github.com/facebook/fb.resnet.torch/blob/master/INSTALL.md
#
# train/
This file has been truncated, but you can view the full file.
mkdir -p n01440764
mkdir -p n01443537
mkdir -p n01484850
mkdir -p n01491361
mkdir -p n01494475
mkdir -p n01496331
mkdir -p n01498041
mkdir -p n01514668
mkdir -p n01514859
mkdir -p n01518878
mkdir -p n01440764
mkdir -p n01443537
mkdir -p n01484850
mkdir -p n01491361
mkdir -p n01494475
mkdir -p n01496331
mkdir -p n01498041
mkdir -p n01514668
mkdir -p n01514859
mkdir -p n01518878
@leimao
leimao / pytorch_mnist_2.py
Created June 30, 2021 01:34
Horovod PyTorch
import argparse
import os
from filelock import FileLock
import torch.multiprocessing as mp
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torchvision import datasets, transforms
import torch.utils.data.distributed
import torch
from torch.utils.data.distributed import DistributedSampler
from torch.utils.data import DataLoader
import torch.nn as nn
import torch.optim as optim
import torchvision
import torchvision.transforms as transforms
import argparse
@leimao
leimao / graph.py
Last active December 15, 2022 09:15
Graph Traversal
from typing import Iterable, List, Union, Set
class Graph:
def __init__(self) -> None:
# Adjacency set representation.
# key: node name, value: adjacency node name set.
self.edges = dict()
@leimao
leimao / resnet_ddp.py
Created June 20, 2021 02:34
PyTorch Distributed Data-Parallel Training for ResNet
import torch
from torch.utils.data.distributed import DistributedSampler
from torch.utils.data import DataLoader
import torch.nn as nn
import torch.optim as optim
import torchvision
import torchvision.transforms as transforms
import argparse
@leimao
leimao / coco.sh
Created May 5, 2021 17:25 — forked from mkocabas/coco.sh
Download COCO dataset. Run under 'datasets' directory.
mkdir coco
cd coco
mkdir images
cd images
wget http://images.cocodataset.org/zips/train2017.zip
wget http://images.cocodataset.org/zips/val2017.zip
wget http://images.cocodataset.org/zips/test2017.zip
wget http://images.cocodataset.org/zips/unlabeled2017.zip