Use the default stream as the execution stream of rtModel
This commit is contained in:
parent
611544cbf1
commit
273d6bdb40
|
@ -529,7 +529,7 @@ bool AscendKernelRuntime::GenTask(const session::KernelGraph &graph) {
|
|||
<< ", wait_active_stream_list size:" << wait_active_stream_list.size()
|
||||
<< ", force_copy_stream_list size:" << force_copy_stream_list.size();
|
||||
auto model = std::make_shared<ge::model_runner::DavinciModel>(
|
||||
task_info_list, wait_active_stream_list, force_copy_stream_list, 0, 0, 0, 0, 0, 0,
|
||||
task_info_list, wait_active_stream_list, force_copy_stream_list, stream_, 0, 0, 0, 0, 0, 0,
|
||||
resource_manager.cur_stream_num(), graph.label_num(), resource_manager.cur_event_num(), 0);
|
||||
auto ret = graph_model_map_.insert(std::make_pair(graph.graph_id(), model));
|
||||
if (!ret.second) {
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "runtime/base.h"
|
||||
#include "plugin/device/ascend/hal/device/ge_runtime/task_info.h"
|
||||
|
||||
namespace mindspore::ge::model_runner {
|
||||
|
@ -26,13 +27,14 @@ class DavinciModel {
|
|||
public:
|
||||
DavinciModel(const std::vector<std::shared_ptr<TaskInfo>> &task_info_list,
|
||||
const std::vector<uint32_t> &wait_active_stream_list,
|
||||
const std::vector<uint32_t> &force_copy_stream_list, uint64_t mem_size = 0, uint64_t weight_size = 0,
|
||||
uint64_t var_size = 0, uintptr_t logic_mem_base = 0, uintptr_t logic_weight_base = 0,
|
||||
uintptr_t logic_var_base = 0, uint32_t stream_num = 0, uint32_t batch_num = 0, uint32_t event_num = 0,
|
||||
int32_t priority = 0)
|
||||
const std::vector<uint32_t> &force_copy_stream_list, rtStream_t model_stream, uint64_t mem_size = 0,
|
||||
uint64_t weight_size = 0, uint64_t var_size = 0, uintptr_t logic_mem_base = 0,
|
||||
uintptr_t logic_weight_base = 0, uintptr_t logic_var_base = 0, uint32_t stream_num = 0,
|
||||
uint32_t batch_num = 0, uint32_t event_num = 0, int32_t priority = 0)
|
||||
: task_info_list_(task_info_list),
|
||||
wait_active_stream_list_(wait_active_stream_list),
|
||||
force_copy_stream_list_(force_copy_stream_list),
|
||||
model_stream_(model_stream),
|
||||
mem_size_(mem_size),
|
||||
weight_size_(weight_size),
|
||||
var_size_(var_size),
|
||||
|
@ -45,6 +47,8 @@ class DavinciModel {
|
|||
priority_(priority) {}
|
||||
~DavinciModel() {}
|
||||
|
||||
rtStream_t model_stream() const { return model_stream_; }
|
||||
|
||||
uint64_t GetMemSize() const { return mem_size_; }
|
||||
uint64_t GetWeightSize() const { return weight_size_; }
|
||||
uint64_t GetVarSize() const { return var_size_; }
|
||||
|
@ -70,6 +74,8 @@ class DavinciModel {
|
|||
std::vector<uint32_t> wait_active_stream_list_;
|
||||
std::vector<uint32_t> force_copy_stream_list_;
|
||||
|
||||
rtStream_t model_stream_;
|
||||
|
||||
uint64_t mem_size_;
|
||||
uint64_t weight_size_;
|
||||
uint64_t var_size_;
|
||||
|
|
|
@ -139,12 +139,7 @@ void RuntimeModel::InitResource(const std::shared_ptr<DavinciModel> &davinci_mod
|
|||
MS_LOG(EXCEPTION) << "Call rt api rtModelCreate failed, ret: " << rt_ret;
|
||||
}
|
||||
|
||||
// Create rtStream for rt_model_handle_
|
||||
rt_ret = rtStreamCreate(&rt_model_stream_, davinci_model->GetPriority());
|
||||
if (rt_ret != RT_ERROR_NONE) {
|
||||
MS_LOG(EXCEPTION) << "Call rt api rtStreamCreate failed, ret: " << rt_ret;
|
||||
}
|
||||
MS_LOG(INFO) << "rtStreamCreate end";
|
||||
rt_model_stream_ = davinci_model->model_stream();
|
||||
|
||||
InitStream(davinci_model);
|
||||
InitEvent(davinci_model->GetEventNum());
|
||||
|
@ -255,11 +250,6 @@ void RuntimeModel::RtModelUnbindStream() noexcept {
|
|||
}
|
||||
|
||||
void RuntimeModel::RtStreamDestory() noexcept {
|
||||
if (rtStreamDestroy(rt_model_stream_) != RT_ERROR_NONE) {
|
||||
MS_LOG(ERROR) << "Destroy stream for rt_model failed!";
|
||||
return;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < stream_list_.size(); i++) {
|
||||
if (rtStreamDestroy(stream_list_[i]) != RT_ERROR_NONE) {
|
||||
MS_LOG(ERROR) << "Destroy stream failed! Index: " << i;
|
||||
|
|
|
@ -46,9 +46,13 @@ class MockOpsKernelInfoStore : public ge::OpsKernelInfoStore {
|
|||
bool CheckSupported(const ge::OpDescPtr &opDescPtr, std::string &un_supported_reason) const override { return true; }
|
||||
bool CheckSupported(const ge::NodePtr &node, std::string &un_supported_reason) const { return true; }
|
||||
bool CheckAccuracySupported(const ge::OpDescPtr &opDescPtr, std::string &un_supported_reason,
|
||||
const bool realQuery = false) const override { return true; }
|
||||
const bool realQuery = false) const override {
|
||||
return true;
|
||||
}
|
||||
bool CheckAccuracySupported(const ge::NodePtr &node, std::string &un_supported_reason,
|
||||
const bool realQuery = false) const { return true; }
|
||||
const bool realQuery = false) const {
|
||||
return true;
|
||||
}
|
||||
ge::Status LoadTask(ge::GETaskInfo &task) override { return ge::SUCCESS; }
|
||||
};
|
||||
|
||||
|
@ -456,9 +460,9 @@ TEST_F(TestAscendGeRuntime, test_model_runner_success) {
|
|||
std::shared_ptr<TaskInfo> aicpu_task_info = std::make_shared<AicpuTaskInfo>(
|
||||
"op_name", 0, "so_name", "kernel_name", "node_def", "ext_info", std::vector<void *>{reinterpret_cast<void *>(1)},
|
||||
std::vector<void *>{reinterpret_cast<void *>(1)}, true);
|
||||
auto davice_model =
|
||||
std::make_shared<DavinciModel>(std::vector<std::shared_ptr<TaskInfo>>{tbe_task_info, aicpu_task_info},
|
||||
std::vector<uint32_t>{}, std::vector<uint32_t>{}, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0);
|
||||
auto davice_model = std::make_shared<DavinciModel>(
|
||||
std::vector<std::shared_ptr<TaskInfo>>{tbe_task_info, aicpu_task_info}, std::vector<uint32_t>{},
|
||||
std::vector<uint32_t>{}, nullptr, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0);
|
||||
ASSERT_NO_THROW(ModelRunner::Instance().LoadDavinciModel(0, 0, model_id, davice_model));
|
||||
auto iter = ModelRunner::Instance().runtime_models_.find(model_id);
|
||||
ASSERT_TRUE(iter != ModelRunner::Instance().runtime_models_.end());
|
||||
|
|
Loading…
Reference in New Issue