Adding support for Big Endian in decode_raw_op_test (#6689)
This commit is contained in:
parent
3570b5de07
commit
bd970e022f
@ -69,12 +69,6 @@ class DecodeRawOp : public OpKernel {
|
||||
context, context->allocate_output("output", out_shape, &output_tensor));
|
||||
auto out = output_tensor->flat_inner_dims<T>();
|
||||
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<const T*>(flat_in(i).data());
|
||||
|
@ -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 "
|
||||
|
Loading…
Reference in New Issue
Block a user