def testNHWCtoWHCN(self): x_val = [-4, -3, -2, -1, 0, 1, 2, 3] y_val_expected = [3, 1, 0, 2, 3, 1, 0, 2] x = constant_op.constant(x_val) y = nn_ops.data_format_dim_map(x, src_format="NHWC", dst_format="WHCN") with self.session(use_gpu=test_lib.is_gpu_available()) as sess: y_val = sess.run(y) self.assertAllEqual(y_val, y_val_expected)
def testArbitraryASCII(self): x_val = [-4, -3, -2, -1, 0, 1, 2, 3] y_val_expected = [3, 2, 1, 0, 3, 2, 1, 0] x = constant_op.constant(x_val) y = nn_ops.data_format_dim_map(x, src_format="qwer", dst_format="rewq") with self.session(use_gpu=test_lib.is_gpu_available()) as sess: y_val = sess.run(y) self.assertAllEqual(y_val, y_val_expected)
def testArbitraryASCII(self): x_val = [-4, -3, -2, -1, 0, 1, 2, 3] y_val_expected = [3, 2, 1, 0, 3, 2, 1, 0] x = constant_op.constant(x_val) y = nn_ops.data_format_dim_map(x, src_format="qwer", dst_format="rewq") with test_util.use_gpu(): y_val = self.evaluate(y) self.assertAllEqual(y_val, y_val_expected)
def testNHWCtoNCHW(self): x_val = [1, -3, -2] y_val_expected = [2, 2, 3] x = constant_op.constant(x_val) y = nn_ops.data_format_dim_map(x, src_format="NHWC", dst_format="NCHW") with self.session(use_gpu=test_lib.is_gpu_available()) as sess: y_val = sess.run(y) self.assertAllEqual(y_val, y_val_expected)
def testNHWCtoNCHW(self): x_val = [1, -3, -2] y_val_expected = [2, 2, 3] x = constant_op.constant(x_val) y = nn_ops.data_format_dim_map(x, src_format="NHWC", dst_format="NCHW") with test_util.use_gpu(): y_val = self.evaluate(y) self.assertAllEqual(y_val, y_val_expected)
def testNHWCtoWHCN(self): x_val = [-4, -3, -2, -1, 0, 1, 2, 3] y_val_expected = [3, 1, 0, 2, 3, 1, 0, 2] x = constant_op.constant(x_val) y = nn_ops.data_format_dim_map(x, src_format="NHWC", dst_format="WHCN") with test_util.use_gpu(): y_val = self.evaluate(y) self.assertAllEqual(y_val, y_val_expected)
def testArbitraryASCII(self): x_val = [-4, -3, -2, -1, 0, 1, 2, 3] y_val_expected = [3, 2, 1, 0, 3, 2, 1, 0] x = constant_op.constant(x_val) y = nn_ops.data_format_dim_map(x, src_format="qwer", dst_format="rewq") with test_util.use_gpu(): y_val = self.evaluate(y) self.assertAllEqual(y_val, y_val_expected)
def testNHWCtoNCHW(self): x_val = [1, -3, -2] y_val_expected = [2, 2, 3] x = constant_op.constant(x_val) y = nn_ops.data_format_dim_map(x, src_format="NHWC", dst_format="NCHW") with test_util.use_gpu(): y_val = self.evaluate(y) self.assertAllEqual(y_val, y_val_expected)
def testNHWCtoWHCN(self): x_val = [-4, -3, -2, -1, 0, 1, 2, 3] y_val_expected = [3, 1, 0, 2, 3, 1, 0, 2] x = constant_op.constant(x_val) y = nn_ops.data_format_dim_map(x, src_format="NHWC", dst_format="WHCN") with test_util.use_gpu(): y_val = self.evaluate(y) self.assertAllEqual(y_val, y_val_expected)
def testArbitraryASCII(self): x_val = [-4, -3, -2, -1, 0, 1, 2, 3] y_val_expected = [3, 2, 1, 0, 3, 2, 1, 0] x = constant_op.constant(x_val) y = nn_ops.data_format_dim_map(x, src_format="qwer", dst_format="rewq") with self.test_session(use_gpu=test_lib.is_gpu_available()) as sess: y_val = sess.run(y) self.assertAllEqual(y_val, y_val_expected)
def testNHWCtoWHCN(self): x_val = [-4, -3, -2, -1, 0, 1, 2, 3] y_val_expected = [3, 1, 0, 2, 3, 1, 0, 2] x = constant_op.constant(x_val) y = nn_ops.data_format_dim_map(x, src_format="NHWC", dst_format="WHCN") with self.test_session(use_gpu=test_lib.is_gpu_available()) as sess: y_val = sess.run(y) self.assertAllEqual(y_val, y_val_expected)
def testNHWCtoNCHW(self): x_val = [1, -3, -2] y_val_expected = [2, 2, 3] x = constant_op.constant(x_val) y = nn_ops.data_format_dim_map(x, src_format="NHWC", dst_format="NCHW") with self.test_session(use_gpu=test_lib.is_gpu_available()) as sess: y_val = sess.run(y) self.assertAllEqual(y_val, y_val_expected)
def _test(self, input_data, src_format, dst_format, expected): for dtype in {np.int32, np.int64}: x = np.array(input_data, dtype=dtype) with self.session() as session: with self.test_scope(): placeholder = array_ops.placeholder(dtypes.as_dtype(x.dtype), x.shape) param = {placeholder: x} output = nn_ops.data_format_dim_map( placeholder, src_format=src_format, dst_format=dst_format) result = session.run(output, param) self.assertAllEqual(result, expected)
def _test(self, x_val, y_val_expected): x = constant_op.constant(x_val) y = nn_ops.data_format_dim_map(x) with self.test_session(use_gpu=test_lib.is_gpu_available()) as sess: y_val = sess.run(y) self.assertAllEqual(y_val, y_val_expected)
def _test(self, x_val, y_val_expected): x = constant_op.constant(x_val) y = nn_ops.data_format_dim_map(x) y_val = self.evaluate(y) self.assertAllEqual(y_val, y_val_expected)
def _test(self, x_val, y_val_expected): x = constant_op.constant(x_val) y = nn_ops.data_format_dim_map(x) y_val = self.evaluate(y) self.assertAllEqual(y_val, y_val_expected)