| 105 | // Creates a Tensorflow graph with a Conv2D node followed by BiasAdd. |
| 106 | template <typename T> |
| 107 | static Conv2DWithBiasGraph Conv2DWithBias( |
| 108 | int batch, int height, int width, int in_depth, int filter_w, int filter_h, |
| 109 | int out_depth, TensorFormat data_format = FORMAT_NHWC) { |
| 110 | Conv2DGraph conv_graph = Conv2D<T>(batch, height, width, in_depth, filter_w, |
| 111 | filter_h, out_depth, data_format); |
| 112 | |
| 113 | Graph* graph = conv_graph.graph; |
| 114 | Node* conv2d = conv_graph.conv2d; |
| 115 | |
| 116 | Tensor bias_t = MakeRandomTensor<T>({out_depth}); |
| 117 | Node* bias = test::graph::Constant(graph, bias_t, "bias"); |
| 118 | |
| 119 | Node* out; |
| 120 | TF_CHECK_OK(NodeBuilder(graph->NewName("bias"), "BiasAdd") |
| 121 | .Input(conv2d) |
| 122 | .Input(bias) |
| 123 | .Attr("T", DataTypeToEnum<T>::value) |
| 124 | .Attr("data_format", ToString(data_format)) |
| 125 | .Finalize(graph, &out)); |
| 126 | |
| 127 | return {graph, conv2d, out}; |
| 128 | } |
| 129 | |
| 130 | // Creates a Tensorflow graph with a Conv2D node followed by BiasAdd and |
| 131 | // activation (Relu, Relu6, etc...). |