Skip to content
Open
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
1 change: 1 addition & 0 deletions sherpa-onnx/csrc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ if(SHERPA_ONNX_ENABLE_AXCL)
./axcl/axcl-manager.cc
./axcl/axcl-model.cc
./axcl/offline-sense-voice-model-axcl.cc
./axcl/offline-fire-red-asr-ctc-model-axcl.cc
./axcl/utils.cc
)
endif()
Expand Down
30 changes: 30 additions & 0 deletions sherpa-onnx/csrc/axcl/axcl-model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,31 @@ class AxclModel::Impl {
return {};
}

std::vector<uint8_t> GetOutputTensorDataRaw(const std::string &name) const {
for (size_t i = 0; i < output_tensor_names_.size(); ++i) {
if (output_tensor_names_[i] == name) {
size_t bytes = output_tensors_[i].Size();
std::vector<uint8_t> out(bytes);

auto ret = axclrtMemcpy(out.data(), output_tensors_[i].Get(), bytes,
AXCL_MEMCPY_DEVICE_TO_HOST);
if (ret != 0) {
SHERPA_ONNX_LOGE(
"Failed to call axclrtMemcpy(). tensor name: '%s', return code: "
"%d",
name.c_str(), static_cast<int32_t>(ret));
return {};
}

return out;
}
}

SHERPA_ONNX_LOGE("Found no tensor with name: '%s'", name.c_str());

return {};
}

bool Run() const {
uint32_t group = 0;
auto ret =
Expand Down Expand Up @@ -434,6 +459,11 @@ std::vector<float> AxclModel::GetOutputTensorData(
return impl_->GetOutputTensorData(name);
}

std::vector<uint8_t> AxclModel::GetOutputTensorDataRaw(
const std::string &name) const {
return impl_->GetOutputTensorDataRaw(name);
}

bool AxclModel::Run() const { return impl_->Run(); }

bool AxclModel::IsInitialized() const { return impl_->IsInitialized(); }
Expand Down
2 changes: 2 additions & 0 deletions sherpa-onnx/csrc/axcl/axcl-model.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class AxclModel {

std::vector<float> GetOutputTensorData(const std::string &name) const;

std::vector<uint8_t> GetOutputTensorDataRaw(const std::string &name) const;

bool Run() const;
bool IsInitialized() const;

Expand Down
Loading
Loading