| 36 | namespace |
| 37 | { |
| 38 | bool validate_subtensor_shape(const TensorInfo &parent_info, const TensorInfo &child_info, const Coordinates &coords) |
| 39 | { |
| 40 | bool is_valid = true; |
| 41 | const TensorShape &parent_shape = parent_info.tensor_shape(); |
| 42 | const TensorShape &child_shape = child_info.tensor_shape(); |
| 43 | const size_t parent_dims = parent_info.num_dimensions(); |
| 44 | const size_t child_dims = child_info.num_dimensions(); |
| 45 | |
| 46 | if (child_dims <= parent_dims) |
| 47 | { |
| 48 | for (size_t num_dimensions = child_dims; num_dimensions > 0; --num_dimensions) |
| 49 | { |
| 50 | const size_t child_dim_size = coords[num_dimensions - 1] + child_shape[num_dimensions - 1]; |
| 51 | |
| 52 | if ((coords[num_dimensions - 1] < 0) || (child_dim_size > parent_shape[num_dimensions - 1])) |
| 53 | { |
| 54 | is_valid = false; |
| 55 | break; |
| 56 | } |
| 57 | } |
| 58 | } |
| 59 | else |
| 60 | { |
| 61 | is_valid = false; |
| 62 | } |
| 63 | |
| 64 | return is_valid; |
| 65 | } |
| 66 | } // namespace |
| 67 | |
| 68 | TensorAllocator::TensorAllocator(IMemoryManageable *owner) : _owner(owner), _associated_memory_group(nullptr), _memory() |