Skip to content

Instantly share code, notes, and snippets.

View dan-zheng's full-sized avatar
🥛
우유맛

Dan Zheng dan-zheng

🥛
우유맛
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dan-zheng
dan-zheng / tf_conv_gradients.py
Created February 15, 2018 20:45 — forked from yxlao/tf_conv_gradients.py
TensorFlow Convolution Gradients
"""
Demostrating how to compute the gradients for convolution with:
tf.nn.conv2d
tf.nn.conv2d_backprop_input
tf.nn.conv2d_backprop_filter
tf.nn.conv2d_transpose
This is the scripts for this answer: https://stackoverflow.com/a/44350789/1255535
"""

Introduce user-defined dynamically "callable" types

Introduction

This proposal is a follow-on to [SE-0195 - Introduce User-defined "Dynamic Member

@dan-zheng
dan-zheng / README.md
Last active June 23, 2018 02:49
#adjoint expression crasher (https://bugs.swift.org/browse/SR-8087)

The red - lines are produced by direct references to Tensor.dfoo, which doesn't crash.

The green + lines are produced by #adjoint(Tensor.foo), which does crashes.

@dan-zheng
dan-zheng / codable.swift
Created July 13, 2018 21:54
Codable conformance for Tensor crashes
import TensorFlow
import Foundation
func testTensor() throws {
let tensor = Tensor<Int32>(shape: [2, 3], scalars: Array(1...6))
let encoder = JSONEncoder()
let data = try encoder.encode(tensor)
}
try testTensor()
@dan-zheng
dan-zheng / compiler-output.txt
Created July 13, 2018 22:11
Swift struct stored property
$ swiftc -dump-ast stored.swift
(source_file
(struct_decl range=[stored.swift:1:1 - line:3:1] "Model" interface type='Model.Type' access=internal non-resilient
(pattern_binding_decl range=[stored.swift:2:3 - line:2:10]
(pattern_typed type='Float'
(pattern_named type='Float' 'w')
(type_ident
(component id='Float' bind=Swift.(file).Float))))
(var_decl range=[stored.swift:2:7 - line:2:7] "w" type='Float' interface type='Float' access=internal storage_kind=stored_with_trivial_accessors
(accessor_decl implicit range=[stored.swift:2:7 - line:2:7] 'anonname=0x7f83f5055fd0' interface type='(Model) -> () -> Float' access=internal get_for=w
@dan-zheng
dan-zheng / crash.swift
Last active July 24, 2018 20:54
SIL verification failed: Basic block contains a non-contiguous lexical scope at -Onone
// crash.swift
import TensorFlow
func test() {
print(Tensor(1))
}
import TensorFlow
func test(_ array: [Tensor<Float>]) {
for (i, x) in array.enumerated() {
print(x + x)
}
}
test([Tensor(1), Tensor(2)])