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 numpy as np | |
from collections import Counter | |
import tvm | |
from tvm import relay | |
from tvm.relay import ExprFunctor, ExprMutator, ExprVisitor | |
from tvm.relay.expr_functor import ExprMutator, Call | |
from tvm.relay.dataflow_pattern import wildcard, is_op, is_constant, is_expr, rewrite, DFPatternCallback |
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 numpy as np | |
from collections import Counter | |
import tvm | |
from tvm import relay | |
# from tvm.relay import ExprFunctor, ExprMutator, ExprVisitor | |
from tvm.relay.expr_functor import ExprMutator, Call | |
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 | |
import torch.nn as nn | |
import torchvision | |
from torchvision import models | |
batch = 1 | |
dim = 3 | |
res = 224 |
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 numpy as np | |
from collections import Counter | |
import tvm | |
from tvm import relay | |
from tvm.relay import ExprFunctor, ExprMutator, ExprVisitor | |
from tvm.relay.expr_functor import ExprMutator, Call | |
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 os, sys | |
import os.path as osp | |
import math | |
import numpy as np | |
import torch | |
import torch.nn as nn | |
from torchvision import transforms, datasets | |
from ofa.model_zoo import ofa_net |
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
# dense update | |
# forward | |
input: 1, 48, 8, 8 | |
weight: 240, 48, 1, 1 | |
output: 1, 240, 8, 8 | |
# input | |
# (n, c, h, w) => (1, n * c, h, w) | |
input_1 = 1, 48, 8, 8 |
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 os, os.path as osp | |
import json | |
from copy import deepcopy | |
import numpy as np | |
from copy import deepcopy | |
import torch | |
import torch.nn as nn |
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 tokenize import group | |
import torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
from torch.nn.modules.utils import _single, _pair, _triple | |
import warnings | |
from torch.nn.grad import _grad_input_padding | |
@torch.no_grad() |
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
# tested on AWS p2.xlarge August 29, 2018 | |
# install CUDA | |
sudo apt-get update && sudo apt-get install wget -y --no-install-recommends | |
CUDA_URL="https://developer.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda-repo-ubuntu1804-10-1-local-10.1.105-418.39_1.0-1_amd64.deb" | |
wget -c ${CUDA_URL} -O cuda.deb | |
sudo dpkg --install cuda.deb | |
sudo apt-key add /var/cuda-repo-10-1/7fa2af80.pub | |
sudo apt-get update | |
sudo apt-get install -y cuda |
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 | |
import torch.nn as nn | |
import torch.nn.functional as F | |
def serialize(raw_idx): | |
raw_idx = raw_idx.clone() | |
# put 3 int10 into one int32 | |
d = raw_idx.view(-1, 3) | |
d[:, 0] = d[:, 0] << 20 |