Skip to content

Instantly share code, notes, and snippets.

View soumith's full-sized avatar

Soumith Chintala soumith

View GitHub Profile
std::vector<int64_t> input_size = {4, 3, 15, 17}; // B x C x H x W
std::vector<int64_t> kernel_size = {3, 5};
std::vector<int64_t> stride = {1, 2};
std::vector<int64_t> padding = {2, 1};
constexpr int out_channels = 5;
// make inputs
at::Tensor input = torch::randn(input_size);
at::Tensor weight = torch::randn({out_channels, input_size[1], kernel_size[0], kernel_size[1]});
at::Tensor bias = torch::randn({out_channels});
@soumith
soumith / pytorch_api_categorization.md
Last active November 16, 2018 06:17 — forked from ailzhang/pytorch_api_level.md
Pytorch API categorization.md

Torch level 1

function Symbolic_implemented
gather
equal
__and__, __iand__, __or__, __ior__, __xor__, __ixor__, __lshift__, __ilshift__, __rshift__, __irshift__
min, max
all
any
frac yes
diff --git a/torch/csrc/jit/autodiff.cpp b/torch/csrc/jit/autodiff.cpp
index 59eb7ca11..75abe0097 100644
--- a/torch/csrc/jit/autodiff.cpp
+++ b/torch/csrc/jit/autodiff.cpp
@@ -77,7 +77,8 @@ bool isDifferentiable(Node * n) {
"aten::trunc(Tensor self) -> Tensor",
"aten::log_softmax(Tensor self, int dim) -> Tensor",
"aten::avg_pool2d(Tensor self, int[] kernel_size, int[] stride, int[] padding, bool ceil_mode, bool count_include_pad) -> Tensor",
- "aten::max_pool2d_with_indices(Tensor self, int[] kernel_size, int[] stride, int[] padding, int[] dilation, bool ceil_mode) -> (Tensor, Tensor)"
+ "aten::max_pool2d_with_indices(Tensor self, int[] kernel_size, int[] stride, int[] padding, int[] dilation, bool ceil_mode) -> (Tensor, Tensor)",
diff --git a/torch/csrc/jit/autodiff.cpp b/torch/csrc/jit/autodiff.cpp
index 59eb7ca11..75abe0097 100644
--- a/torch/csrc/jit/autodiff.cpp
+++ b/torch/csrc/jit/autodiff.cpp
@@ -77,7 +77,8 @@ bool isDifferentiable(Node * n) {
"aten::trunc(Tensor self) -> Tensor",
"aten::log_softmax(Tensor self, int dim) -> Tensor",
"aten::avg_pool2d(Tensor self, int[] kernel_size, int[] stride, int[] padding, bool ceil_mode, bool count_include_pad) -> Tensor",
- "aten::max_pool2d_with_indices(Tensor self, int[] kernel_size, int[] stride, int[] padding, int[] dilation, bool ceil_mode) -> (Tensor, Tensor)"
+ "aten::max_pool2d_with_indices(Tensor self, int[] kernel_size, int[] stride, int[] padding, int[] dilation, bool ceil_mode) -> (Tensor, Tensor)",
import time
import torch
import torchvision
batch_size = 128
num_iterations = 10
resnet50 = torchvision.models.resnet50().to(device="cuda")
inp = torch.randn(batch_size, 3, 224, 224, device="cuda")
target = torch.arange(batch_size, device="cuda")
diff --git a/imagenet/main.py b/imagenet/main.py
index 20838f0..783bbf2 100644
--- a/imagenet/main.py
+++ b/imagenet/main.py
@@ -20,8 +20,6 @@ model_names = sorted(name for name in models.__dict__
and callable(models.__dict__[name]))
parser = argparse.ArgumentParser(description='PyTorch ImageNet Training')
-parser.add_argument('data', metavar='DIR',
- help='path to dataset')
@soumith
soumith / pytorch-agx-xavier.sh
Last active August 8, 2021 12:33
Install PyTorch on NVIDIA AGX Xavier using JetPack 4.1
sudo apt-get install -y libopenblas-dev cmake ninja-build
sudo apt-get install -y python-pip
sudo pip install virtualenv
virtualenv pytorch-env
. pytorch-env/bin/activate
git clone https://github.com/pytorch/pytorch --recursive
pip install -r requirements.txt
python setup.py install
set -e
# docker run -it --ipc=host --rm -v $(pwd):/remote ubuntu:xenial bash
# bash /remote/run_repro.sh
apt-get update
apt-get install -y build-essential wget git
########################################################
# Setup environment
########################################################
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision
class XlaMNIST(nn.Module):
def __init__(self):
super(XlaMNIST, self).__init__()
self.conv1 = nn.Conv2d(1, 10, kernel_size=5)
self.bn1 = nn.BatchNorm2d(10)
mkl_libs
mkl_libs/libmkl_gnu_thread.a
mkl_libs/libmkl_core.a
mkl_libs/include
mkl_libs/include/mkl_vml.f90
mkl_libs/include/mkl_direct_call.h
mkl_libs/include/mkl_cblas.h
mkl_libs/include/lp64
mkl_libs/include/lp64/lapack95.mod
mkl_libs/include/lp64/f95_precision.mod