Home | History | Annotate | Download | only in dataset
      1 /* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
      2 
      3 Licensed under the Apache License, Version 2.0 (the "License");
      4 you may not use this file except in compliance with the License.
      5 You may obtain a copy of the License at
      6 
      7     http://www.apache.org/licenses/LICENSE-2.0
      8 
      9 Unless required by applicable law or agreed to in writing, software
     10 distributed under the License is distributed on an "AS IS" BASIS,
     11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 See the License for the specific language governing permissions and
     13 limitations under the License.
     14 ==============================================================================*/
     15 
     16 #ifndef TENSORFLOW_CONTRIB_IGNITE_KERNELS_DATASET_IGNITE_BINARY_OBJECT_PARSER_H_
     17 #define TENSORFLOW_CONTRIB_IGNITE_KERNELS_DATASET_IGNITE_BINARY_OBJECT_PARSER_H_
     18 
     19 #include <vector>
     20 #include "tensorflow/contrib/ignite/kernels/client/ignite_byte_swapper.h"
     21 #include "tensorflow/core/framework/tensor.h"
     22 #include "tensorflow/core/lib/core/status.h"
     23 
     24 namespace tensorflow {
     25 
     26 class BinaryObjectParser {
     27  public:
     28   BinaryObjectParser();
     29   Status Parse(uint8_t** ptr, std::vector<Tensor>* out_tensors,
     30                std::vector<int32_t>* types) const;
     31 
     32  private:
     33   uint8_t ParseByte(uint8_t** ptr) const;
     34   int16_t ParseShort(uint8_t** ptr) const;
     35   uint16_t ParseUnsignedShort(uint8_t** ptr) const;
     36   int32_t ParseInt(uint8_t** ptr) const;
     37   int64_t ParseLong(uint8_t** ptr) const;
     38   float ParseFloat(uint8_t** ptr) const;
     39   double ParseDouble(uint8_t** ptr) const;
     40   bool ParseBool(uint8_t** ptr) const;
     41   string ParseString(uint8_t** ptr) const;
     42   uint8_t* ParseByteArr(uint8_t** ptr, int length) const;
     43   int16_t* ParseShortArr(uint8_t** ptr, int length) const;
     44   uint16_t* ParseUnsignedShortArr(uint8_t** ptr, int length) const;
     45   int32_t* ParseIntArr(uint8_t** ptr, int length) const;
     46   int64_t* ParseLongArr(uint8_t** ptr, int length) const;
     47   float* ParseFloatArr(uint8_t** ptr, int length) const;
     48   double* ParseDoubleArr(uint8_t** ptr, int length) const;
     49   bool* ParseBoolArr(uint8_t** ptr, int length) const;
     50 
     51   const ByteSwapper byte_swapper_;
     52 };
     53 
     54 enum ObjectType {
     55   BYTE = 1,
     56   SHORT = 2,
     57   INT = 3,
     58   LONG = 4,
     59   FLOAT = 5,
     60   DOUBLE = 6,
     61   USHORT = 7,
     62   BOOL = 8,
     63   STRING = 9,
     64   DATE = 11,
     65   BYTE_ARR = 12,
     66   SHORT_ARR = 13,
     67   INT_ARR = 14,
     68   LONG_ARR = 15,
     69   FLOAT_ARR = 16,
     70   DOUBLE_ARR = 17,
     71   USHORT_ARR = 18,
     72   BOOL_ARR = 19,
     73   STRING_ARR = 20,
     74   DATE_ARR = 22,
     75   WRAPPED_OBJ = 27,
     76   COMPLEX_OBJ = 103
     77 };
     78 
     79 }  // namespace tensorflow
     80 
     81 #endif  // TENSORFLOW_CONTRIB_IGNITE_KERNELS_DATASET_IGNITE_BINARY_OBJECT_PARSER_H_
     82