Graph-only version of tf.compat.v1.placeholder(), for internal use only.
(dtype, shape, name=None)
| 39 | |
| 40 | |
| 41 | def graph_placeholder(dtype, shape, name=None): |
| 42 | """Graph-only version of tf.compat.v1.placeholder(), for internal use only.""" |
| 43 | dtype = dtype.base_dtype |
| 44 | dtype_value = attr_value_pb2.AttrValue(type=dtype.as_datatype_enum) |
| 45 | if isinstance(shape, (list, tuple)): |
| 46 | shape = tensor_shape.TensorShape(shape) |
| 47 | shape = attr_value_pb2.AttrValue(shape=shape.as_proto()) |
| 48 | g = ops.get_default_graph() |
| 49 | with ops.name_scope(name, "placeholder", []) as name: |
| 50 | op = g.create_op("Placeholder", [], [dtype], input_types=[], |
| 51 | attrs={"dtype": dtype_value, "shape": shape}, name=name) |
| 52 | result, = op.outputs |
| 53 | return result |
no test coverage detected