Skip to content

Instantly share code, notes, and snippets.

@rxwei
Created April 19, 2019 14:41
Show Gist options
  • Save rxwei/07e125bf546e6c517e8b21e47ee1a3e7 to your computer and use it in GitHub Desktop.
Save rxwei/07e125bf546e6c517e8b21e47ee1a3e7 to your computer and use it in GitHub Desktop.
ad memory leak
sil hidden @AD__$s11leak_simple6apply2_2to10TensorFlow0E0VySfGx_AGtAD5LayerRzAG5InputRtzAG6OutputRtzlF__adjoint_src_0_wrt_1 : $@convention(thin) <τ_0_0 where τ_0_0 : Layer, τ_0_0.Input == Tensor<Float>, τ_0_0.Output == Tensor<Float>> (@guaranteed Tensor<Float>, @guaranteed _AD__$s11leak_simple6apply2_2to10TensorFlow0E0VySfGx_AGtAD5LayerRzAG5InputRtzAG6OutputRtzlF__Type__src_0_wrt_1<τ_0_0>) -> @owned Tensor<Float> {
// %0 // users: %13, %46, %2
// %1 // user: %23
bb0(%0 : $Tensor<Float>, %1 : $_AD__$s11leak_simple6apply2_2to10TensorFlow0E0VySfGx_AGtAD5LayerRzAG5InputRtzAG6OutputRtzlF__Type__src_0_wrt_1<τ_0_0>):
retain_value %0 : $Tensor<Float> // id: %2
%3 = alloc_stack $Tensor<Float> // users: %25, %13, %47, %45, %4
%4 = begin_access [init] [static] [no_nested_conflict] %3 : $*Tensor<Float> // users: %8, %10
%5 = metatype $@thin Tensor<Float>.Type // user: %7
// function_ref static Tensor<>.zero.getter
%6 = function_ref @$s10TensorFlow0A0VAASjRzrlE4zeroACyxGvgZ : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // user: %7
%7 = apply %6<Float>(%5) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // user: %8
store %7 to %4 : $*Tensor<Float> // id: %8
%9 = tuple ()
end_access %4 : $*Tensor<Float> // id: %10
%11 = metatype $@thin Tensor<Float>.Type // user: %13
// function_ref static Tensor<>.+= infix(_:_:)
%12 = function_ref @$s10TensorFlow0A0VAASjRzrlE2peoiyyACyxGz_AEtFZ : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@inout Tensor<τ_0_0>, @guaranteed Tensor<τ_0_0>, @thin Tensor<τ_0_0>.Type) -> () // user: %13
%13 = apply %12<Float>(%3, %0, %11) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@inout Tensor<τ_0_0>, @guaranteed Tensor<τ_0_0>, @thin Tensor<τ_0_0>.Type) -> ()
%14 = tuple ()
%15 = alloc_stack $Tensor<Float> // users: %41, %44, %43, %37, %29, %16
%16 = begin_access [init] [static] [no_nested_conflict] %15 : $*Tensor<Float> // users: %20, %22
%17 = metatype $@thin Tensor<Float>.Type // user: %19
// function_ref static Tensor<>.zero.getter
%18 = function_ref @$s10TensorFlow0A0VAASjRzrlE4zeroACyxGvgZ : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // user: %19
%19 = apply %18<Float>(%17) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // user: %20
store %19 to %16 : $*Tensor<Float> // id: %20
%21 = tuple ()
end_access %16 : $*Tensor<Float> // id: %22
%23 = struct_extract %1 : $_AD__$s11leak_simple6apply2_2to10TensorFlow0E0VySfGx_AGtAD5LayerRzAG5InputRtzAG6OutputRtzlF__Type__src_0_wrt_1<τ_0_0>, #_AD__$s11leak_simple6apply2_2to10TensorFlow0E0VySfGx_AGtAD5LayerRzAG5InputRtzAG6OutputRtzlF__Type__src_0_wrt_1.pullback_0 // user: %26
%24 = alloc_stack $τ_0_0.CotangentVector // users: %26, %36, %28
%25 = load %3 : $*Tensor<Float> // user: %26
%26 = apply %23(%24, %25) : $@callee_guaranteed (@guaranteed Tensor<Float>) -> (@out τ_0_0.CotangentVector, @owned Tensor<Float>) // users: %35, %32
%27 = tuple ()
destroy_addr %24 : $*τ_0_0.CotangentVector // id: %28
%29 = begin_access [modify] [static] [no_nested_conflict] %15 : $*Tensor<Float> // users: %32, %34
%30 = metatype $@thin Tensor<Float>.Type // user: %32
// function_ref static Tensor<>.+= infix(_:_:)
%31 = function_ref @$s10TensorFlow0A0VAASjRzrlE2peoiyyACyxGz_AEtFZ : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@inout Tensor<τ_0_0>, @guaranteed Tensor<τ_0_0>, @thin Tensor<τ_0_0>.Type) -> () // user: %32
%32 = apply %31<Float>(%29, %26, %30) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@inout Tensor<τ_0_0>, @guaranteed Tensor<τ_0_0>, @thin Tensor<τ_0_0>.Type) -> ()
%33 = tuple ()
end_access %29 : $*Tensor<Float> // id: %34
release_value %26 : $Tensor<Float> // id: %35
dealloc_stack %24 : $*τ_0_0.CotangentVector // id: %36
%37 = load %15 : $*Tensor<Float> // user: %48
%38 = metatype $@thin Tensor<Float>.Type // user: %40
// function_ref static Tensor<>.zero.getter
%39 = function_ref @$s10TensorFlow0A0VAASjRzrlE4zeroACyxGvgZ : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // user: %40
%40 = apply %39<Float>(%38) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // user: %41
store %40 to %15 : $*Tensor<Float> // id: %41
%42 = tuple ()
destroy_addr %15 : $*Tensor<Float> // id: %43
dealloc_stack %15 : $*Tensor<Float> // id: %44
destroy_addr %3 : $*Tensor<Float> // id: %45
release_value %0 : $Tensor<Float> // id: %46
dealloc_stack %3 : $*Tensor<Float> // id: %47
return %37 : $Tensor<Float> // id: %48
} // end sil function 'AD__$s11leak_simple6apply2_2to10TensorFlow0E0VySfGx_AGtAD5LayerRzAG5InputRtzAG6OutputRtzlF__adjoint_src_0_wrt_1'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment