MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / build_graph

Function build_graph

tensorflow/python/ops/transpose_benchmark.py:34–59  ·  view source on GitHub ↗

builds a graph containing a sequence of conv2d operations. Args: device: String, the device to run on. input_shape: Shape of the input tensor. perm: A list of ints with the same length as input tensor's dimension. datatype: numpy data type of the input tensor. num_iters: numbe

(device, input_shape, perm, datatype, num_iters)

Source from the content-addressed store, hash-verified

32
33
34def build_graph(device, input_shape, perm, datatype, num_iters):
35 """builds a graph containing a sequence of conv2d operations.
36
37 Args:
38 device: String, the device to run on.
39 input_shape: Shape of the input tensor.
40 perm: A list of ints with the same length as input tensor's dimension.
41 datatype: numpy data type of the input tensor.
42 num_iters: number of iterations to run transpose.
43
44 Returns:
45 An array of tensors to run()
46 """
47 with ops.device("/%s:0" % device):
48 total_size = np.prod(input_shape)
49 inp = np.arange(1, total_size + 1, dtype=datatype).reshape(input_shape)
50 t = constant_op.constant(inp, shape=input_shape)
51
52 outputs = []
53 transpose_op = array_ops.transpose(t, perm)
54 outputs.append(transpose_op)
55 for _ in range(1, num_iters):
56 with ops.control_dependencies([transpose_op]):
57 transpose_op = array_ops.transpose(t, perm)
58 outputs.append(transpose_op)
59 return control_flow_ops.group(*outputs)
60
61
62class TransposeBenchmark(test.Benchmark):

Callers 1

_run_graphMethod · 0.70

Calls 8

reshapeMethod · 0.80
transposeMethod · 0.80
rangeFunction · 0.70
deviceMethod · 0.45
constantMethod · 0.45
appendMethod · 0.45
control_dependenciesMethod · 0.45
groupMethod · 0.45

Tested by

no test coverage detected