- Proposal: SE-NNNN
- Authors: Chris Lattner, Dan Zheng
- Review Manager: TBD
- Status: Awaiting implementation
This proposal is a follow-on to [SE-0195 - Introduce User-defined "Dynamic Member
""" | |
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 | |
""" |
This proposal is a follow-on to [SE-0195 - Introduce User-defined "Dynamic Member
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.
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() |
$ 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 |
// 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)]) |