Skip to content

Instantly share code, notes, and snippets.

View syed-ahmed's full-sized avatar

Syed Tousif Ahmed syed-ahmed

View GitHub Profile
@syed-ahmed
syed-ahmed / torch_fp_errors.py
Created June 1, 2022 20:23
Floating-point intrinsic errors demonstrated using PyTorch
import torch
import ctypes
def print_binary_val(tensor):
print(bin(ctypes.c_uint.from_buffer(ctypes.c_float(tensor.item())).value))
# Error 1: Large round-off incurred when
# representing the same number in a lower precision.
A = torch.tensor(1.0001, dtype=torch.float32).cuda()
B = A.half()
@syed-ahmed
syed-ahmed / Makefile
Created February 10, 2021 04:43
a200t_1600_LUTS
pld_dir?=/media/lilbirb/research/code/pld/
src=$(pld_dir)/do_blink/symbiflow_benchmark/fig2_at200/1600/src
base=$(abspath .)
symb_dir?=$(pld_dir)/third_party/symbiflow-arch-defs
do_blink_dir?=$(pld_dir)/build/do_blink/rrgraphs
YOSYS = $(symb_dir)/env/conda/envs/symbiflow_arch_def_base/bin/yosys
VPR?=$(pld_dir)/third_party/vtr-verilog-to-routing/vpr/vpr
GENFASM = $(symb_dir)/env/conda/envs/symbiflow_arch_def_base/bin/genfasm
XCFASM = $(symb_dir)/env/conda/envs/symbiflow_arch_def_base/bin/xcfasm
set_property DONT_TOUCH true [get_cells design_1_i/page_0/inst]
set_property HD.RECONFIGURABLE true [get_cells design_1_i/page_0/inst]
set_property DONT_TOUCH true [get_cells design_1_i/leaf_dummy_2/inst]
set_property HD.RECONFIGURABLE true [get_cells design_1_i/leaf_dummy_2/inst]
set_property DONT_TOUCH true [get_cells design_1_i/leaf_dummy_3/inst]
set_property HD.RECONFIGURABLE true [get_cells design_1_i/leaf_dummy_3/inst]
set_property DONT_TOUCH true [get_cells design_1_i/leaf_dummy_4/inst]
set_property HD.RECONFIGURABLE true [get_cells design_1_i/leaf_dummy_4/inst]
set_property DONT_TOUCH true [get_cells design_1_i/leaf_dummy_5/inst]
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <linux/if_alg.h>
#include <linux/socket.h>
#define SHA384_DIGEST_SZ 48
int main(void) {
@syed-ahmed
syed-ahmed / ap_int.h
Created November 12, 2019 22:24
Bin conv with light hls
#ifndef _APINT
#define _APINT
#define NULL __null
template <int Bits>
using ap_uint = __attribute__((__ap_int(Bits))) unsigned ;
template <int Bits>
using ap_int = __attribute__((__ap_int(Bits))) int ;
@syed-ahmed
syed-ahmed / main.tex
Last active September 3, 2019 23:39
Latex template for Homework 1 - ESE532
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{enumitem}
\title{ESE-532 Homework 1}
\author{James Bond \\ Partner: Donald Duck}
\date{\today}
\begin{document}
\maketitle
@syed-ahmed
syed-ahmed / Dockerfile
Last active September 3, 2019 15:35
Dockerfile for IC research
FROM ubuntu:18.04
ARG PYTHON_VERSION=3.6
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates wget \
gnupg2 \
build-essential \
cmake \
git \
curl \
diff --git a/test/common_quantization.py b/test/common_quantization.py
index 188fbf200..13dbc6358 100644
--- a/test/common_quantization.py
+++ b/test/common_quantization.py
@@ -55,6 +55,10 @@ class QuantizationTestCase(TestCase):
self.train_data = [(torch.rand(20, 5, dtype=torch.float), torch.randint(0, 1, (20,), dtype=torch.long)) for _ in range(20)]
self.img_data = [(torch.rand(20, 3, 10, 10, dtype=torch.float), torch.randint(0, 1, (20,), dtype=torch.long))
for _ in range(20)]
+ fullname = self.id().lower()
+ is_cuda_test = 'gpu' in fullname or 'cuda' in fullname or 'cuda' in torch.tensor([]).device.type

Summary: Time (seconds) to get 134217728 randoms with varying number of threads

Best and Worst Average Times per Thread
diff --git a/aten/src/ATen/CPUGenerator.cpp b/aten/src/ATen/CPUGenerator.cpp
index c0b6e30..97cbb4d 100644
--- a/aten/src/ATen/CPUGenerator.cpp
+++ b/aten/src/ATen/CPUGenerator.cpp
@@ -50,6 +50,7 @@ inline uint64_t make64BitsFrom32Bits(uint32_t hi, uint32_t lo) {
CPUGenerator::CPUGenerator(uint64_t seed_in)
: Generator{Device(DeviceType::CPU)},
engine_{seed_in},
+ engine2{seed_in, 0, 0},
next_float_normal_sample_{c10::optional<float>()},