def _test_lrn(ishape, size, axis, bias, alpha, beta): """ testing local response normalization """ lrn_depth_radius = size / 2 inp_array = np.random.uniform(size=ishape).astype(np.float32) with tf.Graph().as_default(): in1 = tf.placeholder(shape=inp_array.shape, dtype=inp_array.dtype, name="lrn0_data") nn_ops.local_response_normalization(in1, name="lrn", depth_radius=lrn_depth_radius, bias=bias, alpha=alpha, beta=beta) with tf.Session() as sess: graph_def = tf.graph_util.convert_variables_to_constants( sess, sess.graph.as_graph_def(add_shapes=True), ['lrn'], ) tf_output = run_tf_graph(sess, inp_array, 'lrn0_data:0', 'lrn:0') tvm_output = run_tvm_graph(graph_def, inp_array, "lrn0_data", tf_output.shape, tf_output.dtype) np.testing.assert_allclose(tf_output, tvm_output, atol=1e-3, rtol=1e-3) sess.close()
def _test_lrn(ishape, size, axis, bias, alpha, beta): """ testing local response normalization """ lrn_depth_radius = size / 2 inp_array = np.random.uniform(size=ishape).astype(np.float32) with tf.Graph().as_default(): in1 = tf.placeholder(shape=inp_array.shape, dtype=inp_array.dtype, name="lrn0_data") nn_ops.local_response_normalization(in1, name="lrn", depth_radius=lrn_depth_radius, bias=bias, alpha=alpha, beta=beta) compare_tf_with_tvm(inp_array, 'lrn0_data:0', 'lrn:0')
def call(self, inputs, **kwargs): return local_response_normalization(input=inputs, depth_radius=self.n, bias=self.k, alpha=self.alpha, beta=self.beta)