Skip to content

Instantly share code, notes, and snippets.

from torch import nn, jit
from typing import Dict
@jit.script
def lookup_all(d, nested_keys):
# type: (Dict[str, Tensor], List[str]) -> List[Tensor]
tensors = []
for i in range(len(nested_keys)):
key = nested_keys[i]
tensors.append(d[key])
#include <torch/script.h>
#include <iostream>
#include <memory>
int main() {
std::shared_ptr<torch::jit::script::Module> module =
torch::jit::load("msm.pt");
for (auto ivalue : module->find_method("forward")->initial_ivalues()) {
import torch
import torch.nn as nn
from typing import Dict, Optional
import torchvision
class Model(nn.Module):
def __init__(self, num_cats):
super(Model, self).__init__()
self.model = torchvision.models.resnet18(pretrained=True)
self.model.fc = nn.Linear(self.model.fc.in_features, num_cats)
class M(nn.Module):
# Only empty lists/dicts and TorchScript classes need types
__annotations__ = {
my_list: List[int],
}
def __init__(self, some_values):
super(M, self).__init__()
for key in some_values:
setattr(self, key, some_values[key])
To install:
https://negativo17.org/nvidia-driver/
```bash
# Add repo
sudo dnf config-manager --add-repo=https://negativo17.org/repos/fedora-nvidia.repo
# Install nvidia driver
# ???
@driazati
driazati / main
Created February 4, 2020 19:43
auto-created gist
import fileinput
import configparser
import os
import requests
class col:
HEADER = "\033[95m"
BLUE = "\033[94m"
GREEN = "\033[92m"
YELLOW = "\033[93m"
@driazati
driazati / main.py
Created February 4, 2020 19:45
auto-created gist
import fileinput
import configparser
import os
import requests
class col:
HEADER = "\033[95m"
BLUE = "\033[94m"
GREEN = "\033[92m"
YELLOW = "\033[93m"
import fileinput
import configparser
import os
import requests
class col:
HEADER = "\033[95m"
BLUE = "\033[94m"
GREEN = "\033[92m"
YELLOW = "\033[93m"
import torch
from pyarkbench import default_args, Benchmark, Timer
class Bench(Benchmark):
def __init__(self, x, out, use_new):
super().__init__(*default_args.bench())
self.x = x
self.output = out
self.use_new = use_new
import datetime
import json
import os
import re
import subprocess
import sys
# Get all changed files
# For each one, if there is a setup.py in any directory between it and the repo