tensorflow / java

Java bindings for TensorFlow
Apache License 2.0
813 stars 200 forks source link

What is the difference between statefulIf and StatelessIf and when is a ConcreteFunction stateful? #346

Open JimClarke5 opened 3 years ago

JimClarke5 commented 3 years ago

@rnett Could you please explain tf.statefulIf vs tf.statelessIf and when a ConcreteFunction is stateful vs stateless?

rnett commented 3 years ago

I'm not sure tbh, it's an internal tensorflow distinction. I have been meaning to play with it to get an answer but haven't yet, you might have better luck making an issue in the main tensorflow repo. All I'm doing is propagating statefulness, i.e. if a stateful op is used in a ConcreteFunction, make the function stateful; if one of the if's functions is stateful, make the if stateful, etc. Generally you should just use ifOp and rely on that, it does it automatically.