Skip to content

Instantly share code, notes, and snippets.

View gautamborad's full-sized avatar

Gautam Borad gautamborad

View GitHub Profile
@gautamborad
gautamborad / bobp-python.md
Created August 31, 2021 05:49 — forked from sloria/bobp-python.md
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@gautamborad
gautamborad / test-tensor-printout-differ.out
Last active June 15, 2021 17:50
Eager vs TorchScript print comparison for multi-dimensional (1D, 2D, 3D, 4D) tensors with all possible DTypes
% python test-tensor-printout-differ.py
==================== ALL INT DTYPES =====================================
Eager [1-D] type:torch.uint8
tensor([0, 0, 0], dtype=torch.uint8)
TorchScript [1-D] type:torch.uint8
tensor([0, 0, 0])
[ CPUByteType{3} ]
TorchScript time for (1-D) -> torch.uint8: (0.05977s)!
-----------
@gautamborad
gautamborad / check_print_format.py
Last active June 15, 2021 17:50
Eager vs TorchScript print comparison for tensors with all possible DTypes from range 1.e-15 to 1.e+15
import torch
from typing import Any
def f(a : Any):
print(a)
return (isinstance(a, torch.Tensor))
m = torch.jit.script(f)
def pr(ts):
BEFORE CODE CHANGES
====================================
TorchScript one_d time for torch.uint8: (0.00162s)!
TorchScript two_d time for torch.uint8: (0.00019s)!
TorchScript three_d time for torch.uint8: (0.00024s)!
TorchScript four_d time for torch.uint8: (0.00071s)!
Eager:
=====
one_d:
tensor([3, 3, 0], dtype=torch.uint8)
TorchScript:
=====
one_d:
tensor([ 3, 3, 0])
[ CPUByteType{3} ]
@gautamborad
gautamborad / rules.py
Created October 29, 2020 09:58 — forked from miraculixx/rules.py
a simple python based rule engine
"""
(c) 2014 miraculixx at gmx.ch
"""
from shrutil.dictobj import DictObject
class RuleContext(DictObject):
"""
rule context to store values and attributes (or any object)
"""
def __init__(self):
import {observable, autorun} from 'mobx';
import axios from 'axios';
import Post from '../models/postModel'; // TODO!!
export default class BaseStore {
@observable models = [];
@observable isLoading = true;
constructor(type, url) {
this.type = type;