From f7ea9477fb15a02a285544b5e3796acd431f9c6a Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EA=B9=80=EC=88=98=EC=A7=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Engineer/=EC=82=BC=EC=84=B1=EC=A0=84?= =?utf8?q?=EC=9E=90?= Date: Tue, 31 Jul 2018 16:44:19 +0900 Subject: [PATCH] [neurun] Add skeleton of tensor conversion kernels (#2065) * [neurun] Add skeleton of tensor conversion kernels Related : #1974 This commit adds skeleton of tensor conversion kernels inherited arm_compute::IFunction. It's part PR of #2056(https://github.sec.samsung.net/STAR/nnfw/pull/2056#issuecomment-128722) Signed-off-by: sjsujinkim * Seperate specific layers and apply common tensor --- .../kernel/acl_cl/TensorConvertFromCommonLayer.cc | 46 ++++++++++++++++++ .../kernel/acl_cl/TensorConvertFromCommonLayer.h | 56 ++++++++++++++++++++++ .../kernel/acl_cl/TensorConvertToCommonLayer.cc | 46 ++++++++++++++++++ .../src/kernel/acl_cl/TensorConvertToCommonLayer.h | 56 ++++++++++++++++++++++ .../cpufallback/TensorConvertFromCommonLayer.cc | 46 ++++++++++++++++++ .../cpufallback/TensorConvertFromCommonLayer.h | 55 +++++++++++++++++++++ .../cpufallback/TensorConvertToCommonLayer.cc | 46 ++++++++++++++++++ .../cpufallback/TensorConvertToCommonLayer.h | 55 +++++++++++++++++++++ 8 files changed, 406 insertions(+) create mode 100644 runtimes/neurun/src/kernel/acl_cl/TensorConvertFromCommonLayer.cc create mode 100644 runtimes/neurun/src/kernel/acl_cl/TensorConvertFromCommonLayer.h create mode 100644 runtimes/neurun/src/kernel/acl_cl/TensorConvertToCommonLayer.cc create mode 100644 runtimes/neurun/src/kernel/acl_cl/TensorConvertToCommonLayer.h create mode 100644 runtimes/neurun/src/kernel/cpufallback/TensorConvertFromCommonLayer.cc create mode 100644 runtimes/neurun/src/kernel/cpufallback/TensorConvertFromCommonLayer.h create mode 100644 runtimes/neurun/src/kernel/cpufallback/TensorConvertToCommonLayer.cc create mode 100644 runtimes/neurun/src/kernel/cpufallback/TensorConvertToCommonLayer.h diff --git a/runtimes/neurun/src/kernel/acl_cl/TensorConvertFromCommonLayer.cc b/runtimes/neurun/src/kernel/acl_cl/TensorConvertFromCommonLayer.cc new file mode 100644 index 0000000..6885817 --- /dev/null +++ b/runtimes/neurun/src/kernel/acl_cl/TensorConvertFromCommonLayer.cc @@ -0,0 +1,46 @@ +/* + * 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 "TensorConvertFromCommonLayer.h" + +#include "logging.h" + +namespace internal +{ +namespace kernel +{ +namespace acl_cl +{ + +bool TensorConvertFromCommonLayer::convert() +{ + VERBOSE(TensorConvertFromCommonLayer) + << "Tensor conversion from common, but it is not yet implemented." << std::endl; + return true; +} + +void TensorConvertFromCommonLayer::configure(::internal::common::Tensor *inputTensor, + ::arm_compute::ICLTensor *outputTensor) +{ + _inputTensor = inputTensor; + _outputTensor = outputTensor; +} + +void TensorConvertFromCommonLayer::run() { convert(); } + +} // namespace acl_cl +} // namespace kernel +} // namespace internal diff --git a/runtimes/neurun/src/kernel/acl_cl/TensorConvertFromCommonLayer.h b/runtimes/neurun/src/kernel/acl_cl/TensorConvertFromCommonLayer.h new file mode 100644 index 0000000..3b79ca1 --- /dev/null +++ b/runtimes/neurun/src/kernel/acl_cl/TensorConvertFromCommonLayer.h @@ -0,0 +1,56 @@ +/* + * 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. + */ + +#ifndef __INTERNAL_KERNELS_ACL_CL_TENSOR_CONVERT_FROM_COMMON_LAYER_H__ +#define __INTERNAL_KERNELS_ACL_CL_TENSOR_CONVERT_FROM_COMMON_LAYER_H__ + +#include + +#include +#include + +#include "internal/Model.h" +#include "internal/common/Tensor.h" + +namespace internal +{ +namespace kernel +{ +namespace acl_cl +{ + +class TensorConvertFromCommonLayer : public ::arm_compute::IFunction +{ +public: + TensorConvertFromCommonLayer() {} + +public: + bool convert(); + + void configure(::internal::common::Tensor *inputTensor, ::arm_compute::ICLTensor *outputTensor); + + void run(); + +private: + ::internal::common::Tensor *_inputTensor; + ::arm_compute::ICLTensor *_outputTensor; +}; + +} // namespace acl_cl +} // namespace kernel +} // namespace internal + +#endif // __INTERNAL_KERNELS_ACL_CL_TENSOR_CONVERT_FROM_COMMON_LAYER_H__ diff --git a/runtimes/neurun/src/kernel/acl_cl/TensorConvertToCommonLayer.cc b/runtimes/neurun/src/kernel/acl_cl/TensorConvertToCommonLayer.cc new file mode 100644 index 0000000..45781e8 --- /dev/null +++ b/runtimes/neurun/src/kernel/acl_cl/TensorConvertToCommonLayer.cc @@ -0,0 +1,46 @@ +/* + * 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 "TensorConvertToCommonLayer.h" + +#include "logging.h" + +namespace internal +{ +namespace kernel +{ +namespace acl_cl +{ + +bool TensorConvertToCommonLayer::convert() +{ + VERBOSE(TensorConvertToCommonLayer) + << "Tensor conversion to common, but it is not yet implemented." << std::endl; + return true; +} + +void TensorConvertToCommonLayer::configure(::arm_compute::ICLTensor *inputTensor, + ::internal::common::Tensor *outputTensor) +{ + _inputTensor = inputTensor; + _outputTensor = outputTensor; +} + +void TensorConvertToCommonLayer::run() { convert(); } + +} // namespace acl_cl +} // namespace kernel +} // namespace internal diff --git a/runtimes/neurun/src/kernel/acl_cl/TensorConvertToCommonLayer.h b/runtimes/neurun/src/kernel/acl_cl/TensorConvertToCommonLayer.h new file mode 100644 index 0000000..1214afa --- /dev/null +++ b/runtimes/neurun/src/kernel/acl_cl/TensorConvertToCommonLayer.h @@ -0,0 +1,56 @@ +/* + * 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. + */ + +#ifndef __INTERNAL_KERNELS_ACL_CL_TENSOR_CONVERT_TO_COMMON_LAYER_H__ +#define __INTERNAL_KERNELS_ACL_CL_TENSOR_CONVERT_TO_COMMON_LAYER_H__ + +#include + +#include +#include + +#include "internal/Model.h" +#include "internal/common/Tensor.h" + +namespace internal +{ +namespace kernel +{ +namespace acl_cl +{ + +class TensorConvertToCommonLayer : public ::arm_compute::IFunction +{ +public: + TensorConvertToCommonLayer() {} + +public: + bool convert(); + + void configure(::arm_compute::ICLTensor *inputTensor, ::internal::common::Tensor *outputTensor); + + void run(); + +private: + ::arm_compute::ICLTensor *_inputTensor; + ::internal::common::Tensor *_outputTensor; +}; + +} // namespace acl_cl +} // namespace kernel +} // namespace internal + +#endif // __INTERNAL_KERNELS_ACL_CL_TENSOR_CONVERT_TO_COMMON_LAYER_H__ diff --git a/runtimes/neurun/src/kernel/cpufallback/TensorConvertFromCommonLayer.cc b/runtimes/neurun/src/kernel/cpufallback/TensorConvertFromCommonLayer.cc new file mode 100644 index 0000000..8264d7f --- /dev/null +++ b/runtimes/neurun/src/kernel/cpufallback/TensorConvertFromCommonLayer.cc @@ -0,0 +1,46 @@ +/* + * 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 "TensorConvertFromCommonLayer.h" + +#include "logging.h" + +namespace internal +{ +namespace kernel +{ +namespace cpu +{ + +bool TensorConvertFromCommonLayer::convert() +{ + VERBOSE(TensorConvertFromCommonLayer) + << "Tensor conversion from common, but it is not yet implemented." << std::endl; + return true; +} + +void TensorConvertFromCommonLayer::configure(::internal::common::Tensor *inputData, + uint8_t *outputData) +{ + _inputData = inputData; + _outputData = outputData; +} + +void TensorConvertFromCommonLayer::run() { convert(); } + +} // namespace cpu +} // namespace kernel +} // namespace internal diff --git a/runtimes/neurun/src/kernel/cpufallback/TensorConvertFromCommonLayer.h b/runtimes/neurun/src/kernel/cpufallback/TensorConvertFromCommonLayer.h new file mode 100644 index 0000000..fd745bb --- /dev/null +++ b/runtimes/neurun/src/kernel/cpufallback/TensorConvertFromCommonLayer.h @@ -0,0 +1,55 @@ +/* + * 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. + */ + +#ifndef __INTERNAL_KERNELS_CPU_TENSOR_CONVERT_FROM_COMMON_LAYER_H__ +#define __INTERNAL_KERNELS_CPU_TENSOR_CONVERT_FROM_COMMON_LAYER_H__ + +#include + +#include + +#include "internal/Model.h" +#include "internal/common/Tensor.h" + +namespace internal +{ +namespace kernel +{ +namespace cpu +{ + +class TensorConvertFromCommonLayer : public ::arm_compute::IFunction +{ +public: + TensorConvertFromCommonLayer() {} + +public: + bool convert(); + + void configure(::internal::common::Tensor *inputData, uint8_t *outputData); + + void run(); + +private: + ::internal::common::Tensor *_inputData; + uint8_t *_outputData; +}; + +} // namespace cpu +} // namespace kernel +} // namespace internal + +#endif // __INTERNAL_KERNELS_CPU_TENSOR_CONVERT_FROM_COMMON_LAYER_H__ diff --git a/runtimes/neurun/src/kernel/cpufallback/TensorConvertToCommonLayer.cc b/runtimes/neurun/src/kernel/cpufallback/TensorConvertToCommonLayer.cc new file mode 100644 index 0000000..7408561 --- /dev/null +++ b/runtimes/neurun/src/kernel/cpufallback/TensorConvertToCommonLayer.cc @@ -0,0 +1,46 @@ +/* + * 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 "TensorConvertToCommonLayer.h" + +#include "logging.h" + +namespace internal +{ +namespace kernel +{ +namespace cpu +{ + +bool TensorConvertToCommonLayer::convert() +{ + VERBOSE(ConvertToCommon) << "Tensor conversion to common, but it is not yet implemented." + << std::endl; + return true; +} + +void TensorConvertToCommonLayer::configure(uint8_t *inputData, + ::internal::common::Tensor *outputData) +{ + _inputData = inputData; + _outputData = outputData; +} + +void TensorConvertToCommonLayer::run() { convert(); } + +} // namespace cpu +} // namespace kernel +} // namespace internal diff --git a/runtimes/neurun/src/kernel/cpufallback/TensorConvertToCommonLayer.h b/runtimes/neurun/src/kernel/cpufallback/TensorConvertToCommonLayer.h new file mode 100644 index 0000000..738ffa5 --- /dev/null +++ b/runtimes/neurun/src/kernel/cpufallback/TensorConvertToCommonLayer.h @@ -0,0 +1,55 @@ +/* + * 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. + */ + +#ifndef __INTERNAL_KERNELS_CPU_TENSOR_CONVERT_TO_COMMON_LAYER_H__ +#define __INTERNAL_KERNELS_CPU_TENSOR_CONVERT_TO_COMMON_LAYER_H__ + +#include + +#include + +#include "internal/Model.h" +#include "internal/common/Tensor.h" + +namespace internal +{ +namespace kernel +{ +namespace cpu +{ + +class TensorConvertToCommonLayer : public ::arm_compute::IFunction +{ +public: + TensorConvertToCommonLayer() {} + +public: + bool convert(); + + void configure(uint8_t *inputData, ::internal::common::Tensor *outputData); + + void run(); + +private: + uint8_t *_inputData; + ::internal::common::Tensor *_outputData; +}; + +} // namespace cpu +} // namespace kernel +} // namespace internal + +#endif // __INTERNAL_KERNELS_CPU_TENSOR_CONVERT_TO_COMMON_LAYER_H__ -- 2.7.4