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 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
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
# 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
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 |
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 | |
import numpy as np | |
import torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
import tvm | |
from tvm import relay, autotvm, auto_scheduler | |
import tvm.relay.testing |
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 | |
# pytorch way | |
input = torch.randn(3, 5) | |
target = torch.randint(5, (3,), dtype=torch.int64) | |
loss1 = F.cross_entropy(input, target) | |
## equal with cross_entropy_with_logits |