1 /* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef bts_SUB_VEC_MAP_EM_H 18 #define bts_SUB_VEC_MAP_EM_H 19 20 /* ---- includes ----------------------------------------------------------- */ 21 22 #include "b_BasicEm/Context.h" 23 #include "b_BasicEm/Basic.h" 24 #include "b_BasicEm/MemTbl.h" 25 #include "b_TensorEm/VectorMap.h" 26 27 /* ---- related objects --------------------------------------------------- */ 28 29 /* ---- typedefs ----------------------------------------------------------- */ 30 31 /* ---- constants ---------------------------------------------------------- */ 32 33 /** data format version number */ 34 #define bts_SUB_VEC_MAP_VERSION 100 35 36 /* ---- object definition -------------------------------------------------- */ 37 38 /** extracts a section from the input vector and returns it as sub-vector */ 39 struct bts_SubVecMap 40 { 41 /* ---- public data ---------------------------------------------------- */ 42 43 /** base element (must be first element) */ 44 struct bts_VectorMap baseE; 45 46 /* ---- private data --------------------------------------------------- */ 47 48 /** vector offset */ 49 int32 offsetE; 50 51 /** vector size (-1: size = input size - offsetE) */ 52 int32 sizeE; 53 54 /* ---- public data ---------------------------------------------------- */ 55 56 }; 57 58 /* ---- associated objects ------------------------------------------------- */ 59 60 /* ---- external functions ------------------------------------------------- */ 61 62 /* ---- \ghd{ constructor/destructor } ------------------------------------- */ 63 64 /** initializes bts_SubVecMap */ 65 void bts_SubVecMap_init( struct bbs_Context* cpA, 66 struct bts_SubVecMap* ptrA ); 67 68 /** resets bts_SubVecMap */ 69 void bts_SubVecMap_exit( struct bbs_Context* cpA, 70 struct bts_SubVecMap* ptrA ); 71 72 /* ---- \ghd{ operators } -------------------------------------------------- */ 73 74 /** copy operator */ 75 void bts_SubVecMap_copy( struct bbs_Context* cpA, 76 struct bts_SubVecMap* ptrA, 77 const struct bts_SubVecMap* srcPtrA ); 78 79 /** equal operator */ 80 flag bts_SubVecMap_equal( struct bbs_Context* cpA, 81 const struct bts_SubVecMap* ptrA, 82 const struct bts_SubVecMap* srcPtrA ); 83 84 /* ---- \ghd{ query functions } -------------------------------------------- */ 85 86 /* ---- \ghd{ modify functions } ------------------------------------------- */ 87 88 /* ---- \ghd{ memory I/O } ------------------------------------------------- */ 89 90 /** word size (16-bit) object needs when written to memory */ 91 uint32 bts_SubVecMap_memSize( struct bbs_Context* cpA, 92 const struct bts_SubVecMap* ptrA ); 93 94 /** writes object to memory; returns number of words (16-bit) written */ 95 uint32 bts_SubVecMap_memWrite( struct bbs_Context* cpA, 96 const struct bts_SubVecMap* ptrA, uint16* memPtrA ); 97 98 /** reads object from memory; returns number of words (16-bit) read */ 99 uint32 bts_SubVecMap_memRead( struct bbs_Context* cpA, 100 struct bts_SubVecMap* ptrA, 101 const uint16* memPtrA, 102 struct bbs_MemTbl* mtpA ); 103 104 /* ---- \ghd{ exec functions } --------------------------------------------- */ 105 106 /** Vector map operation. 107 * Maps vector inVec to outVec (overflow-safe) 108 * Memory areas of vectors may not overlap 109 */ 110 void bts_SubVecMap_map( struct bbs_Context* cpA, 111 const struct bts_VectorMap* ptrA, 112 const struct bts_Flt16Vec* inVecPtrA, 113 struct bts_Flt16Vec* outVecPtrA ); 114 115 #endif /* bts_SUB_VEC_MAP_EM_H */ 116 117