1/* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16#ifndef OHOS_HDI_NNRT_V2_0_NNRTDEVICESTUB_H 17#define OHOS_HDI_NNRT_V2_0_NNRTDEVICESTUB_H 18 19#include <ipc_object_stub.h> 20#include <message_option.h> 21#include <message_parcel.h> 22#include <object_collector.h> 23#include <refbase.h> 24#include "v2_0/innrt_device.h" 25 26namespace OHOS { 27namespace HDI { 28namespace Nnrt { 29namespace V2_0 { 30 31using namespace OHOS; 32class NnrtDeviceStub : public IPCObjectStub { 33public: 34 explicit NnrtDeviceStub(const sptr<INnrtDevice> &impl); 35 virtual ~NnrtDeviceStub(); 36 37 int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; 38 39 static int32_t NnrtDeviceStubGetDeviceName_(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption, sptr<OHOS::HDI::Nnrt::V2_0::INnrtDevice> impl); 40 41 static int32_t NnrtDeviceStubGetVendorName_(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption, sptr<OHOS::HDI::Nnrt::V2_0::INnrtDevice> impl); 42 43 static int32_t NnrtDeviceStubGetDeviceType_(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption, sptr<OHOS::HDI::Nnrt::V2_0::INnrtDevice> impl); 44 45 static int32_t NnrtDeviceStubGetDeviceStatus_(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption, sptr<OHOS::HDI::Nnrt::V2_0::INnrtDevice> impl); 46 47 static int32_t NnrtDeviceStubGetSupportedOperation_(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption, sptr<OHOS::HDI::Nnrt::V2_0::INnrtDevice> impl); 48 49 static int32_t NnrtDeviceStubIsFloat16PrecisionSupported_(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption, sptr<OHOS::HDI::Nnrt::V2_0::INnrtDevice> impl); 50 51 static int32_t NnrtDeviceStubIsPerformanceModeSupported_(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption, sptr<OHOS::HDI::Nnrt::V2_0::INnrtDevice> impl); 52 53 static int32_t NnrtDeviceStubIsPrioritySupported_(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption, sptr<OHOS::HDI::Nnrt::V2_0::INnrtDevice> impl); 54 55 static int32_t NnrtDeviceStubIsDynamicInputSupported_(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption, sptr<OHOS::HDI::Nnrt::V2_0::INnrtDevice> impl); 56 57 static int32_t NnrtDeviceStubPrepareModel_(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption, sptr<OHOS::HDI::Nnrt::V2_0::INnrtDevice> impl); 58 59 static int32_t NnrtDeviceStubIsModelCacheSupported_(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption, sptr<OHOS::HDI::Nnrt::V2_0::INnrtDevice> impl); 60 61 static int32_t NnrtDeviceStubPrepareModelFromModelCache_(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption, sptr<OHOS::HDI::Nnrt::V2_0::INnrtDevice> impl); 62 63 static int32_t NnrtDeviceStubPrepareOfflineModel_(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption, sptr<OHOS::HDI::Nnrt::V2_0::INnrtDevice> impl); 64 65 static int32_t NnrtDeviceStubAllocateBuffer_(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption, sptr<OHOS::HDI::Nnrt::V2_0::INnrtDevice> impl); 66 67 static int32_t NnrtDeviceStubReleaseBuffer_(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption, sptr<OHOS::HDI::Nnrt::V2_0::INnrtDevice> impl); 68 69 static int32_t NnrtDeviceStubGetVersion_(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption, sptr<OHOS::HDI::Nnrt::V2_0::INnrtDevice> impl); 70 71private: 72 int32_t NnrtDeviceStubGetDeviceName(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption); 73 74 int32_t NnrtDeviceStubGetVendorName(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption); 75 76 int32_t NnrtDeviceStubGetDeviceType(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption); 77 78 int32_t NnrtDeviceStubGetDeviceStatus(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption); 79 80 int32_t NnrtDeviceStubGetSupportedOperation(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption); 81 82 int32_t NnrtDeviceStubIsFloat16PrecisionSupported(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption); 83 84 int32_t NnrtDeviceStubIsPerformanceModeSupported(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption); 85 86 int32_t NnrtDeviceStubIsPrioritySupported(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption); 87 88 int32_t NnrtDeviceStubIsDynamicInputSupported(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption); 89 90 int32_t NnrtDeviceStubPrepareModel(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption); 91 92 int32_t NnrtDeviceStubIsModelCacheSupported(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption); 93 94 int32_t NnrtDeviceStubPrepareModelFromModelCache(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption); 95 96 int32_t NnrtDeviceStubPrepareOfflineModel(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption); 97 98 int32_t NnrtDeviceStubAllocateBuffer(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption); 99 100 int32_t NnrtDeviceStubReleaseBuffer(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption); 101 102 int32_t NnrtDeviceStubGetVersion(MessageParcel& nnrtDeviceData, MessageParcel& nnrtDeviceReply, MessageOption& nnrtDeviceOption); 103 104 105 static inline ObjectDelegator<OHOS::HDI::Nnrt::V2_0::NnrtDeviceStub, OHOS::HDI::Nnrt::V2_0::INnrtDevice> objDelegator_; 106 sptr<OHOS::HDI::Nnrt::V2_0::INnrtDevice> impl_; 107}; 108} // V2_0 109} // Nnrt 110} // HDI 111} // OHOS 112 113#endif // OHOS_HDI_NNRT_V2_0_NNRTDEVICESTUB_H 114 115