diff --git a/include/data/tensor_util.hpp b/include/data/tensor_util.hpp index d0d89d7b..c79e31f9 100644 --- a/include/data/tensor_util.hpp +++ b/include/data/tensor_util.hpp @@ -335,15 +335,17 @@ std::tuple>, std::shared_ptr>> TensorBroadca TensorCreate(tensor2->channels(), tensor1->rows(), tensor1->cols()); CHECK(tensor2->size() == tensor2->channels()); for (uint32_t c = 0; c < tensor2->channels(); ++c) { - new_tensor->slice(c).fill(tensor2->index(c)); + T* new_tensor_ptr = new_tensor->matrix_raw_ptr(c); + std::fill(new_tensor_ptr, new_tensor_ptr + new_tensor->plane_size(), tensor2->index(c)); } return {tensor1, new_tensor}; } else if (tensor1->rows() == 1 && tensor1->cols() == 1) { std::shared_ptr> new_tensor = TensorCreate(tensor1->channels(), tensor2->rows(), tensor2->cols()); CHECK(tensor1->size() == tensor1->channels()); - for (uint32_t c = 0; c < tensor1->channels(); ++c) { - new_tensor->slice(c).fill(tensor1->index(c)); + for (uint32_t c = 0; c < tensor1->channels(); ++c) { + T* new_tensor_ptr = new_tensor->matrix_raw_ptr(c); + std::fill(new_tensor_ptr, new_tensor_ptr + new_tensor->plane_size(), tensor1->index(c)); } return {new_tensor, tensor2}; } else { diff --git a/include/runtime/runtime_ir.hpp b/include/runtime/runtime_ir.hpp index b225d59c..c0302651 100644 --- a/include/runtime/runtime_ir.hpp +++ b/include/runtime/runtime_ir.hpp @@ -51,7 +51,7 @@ class RuntimeGraph { * @param param_path Path to the parameter file defining the graph structure * @param bin_path Path to the bin file containing the graph weights */ - RuntimeGraph(std::string param_path, std::string bin_path); + explicit RuntimeGraph(std::string param_path, std::string bin_path); /** * @brief Sets the inputs to the graph diff --git a/include/runtime/runtime_operand.hpp b/include/runtime/runtime_operand.hpp index dacf3420..4eeaca0d 100644 --- a/include/runtime/runtime_operand.hpp +++ b/include/runtime/runtime_operand.hpp @@ -41,10 +41,10 @@ namespace kuiper_infer { */ template struct RuntimeOperandBase { - RuntimeOperandBase() = default; + explicit RuntimeOperandBase() = default; - RuntimeOperandBase(std::string name, std::vector shapes, - std::vector>> datas, RuntimeDataType type) + explicit RuntimeOperandBase(std::string name, std::vector shapes, + std::vector>> datas, RuntimeDataType type) : name(std::move(name)), shapes(std::move(shapes)), datas(std::move(datas)), type(type) {} /// Name of the operand diff --git a/source/runtime/runtime_ir.cpp b/source/runtime/runtime_ir.cpp index 9797b14f..2acd07bc 100644 --- a/source/runtime/runtime_ir.cpp +++ b/source/runtime/runtime_ir.cpp @@ -114,7 +114,6 @@ void RuntimeGraph::Build() { // 初始化节点的输入和输出空间 RuntimeOperatorUtils::InitOperatorInput(operators_); RuntimeOperatorUtils::InitOperatorOutput(graph_->ops, operators_); - graph_state_ = GraphState::Complete; if (graph_ != nullptr) { graph_.reset(); @@ -123,8 +122,8 @@ void RuntimeGraph::Build() { } template -StatusCode ExecuteLayer(const std::shared_ptr>& layer, const std::string& op_name, - const std::string& op_type, bool is_debug) { +StatusCode ExecuteLayer(const T& layer, const std::string& op_name, const std::string& op_type, + bool is_debug) { CHECK(layer != nullptr); StatusCode status; if (is_debug) {