diff options
Diffstat (limited to 'runtimes/neurun/src/backend/acl_cl/Convert.cc')
-rw-r--r-- | runtimes/neurun/src/backend/acl_cl/Convert.cc | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/runtimes/neurun/src/backend/acl_cl/Convert.cc b/runtimes/neurun/src/backend/acl_cl/Convert.cc deleted file mode 100644 index ed0a089c4..000000000 --- a/runtimes/neurun/src/backend/acl_cl/Convert.cc +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "Convert.h" - -#include "Swizzle.h" -#include "model/operand/DataType.h" - -namespace neurun -{ -namespace backend -{ -namespace acl_cl -{ - -::arm_compute::TensorShape asTensorShape(const ::neurun::model::operand::Shape &shape, - bool apply_dim_correction) -{ - const uint32_t rank = shape.rank(); - - ::arm_compute::TensorShape res{}; - - res.set_num_dimensions(rank); - - for (uint32_t axis = 0; axis < rank; ++axis) - { - // NOTE In some cases, in incorrect dimensions is required. - // For example, intput_size is 1 in LSTM. The input-to-input weights([num_units, input_size]) of - // LSTM is used as the weight of the FullyConnected. - // The FullyConnected's weight must be greater or equal than 2-dimensions. - // However, if the dimension correction is applied to input_to_input_weights with input_size - // equal to 1, it will be changed to 1-D. - // So input_to_input_weights is not used by the weight of FullyConnected. - res.set(ToARMComputeAxis(rank, axis).value(), shape.dim(axis), apply_dim_correction); - } - - return res; -} - -::arm_compute::DataType asDataType(const ::neurun::model::operand::DataType &type) -{ - switch (type) - { - case ::neurun::model::operand::DataType::SCALAR_FLOAT32: - case ::neurun::model::operand::DataType::TENSOR_FLOAT32: - return ::arm_compute::DataType::F32; - case ::neurun::model::operand::DataType::SCALAR_INT32: - case ::neurun::model::operand::DataType::TENSOR_INT32: - return ::arm_compute::DataType::S32; - case ::neurun::model::operand::DataType::SCALAR_UINT32: - return ::arm_compute::DataType::U32; - case ::neurun::model::operand::DataType::TENSOR_QUANT8_ASYMM: - return ::arm_compute::DataType::QASYMM8; - default: - throw std::runtime_error("Not supported, yet"); - break; - } -} - -::arm_compute::QuantizationInfo asQuantizationInfo(const float scale, const int32_t offset) -{ - return ::arm_compute::QuantizationInfo(scale, offset); -} - -::arm_compute::TensorInfo asTensorInfo(const ::neurun::model::operand::Shape &shape, - const ::neurun::model::operand::TypeInfo &typeInfo) -{ - return ::arm_compute::TensorInfo(asTensorShape(shape), 1, asDataType(typeInfo.type()), - asQuantizationInfo(typeInfo.scale(), typeInfo.offset())); -} - -} // namespace acl_cl -} // namespace backend -} // namespace neurun |