Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion lite/backends/apu/neuron_adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,20 @@ void NeuronAdapter::InitFunctions() {
PADDLE_DLSYM(NeuronModel_setOperandValue);
PADDLE_DLSYM(NeuronModel_setOperandSymmPerChannelQuantParams);
PADDLE_DLSYM(NeuronModel_addOperation);
PADDLE_DLSYM(NeuronModel_addOperationExtension);
PADDLE_DLSYM(NeuronModel_identifyInputsAndOutputs);
PADDLE_DLSYM(NeuronCompilation_create);
PADDLE_DLSYM(NeuronCompilation_free);
PADDLE_DLSYM(NeuronCompilation_finish);
PADDLE_DLSYM(NeuronCompilation_createForDevices);
PADDLE_DLSYM(NeuronExecution_create);
PADDLE_DLSYM(NeuronExecution_free);
PADDLE_DLSYM(NeuronExecution_setInput);
PADDLE_DLSYM(NeuronExecution_setOutput);
PADDLE_DLSYM(NeuronExecution_compute);

PADDLE_DLSYM(Neuron_getDeviceCount);
PADDLE_DLSYM(Neuron_getDevice);
PADDLE_DLSYM(NeuronDevice_getName);
#undef PADDLE_DLSYM
}

Expand Down Expand Up @@ -146,6 +150,25 @@ int NeuronModel_addOperation(NeuronModel* model,
model, type, inputCount, inputs, outputCount, outputs);
}

int NeuronModel_addOperationExtension(NeuronModel* model,
const char* name,
const char* vendor,
const NeuronDevice* device,
uint32_t inputCount,
const uint32_t* inputs,
uint32_t outputCount,
const uint32_t* outputs) {
return paddle::lite::NeuronAdapter::Global()
->NeuronModel_addOperationExtension()(model,
name,
vendor,
device,
inputCount,
inputs,
outputCount,
outputs);
}

int NeuronModel_identifyInputsAndOutputs(NeuronModel* model,
uint32_t inputCount,
const uint32_t* inputs,
Expand All @@ -172,6 +195,15 @@ int NeuronCompilation_finish(NeuronCompilation* compilation) {
compilation);
}

int NeuronCompilation_createForDevices(NeuronModel* model,
const NeuronDevice* const* devices,
uint32_t numDevices,
NeuronCompilation** compilation) {
return paddle::lite::NeuronAdapter::Global()
->NeuronCompilation_createForDevices()(
model, devices, numDevices, compilation);
}

int NeuronExecution_create(NeuronCompilation* compilation,
NeuronExecution** execution) {
return paddle::lite::NeuronAdapter::Global()->NeuronExecution_create()(
Expand Down Expand Up @@ -205,3 +237,18 @@ int NeuronExecution_compute(NeuronExecution* execution) {
return paddle::lite::NeuronAdapter::Global()->NeuronExecution_compute()(
execution);
}

int Neuron_getDeviceCount(uint32_t* numDevices) {
return paddle::lite::NeuronAdapter::Global()->Neuron_getDeviceCount()(
numDevices);
}

int Neuron_getDevice(uint32_t devIndex, NeuronDevice** device) {
return paddle::lite::NeuronAdapter::Global()->Neuron_getDevice()(devIndex,
device);
}

int NeuronDevice_getName(const NeuronDevice* device, const char** name) {
return paddle::lite::NeuronAdapter::Global()->NeuronDevice_getName()(device,
name);
}
53 changes: 53 additions & 0 deletions lite/backends/apu/neuron_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,25 @@ class NeuronAdapter final {
const uint32_t *,
uint32_t,
const uint32_t *);
using NeuronModel_addOperationExtension_Type = int (*)(NeuronModel *,
const char *,
const char *,
const NeuronDevice *,
uint32_t,
const uint32_t *,
uint32_t,
const uint32_t *);
using NeuronModel_identifyInputsAndOutputs_Type = int (*)(
NeuronModel *, uint32_t, const uint32_t *, uint32_t, const uint32_t *);
using NeuronCompilation_create_Type = int (*)(NeuronModel *,
NeuronCompilation **);
using NeuronCompilation_free_Type = void (*)(NeuronCompilation *);
using NeuronCompilation_finish_Type = int (*)(NeuronCompilation *);
using NeuronCompilation_createForDevices_Type =
int (*)(NeuronModel *,
const NeuronDevice *const *,
uint32_t,
NeuronCompilation **);
using NeuronExecution_create_Type = int (*)(NeuronCompilation *,
NeuronExecution **);
using NeuronExecution_free_Type = void (*)(NeuronExecution *);
Expand All @@ -59,6 +72,10 @@ class NeuronAdapter final {
using NeuronExecution_setOutput_Type = int (*)(
NeuronExecution *, int32_t, const NeuronOperandType *, void *, size_t);
using NeuronExecution_compute_Type = int (*)(NeuronExecution *);
using Neuron_getDeviceCount_Type = int (*)(uint32_t *);
using Neuron_getDevice_Type = int (*)(uint32_t, NeuronDevice **);
using NeuronDevice_getName_Type = int (*)(const NeuronDevice *,
const char **);

Neuron_getVersion_Type Neuron_getVersion() {
CHECK(Neuron_getVersion_ != nullptr) << "Cannot load Neuron_getVersion!";
Expand Down Expand Up @@ -105,6 +122,12 @@ class NeuronAdapter final {
return NeuronModel_addOperation_;
}

NeuronModel_addOperationExtension_Type NeuronModel_addOperationExtension() {
CHECK(NeuronModel_addOperationExtension_ != nullptr)
<< "Cannot load NeuronModel_addOperationExtension!";
return NeuronModel_addOperationExtension_;
}

NeuronModel_identifyInputsAndOutputs_Type
NeuronModel_identifyInputsAndOutputs() {
CHECK(NeuronModel_identifyInputsAndOutputs_ != nullptr)
Expand All @@ -130,6 +153,12 @@ class NeuronAdapter final {
return NeuronCompilation_finish_;
}

NeuronCompilation_createForDevices_Type NeuronCompilation_createForDevices() {
CHECK(NeuronCompilation_createForDevices_ != nullptr)
<< "Cannot load NeuronCompilation_createForDevices!";
return NeuronCompilation_createForDevices_;
}

NeuronExecution_create_Type NeuronExecution_create() {
CHECK(NeuronExecution_create_ != nullptr)
<< "Cannot load NeuronExecution_create!";
Expand Down Expand Up @@ -160,6 +189,23 @@ class NeuronAdapter final {
return NeuronExecution_compute_;
}

Neuron_getDeviceCount_Type Neuron_getDeviceCount() {
CHECK(Neuron_getDeviceCount_ != nullptr)
<< "Cannot load Neuron_getDeviceCount!";
return Neuron_getDeviceCount_;
}

Neuron_getDevice_Type Neuron_getDevice() {
CHECK(Neuron_getDevice_ != nullptr) << "Cannot load Neuron_getDevice!";
return Neuron_getDevice_;
}

NeuronDevice_getName_Type NeuronDevice_getName() {
CHECK(NeuronDevice_getName_ != nullptr)
<< "Cannot load NeuronDevice_getName!";
return NeuronDevice_getName_;
}

private:
NeuronAdapter();
NeuronAdapter(const NeuronAdapter &) = delete;
Expand All @@ -176,16 +222,23 @@ class NeuronAdapter final {
NeuronModel_setOperandSymmPerChannelQuantParams_Type
NeuronModel_setOperandSymmPerChannelQuantParams_{nullptr};
NeuronModel_addOperation_Type NeuronModel_addOperation_{nullptr};
NeuronModel_addOperationExtension_Type NeuronModel_addOperationExtension_{
nullptr};
NeuronModel_identifyInputsAndOutputs_Type
NeuronModel_identifyInputsAndOutputs_{nullptr};
NeuronCompilation_create_Type NeuronCompilation_create_{nullptr};
NeuronCompilation_free_Type NeuronCompilation_free_{nullptr};
NeuronCompilation_finish_Type NeuronCompilation_finish_{nullptr};
NeuronCompilation_createForDevices_Type NeuronCompilation_createForDevices_{
nullptr};
NeuronExecution_create_Type NeuronExecution_create_{nullptr};
NeuronExecution_free_Type NeuronExecution_free_{nullptr};
NeuronExecution_setInput_Type NeuronExecution_setInput_{nullptr};
NeuronExecution_setOutput_Type NeuronExecution_setOutput_{nullptr};
NeuronExecution_compute_Type NeuronExecution_compute_{nullptr};
Neuron_getDeviceCount_Type Neuron_getDeviceCount_{nullptr};
Neuron_getDevice_Type Neuron_getDevice_{nullptr};
NeuronDevice_getName_Type NeuronDevice_getName_{nullptr};
};
} // namespace lite
} // namespace paddle
4 changes: 4 additions & 0 deletions lite/kernels/apu/bridges/CMakeLists.txt
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ lite_cc_library(subgraph_bridge_act_op_apu SRCS act_op.cc DEPS ${apu_subgraph_br
lite_cc_library(subgraph_bridge_pool_op_apu SRCS pool_op.cc DEPS ${apu_subgraph_bridge_deps})
lite_cc_library(subgraph_bridge_softmax_op_apu SRCS softmax_op.cc DEPS ${apu_subgraph_bridge_deps})
lite_cc_library(subgraph_bridge_fc_op_apu SRCS fc_op.cc DEPS ${apu_subgraph_bridge_deps})
lite_cc_library(subgraph_bridge_concat_op_apu SRCS concat_op.cc DEPS ${apu_subgraph_bridge_deps})
lite_cc_library(subgraph_bridge_conv_transpose_op_apu SRCS conv_transpose_op.cc DEPS ${apu_subgraph_bridge_deps})


set(apu_subgraph_bridges
Expand All @@ -25,6 +27,8 @@ set(apu_subgraph_bridges
subgraph_bridge_softmax_op_apu
subgraph_bridge_fc_op_apu
subgraph_bridge_pool_op_apu
subgraph_bridge_conv_transpose_op_apu
subgraph_bridge_concat_op_apu
CACHE INTERNAL "apu_subgraph_bridges")

message(STATUS "+++++ apu_subgraph_bridges: ${apu_subgraph_bridges}")
Loading