Hello serialization experts,
Serialization for the @differentiable
attribute isn't working properly. Below is a reproducer: I test whether @differentiable
attributes are serialized correctly and show up where referenced from another module during SILGen.
-
Float.+
has@_transparent
and@differentiable
attributes (on tensorflow branch). - For comparison,
BidirectionalCollection.joined
has a@_specialize
attribute.
// fail.swift
Float(1) + 1
["", ""].joined()
When I emit SILGen for the program, the SIL [differentiable]
attribute doesn't show up, but the [_specialize]
attribute does.
$ swiftc -emit-silgen fail.swift
...
// static Float.+ infix(_:_:)
// BUG: 'differentiable' attribute doesn't show up.
sil [transparent] [serialized] @$sSf1poiyS2f_SftFZ : $@convention(method) (Float, Float, @thin Float.Type) -> Float
// BidirectionalCollection<>.joined(separator:)
// 'specialize' attribute shows up.
sil [_specialize exported: false, kind: full, where τ_0_0 == Array<String>] @$sSKsSS7ElementRtzrlE6joined9separatorS2S_tF : $@convention(method) <τ_0_0 where τ_0_0 : BidirectionalCollection, τ_0_0.Element == String> (@guaranteed String, @in_guaranteed τ_0_0) -> @owned String
Here are some relevant code paths regarding @differentaible
attribute serialization. (The implementations were copied from serialization for other attributes.)
- AST serialization:
lib/Serialization/Serialization.cpp
- AST deserialization:
lib/Serialization/Deserialization.cpp
- SIL serialization:
lib/Serialization/SerializeSIL.cpp
- SIL deserialization:
lib/Serialization/DeserializeSIL.cpp
- SILGen:
lib/SILGen/SILGen.cpp
There are two serialization tests for @differentiable
, but they don't catch this bug.
Does anyone know what might be causing this? I imagine the bug is likely that @differentiable
attribute isn't getting (de)serialized at all, rather than one part of (de)serialization being missing.
Any tips would be greatly appreciated!