| 74 | // Creates a simple Tensorflow graph with single Conv2D node. |
| 75 | template <typename T> |
| 76 | static 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. |
| 106 | template <typename T> |
no test coverage detected