// // Copyright © 2021, 2024 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // #pragma once #include #include #include #include #include #include template, typename TOutput=armnn::ResolveType> LayerTestResult CastTest(armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, const armnn::ITensorHandleFactory& tensorHandleFactory, const std::vector& inputTensor, const std::vector& outputTensor); LayerTestResult CastInt32ToFloat2dTest( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, const armnn::ITensorHandleFactory& tensorHandleFactory); LayerTestResult CastInt16ToFloat2dTest( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, const armnn::ITensorHandleFactory& tensorHandleFactory); LayerTestResult CastInt8ToFloat2dTest( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, const armnn::ITensorHandleFactory& tensorHandleFactory); LayerTestResult CastInt8AsymmToFloat2dTest( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, const armnn::ITensorHandleFactory& tensorHandleFactory); LayerTestResult CastUInt8ToFloat2dTest( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, const armnn::ITensorHandleFactory& tensorHandleFactory); LayerTestResult CastInt8ToUInt82dTest( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, const armnn::ITensorHandleFactory& tensorHandleFactory); LayerTestResult CastInt8AsymmToUInt82dTest( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, const armnn::ITensorHandleFactory& tensorHandleFactory); LayerTestResult CastFloat16ToFloat322dTest( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, const armnn::ITensorHandleFactory& tensorHandleFactory); LayerTestResult CastBFloat16ToFloat322dTest( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, const armnn::ITensorHandleFactory& tensorHandleFactory); LayerTestResult CastFloat32ToFloat162dTest( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, const armnn::ITensorHandleFactory& tensorHandleFactory); LayerTestResult CastFloat32ToInt82dTest( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, const armnn::ITensorHandleFactory& tensorHandleFactory); LayerTestResult CastFloat32ToUInt82dTest( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, const armnn::ITensorHandleFactory& tensorHandleFactory); template void CastSimpleTest(const std::vector& backends, const std::vector& shape, const std::vector& inputValues, const std::vector& outputValues, float qScale = 1.0f, int32_t qOffset = 0) { using namespace armnn; const TensorShape inputShape(static_cast(shape.size()), shape.data()); const TensorShape outputShape(static_cast(shape.size()), shape.data()); TensorInfo inputTensorInfo(inputShape, inputDataType, qScale, qOffset, true); TensorInfo outputTensorInfo(outputShape, outputDataType, qScale, qOffset); IRuntime::CreationOptions options; IRuntimePtr runtime(IRuntime::Create(options)); INetworkPtr network(INetwork::Create()); IConnectableLayer* input = network->AddInputLayer(0, "input"); IConnectableLayer* castLayer = network->AddCastLayer("cast"); IConnectableLayer* output = network->AddOutputLayer(0, "output"); Connect(input, castLayer, inputTensorInfo, 0, 0); Connect(castLayer, output, outputTensorInfo, 0, 0); std::map> inputTensorData = {{ 0, inputValues }}; std::map> expectedOutputData = {{ 0, outputValues }}; EndToEndLayerTestImpl(std::move(network), inputTensorData, expectedOutputData, backends); }