Skip to content

Instantly share code, notes, and snippets.

@alsrgv
alsrgv / numba_test.py
Created January 30, 2020 07:27
Numba CUDA jitclass question
View numba_test.py
import numba
import numba.cuda
import numpy as np
@numba.jitclass([
("x", numba.types.int32)
])
class XYZ:
def __init__(self, x):
View mask_rcnn_benchmark.py
import requests
from io import BytesIO
from PIL import Image
import numpy as np
import timeit
import torch
from maskrcnn_benchmark.config import cfg
from predictor import COCODemo, to_image_list
@alsrgv
alsrgv / pytorch_synthetic_benchmark_apex.py
Last active January 12, 2022 12:04
Horovod-PyTorch with Apex (look for "# Apex")
View pytorch_synthetic_benchmark_apex.py
from __future__ import print_function
import argparse
import torch.backends.cudnn as cudnn
import torch.nn.functional as F
import torch.optim as optim
import torch.utils.data.distributed
from torchvision import models
import horovod.torch as hvd
import timeit
@alsrgv
alsrgv / Tangent DL.ipynb
Last active October 19, 2019 20:35
Tangent DL
View Tangent DL.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alsrgv
alsrgv / tmds.cpp
Last active December 3, 2018 22:44
TMDS in C++ HLS
View tmds.cpp
#include <assert.h>
#include "tmds.h"
#include "utils.h"
template<int X>
ap_uint<log2up(X)> count_ones(ap_uint<X> data) {
ap_uint<X> result = data[0];
for (int i = 1; i < 8; i++) {
#pragma HLS UNROLL
@alsrgv
alsrgv / tmds.sv
Last active September 12, 2021 21:31
TMDS encoder/decoder in SystemVerilog
View tmds.sv
package tmds_pkg;
typedef struct packed {
logic inv_q_m;
logic use_xor;
logic [7:0] q_m;
} tmds_encoded_t;
typedef enum logic [9:0]{
CTRL_00 = 10'b1101010100,
@alsrgv
alsrgv / hyperas_keras_example.py
Last active July 25, 2020 20:36
Hyperas + Horovod Example
View hyperas_keras_example.py
from __future__ import print_function
from hyperopt import Trials, STATUS_OK, tpe
from hyperas import optim
from hyperas.distributions import choice, uniform, conditional
import keras
import tensorflow as tf
import horovod.keras as hvd
import keras.backend as K
import math
@alsrgv
alsrgv / pytorch_imagenet_resnet50_1late.py
Created July 27, 2018 18:35
1-late SGD for PyTorch ImageNet example with Horovod
View pytorch_imagenet_resnet50_1late.py
from __future__ import print_function
import argparse
import torch.backends.cudnn as cudnn
import torch.nn.functional as F
import torch.optim as optim
import torch.utils.data.distributed
from torchvision import datasets, transforms, models
import horovod.torch as hvd
import tensorboardX
@alsrgv
alsrgv / pbtxt_to_pb.py
Created March 15, 2018 02:51
Converter of graph.pbtxt to binary graph.pb
View pbtxt_to_pb.py
from __future__ import print_function
import os
import sys
import tensorflow as tf
from google.protobuf import text_format
from tensorflow.python.framework import graph_io
if len(sys.argv) < 2:
print('Usage: %s <filename prefix>' % sys.argv[0])
@alsrgv
alsrgv / horovod_model_parallelism.py
Created January 27, 2018 06:20
Model parallelism in Horovod
View horovod_model_parallelism.py
# Copyright 2018 Uber Technologies, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,