1 /* 2 * Copyright (C) 2018 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 #define LOG_TAG "Operations" 18 19 #include "ExpandDims.h" 20 21 #include "Utils.h" 22 23 namespace android { 24 namespace nn { 25 namespace expand_dims { 26 27 bool prepare(const Shape& input, int32_t axis, Shape* output) { 28 NN_CHECK(handleNegativeAxis(getNumberOfDimensions(input) + 1, &axis)); 29 30 output->type = input.type; 31 output->offset = input.offset; 32 output->scale = input.scale; 33 34 output->dimensions.assign(input.dimensions.begin(), input.dimensions.end()); 35 output->dimensions.insert(output->dimensions.begin() + axis, 1); 36 37 return true; 38 } 39 40 bool eval(const uint8_t* inputData, const Shape& inputShape, int32_t axis, uint8_t* outputData, 41 const Shape& outputShape) { 42 memcpy(outputData, inputData, 43 nonExtensionOperandSizeOfData(inputShape.type, inputShape.dimensions)); 44 return true; 45 } 46 47 } // namespace expand_dims 48 } // namespace nn 49 } // namespace android 50