Skip to content

Instantly share code, notes, and snippets.

View d3lm's full-sized avatar
💻
Coding

Dominic Elm d3lm

💻
Coding
View GitHub Profile

CLang optimizations on Mac OSX

Version:

Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.1.0
Thread model: posix

This was made with commands:

@d3lm
d3lm / compile.md
Last active July 27, 2026 08:27
Compile Node.js
./configure --ninja --node-builtin-modules-path `pwd`

# Node's own C++ steppable, V8 fast-but-opaque. Good default
./configure --ninja --debug --node-builtin-modules-path "$(pwd)"

# V8 internals also steppable, plus ENABLE_SLOW_DCHECKS, much slower to build and run
./configure --ninja --debug --v8-non-optimized-debug --node-builtin-modules-path "$(pwd)"
@d3lm
d3lm / main.py
Last active April 5, 2021 13:39
tf_api
import numpy as np
import tf_api as tf
# Create model
model = lambda x: 1.23 * x + 10
# Create small dataset of 5 entries
train_X = np.linspace(0, 5, 5).reshape((-1, 1))
train_Y = np.array([model(x) for x in train_X]).reshape((-1, 1))
@d3lm
d3lm / multiply.py
Last active June 6, 2019 19:43
Matrix Multiplication
class multiply(BinaryOperation):
"""
Computes a * b, element-wise
"""
def forward(self, a, b):
return a * b
def backward(self, upstream_grad):
raise NotImplementedError
class BinaryOperation(Operation):
def __init__(self, a, b):
super().__init__([a, b])
import tf_api as tf
# create default graph
tf.Graph().as_default()
# construct computational graph by creating some nodes
a = tf.Constant(15)
b = tf.Constant(5)
prod = tf.multiply(a, b)
sum = tf.add(a, b)
@d3lm
d3lm / session.py
Last active August 7, 2019 13:10
class Session():
def run(self, operation, feed_dict={}):
nodes_sorted = topology_sort(operation)
for node in nodes_sorted:
if type(node) == Placeholder:
node.output = feed_dict[node]
elif type(node) == Variable or type(node) == Constant:
node.output = node.value
else:
def topology_sort(operation):
ordering = []
visited_nodes = set()
def recursive_helper(node):
if isinstance(node, Operation):
for input_node in node.input_nodes:
if input_node not in visited_nodes:
recursive_helper(input_node)
class Variable():
def __init__(self, initial_value=None):
self.value = initial_value
_default_graph.variables.append(self)
class Placeholder():
def __init__(self):
self.value = None
_default_graph.placeholders.append(self)