{"action":"created","issue":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/6399","repository_url":"https://api.github.com/repos/tensorflow/tensorflow","labels_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/6399/labels{/name}","comments_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/6399/comments","events_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/6399/events","html_url":"https://github.com/tensorflow/tensorflow/issues/6399","id":196426992,"number":6399,"title":"Make an op compute its input once and hold.","user":{"login":"jonasrauber","id":5837385,"avatar_url":"https://avatars.githubusercontent.com/u/5837385?v=3","gravatar_id":"","url":"https://api.github.com/users/jonasrauber","html_url":"https://github.com/jonasrauber","followers_url":"https://api.github.com/users/jonasrauber/followers","following_url":"https://api.github.com/users/jonasrauber/following{/other_user}","gists_url":"https://api.github.com/users/jonasrauber/gists{/gist_id}","starred_url":"https://api.github.com/users/jonasrauber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonasrauber/subscriptions","organizations_url":"https://api.github.com/users/jonasrauber/orgs","repos_url":"https://api.github.com/users/jonasrauber/repos","events_url":"https://api.github.com/users/jonasrauber/events{/privacy}","received_events_url":"https://api.github.com/users/jonasrauber/received_events","type":"User","site_admin":false},"labels":[{"id":404586594,"url":"https://api.github.com/repos/tensorflow/tensorflow/labels/awaiting%20googler","name":"awaiting googler","color":"b60205","default":false},{"id":386191887,"url":"https://api.github.com/repos/tensorflow/tensorflow/labels/awaiting%20response","name":"awaiting response","color":"5319e7","default":false},{"id":473184161,"url":"https://api.github.com/repos/tensorflow/tensorflow/labels/type:support","name":"type:support","color":"b60205","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-12-19T14:30:41Z","updated_at":"2016-12-28T02:00:08Z","closed_at":null,"body":"Currently, tf.constant can take NumPy arrays as input, but it cannot take TensorFlow tensors as input. It would be useful to allow tf.constant to take tensors (that change with every evaluation, e.g. the tensor created by a dequeue op) and turn it into a constant tensor by evaluating the input tensor only once."},"comment":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/comments/269412487","html_url":"https://github.com/tensorflow/tensorflow/issues/6399#issuecomment-269412487","issue_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/6399","id":269412487,"user":{"login":"mrry","id":192142,"avatar_url":"https://avatars.githubusercontent.com/u/192142?v=3","gravatar_id":"","url":"https://api.github.com/users/mrry","html_url":"https://github.com/mrry","followers_url":"https://api.github.com/users/mrry/followers","following_url":"https://api.github.com/users/mrry/following{/other_user}","gists_url":"https://api.github.com/users/mrry/gists{/gist_id}","starred_url":"https://api.github.com/users/mrry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrry/subscriptions","organizations_url":"https://api.github.com/users/mrry/orgs","repos_url":"https://api.github.com/users/mrry/repos","events_url":"https://api.github.com/users/mrry/events{/privacy}","received_events_url":"https://api.github.com/users/mrry/received_events","type":"User","site_admin":false},"created_at":"2016-12-28T02:00:08Z","updated_at":"2016-12-28T02:00:08Z","body":"Off the top of my head, there are a few different possibilities here (although I'm sure there are others...):\r\n\r\n* The easiest would be to implement a write-once version of `tf.Variable`. It would still have an explicit `initialize` op, but it could be treated as a constant subsequently (e.g. in graph optimizations constant folding, CSE, etc.). Depending on how you want to use it, it could have blocking read semantics (block until initialized) or it could raise an error (like a normal `tf.Variable`). With the blocking read semantics, it would essentially be an [I-Structure](http://www.cse.chalmers.se/edu/year/2016/course/pfp/Papers/IStructures.pdf) (see Section 5 for details), but it would also be another potential source of deadlock :).\r\n\r\n* You could build a constant-like construct using a TensorFlow function (or perhaps a `tf.Variable` and `tf.cond()`, if you're not worried about concurrent assignments). On the first execution, it would call the function and store the result in the \"constant\", then produce that value. Subsequent executions would produce the same value. We discussed doing something like this for `tf.Variable` initialization a long time ago, but neither functions nor control flow were stable enough at the time.\r\n\r\nTensorFlow's push semantics make it tricky to implement a construct that takes a `tf.Tensor` and conditionally executes the subgraph needed to produce that tensor. I'm sure it could be done, but it would require changes in the core executor, so either of the above two options would be preferable."}}
{"actor":{"display_login":"mrry"}}