diff --git a/csrc/mmdeploy/codebase/mmdet/instance_segmentation.cpp b/csrc/mmdeploy/codebase/mmdet/instance_segmentation.cpp index 34ffdf691c..c24be17f2c 100644 --- a/csrc/mmdeploy/codebase/mmdet/instance_segmentation.cpp +++ b/csrc/mmdeploy/codebase/mmdet/instance_segmentation.cpp @@ -28,6 +28,7 @@ class ResizeInstanceMask : public ResizeBBox { Result operator()(const Value& prep_res, const Value& infer_res) { MMDEPLOY_DEBUG("prep_res: {}\ninfer_res: {}", prep_res, infer_res); try { + DeviceGuard guard(device_); auto dets = infer_res["dets"].get(); auto labels = infer_res["labels"].get(); auto masks = infer_res["masks"].get(); diff --git a/csrc/mmdeploy/preprocess/transform/compose.cpp b/csrc/mmdeploy/preprocess/transform/compose.cpp index ea0315d022..44fbd86d4c 100644 --- a/csrc/mmdeploy/preprocess/transform/compose.cpp +++ b/csrc/mmdeploy/preprocess/transform/compose.cpp @@ -55,6 +55,7 @@ class Compose : public Transform { if (!hash_code_.empty()) { context.set_use_dummy(true); } + DeviceGuard guard(device_); for (size_t i = 0; i < transforms_.size(); ++i) { std::optional child_counter; if (scope_) {