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

Function Conv2D

tensorflow/core/kernels/conv_ops_benchmark_test.cc:76–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74// Creates a simple Tensorflow graph with single Conv2D node.
75template <typename T>
76static Conv2DGraph Conv2D(int batch, int height, int width, int in_depth,
77 int filter_w, int filter_h, int out_depth,
78 TensorFormat data_format = FORMAT_NHWC) {
79 Graph* graph = new Graph(OpRegistry::Global());
80
81 Tensor images_t = data_format == FORMAT_NHWC
82 ? MakeRandomTensor<T>({batch, height, width, in_depth})
83 : MakeRandomTensor<T>({batch, in_depth, height, width});
84
85 // Filter is always in HWIO.
86 Tensor filter_t =
87 MakeRandomTensor<T>({filter_w, filter_h, in_depth, out_depth});
88
89 Node* images = test::graph::Constant(graph, images_t, "images");
90 Node* filter = test::graph::Constant(graph, filter_t, "filter");
91
92 Node* conv2d;
93 TF_CHECK_OK(NodeBuilder(graph->NewName("conv"), "Conv2D")
94 .Input(images)
95 .Input(filter)
96 .Attr("T", DataTypeToEnum<T>::value)
97 .Attr("strides", {1, 1, 1, 1})
98 .Attr("padding", "SAME")
99 .Attr("data_format", ToString(data_format))
100 .Finalize(graph, &conv2d));
101
102 return {graph, conv2d};
103}
104
105// Creates a Tensorflow graph with a Conv2D node followed by BiasAdd.
106template <typename T>

Calls 7

ConstantFunction · 0.70
ToStringFunction · 0.70
NodeBuilderClass · 0.50
FinalizeMethod · 0.45
AttrMethod · 0.45
InputMethod · 0.45
NewNameMethod · 0.45

Tested by

no test coverage detected