From bd970e022fdf3db05c4fb18d0f4c4115695eeda7 Mon Sep 17 00:00:00 2001 From: Nayana Thorat Date: Tue, 24 Jan 2017 23:24:54 +0530 Subject: [PATCH] Adding support for Big Endian in decode_raw_op_test (#6689) --- tensorflow/core/kernels/decode_raw_op.cc | 6 ------ tensorflow/python/kernel_tests/decode_raw_op_test.py | 9 +++++++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/tensorflow/core/kernels/decode_raw_op.cc b/tensorflow/core/kernels/decode_raw_op.cc index 280c2dc71c3..4247abcd710 100644 --- a/tensorflow/core/kernels/decode_raw_op.cc +++ b/tensorflow/core/kernels/decode_raw_op.cc @@ -69,12 +69,6 @@ class DecodeRawOp : public OpKernel { context, context->allocate_output("output", out_shape, &output_tensor)); auto out = output_tensor->flat_inner_dims(); DCHECK_EQ(flat_in.size(), out.dimensions()[0]); - OP_REQUIRES( - context, - little_endian_ == ::tensorflow::port::kLittleEndian || sizeof(T) == 1, - errors::Unimplemented("Unimplemented support for little_endian=", - little_endian_ ? "true" : "false")); - // Endianness matches, so just copy each string byte-for-byte. T* out_data = out.data(); for (int64 i = 0; i < flat_in.size(); ++i) { const T* in_data = reinterpret_cast(flat_in(i).data()); diff --git a/tensorflow/python/kernel_tests/decode_raw_op_test.py b/tensorflow/python/kernel_tests/decode_raw_op_test.py index 472808c8f9c..cd7216c5279 100644 --- a/tensorflow/python/kernel_tests/decode_raw_op_test.py +++ b/tensorflow/python/kernel_tests/decode_raw_op_test.py @@ -19,6 +19,7 @@ from __future__ import division from __future__ import print_function import numpy as np +import sys from tensorflow.python.framework import dtypes from tensorflow.python.ops import array_ops @@ -53,8 +54,12 @@ class DecodeRawOpTest(test.TestCase): self.assertEqual([None, None], decode.get_shape().as_list()) result = decode.eval(feed_dict={in_bytes: ["AaBC"]}) - self.assertAllEqual( - [[ord("A") + ord("a") * 256, ord("B") + ord("C") * 256]], result) + if sys.byteorder == "big": + self.assertAllEqual( + [[ord("A") * 256 + ord("a"), ord("B") * 256 + ord("C")]], result) + else: + self.assertAllEqual( + [[ord("A") + ord("a") * 256, ord("B") + ord("C") * 256]], result) with self.assertRaisesOpError( "Input to DecodeRaw has length 3 that is not a multiple of 2, the "