aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/g3doc/api_docs/python/session_ops.md
blob: 9794923c7969207192d5c6ecf52276e3d8ff9847 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<!-- This file is machine generated: DO NOT EDIT! -->

# Tensor Handle Operations

Note: Functions taking `Tensor` arguments can also take anything accepted by
[`tf.convert_to_tensor`](framework.md#convert_to_tensor).

[TOC]

Tensor Handle Operations. See the @{python/session_ops} guide.

- - -

### `tf.get_session_handle(data, name=None)` {#get_session_handle}

Return the handle of `data`.

This is EXPERIMENTAL and subject to change.

Keep `data` "in-place" in the runtime and create a handle that can be
used to retrieve `data` in a subsequent run().

Combined with `get_session_tensor`, we can keep a tensor produced in
one run call in place, and use it as the input in a future run call.

##### Args:


*  <b>`data`</b>: A tensor to be stored in the session.
*  <b>`name`</b>: Optional name prefix for the return tensor.

##### Returns:

  A scalar string tensor representing a unique handle for `data`.

##### Raises:


*  <b>`TypeError`</b>: if `data` is not a Tensor.


*  <b>`Example`</b>: 

```python
c = tf.multiply(a, b)
h = tf.get_session_handle(c)
h = sess.run(h)

p, a = tf.get_session_tensor(h.handle, tf.float32)
b = tf.multiply(a, 10)
c = sess.run(b, feed_dict={p: h.handle})
```


- - -

### `tf.get_session_tensor(handle, dtype, name=None)` {#get_session_tensor}

Get the tensor of type `dtype` by feeding a tensor handle.

This is EXPERIMENTAL and subject to change.

Get the value of the tensor from a tensor handle. The tensor
is produced in a previous run() and stored in the state of the
session.

##### Args:


*  <b>`handle`</b>: The string representation of a persistent tensor handle.
*  <b>`dtype`</b>: The type of the output tensor.
*  <b>`name`</b>: Optional name prefix for the return tensor.

##### Returns:

  A pair of tensors. The first is a placeholder for feeding a
  tensor handle and the second is the tensor in the session state
  keyed by the tensor handle.


*  <b>`Example`</b>: 

```python
c = tf.multiply(a, b)
h = tf.get_session_handle(c)
h = sess.run(h)

p, a = tf.get_session_tensor(h.handle, tf.float32)
b = tf.multiply(a, 10)
c = sess.run(b, feed_dict={p: h.handle})
```


- - -

### `tf.delete_session_tensor(handle, name=None)` {#delete_session_tensor}

Delete the tensor for the given tensor handle.

This is EXPERIMENTAL and subject to change.

Delete the tensor of a given tensor handle. The tensor is produced
in a previous run() and stored in the state of the session.

##### Args:


*  <b>`handle`</b>: The string representation of a persistent tensor handle.
*  <b>`name`</b>: Optional name prefix for the return tensor.

##### Returns:

  A pair of graph elements. The first is a placeholder for feeding a
  tensor handle and the second is a deletion operation.