// Copyright (c) OpenMMLab. All rights reserved. #include "test_utils.h" using namespace std; namespace mmdeploy::test { unique_ptr CreateTransform(const Value& cfg, Device device, Stream stream) { auto op_type = cfg.value("type", ""); auto op_version = cfg.value("version", 1); try { auto creator = Registry::Get().GetCreator(op_type, op_version); if (creator == nullptr) { return nullptr; } auto _cfg = cfg; _cfg["context"]["device"] = device; _cfg["context"]["stream"] = stream; return creator->Create(_cfg); } catch (std::exception& e) { cout << "exception: " << e.what() << endl; return nullptr; } catch (...) { cout << "unexpected exception" << endl; return nullptr; } } vector Shape(const Value& value, const string& shape_key) { vector shape; for (auto& v : value[shape_key]) { shape.push_back(v.get()); } return shape; } vector ImageNormCfg(const Value& value, const std::string& key) { vector res; for (auto& v : value["img_norm_cfg"][key]) { res.push_back(v.get()); } return res; } } // namespace mmdeploy::test