| 12 | |
| 13 | using namespace MNN; |
| 14 | int main(int argc, const char* argv[]) { |
| 15 | if (argc < 3) { |
| 16 | MNN_ERROR("Usage: ./fuseTest XXX.spirv XXX.json\n"); |
| 17 | return 0; |
| 18 | } |
| 19 | { |
| 20 | ScheduleConfig config; |
| 21 | std::vector<ScheduleConfig> configs = {config}; |
| 22 | auto rt = Interpreter::createRuntime(configs); |
| 23 | } |
| 24 | rapidjson::Document configJson; |
| 25 | std::ifstream fileNames(argv[2]); |
| 26 | if (fileNames.fail()) { |
| 27 | MNN_ERROR("Can' open config file: %s\n", argv[2]); |
| 28 | return 0; |
| 29 | } |
| 30 | { |
| 31 | std::ostringstream output; |
| 32 | output << fileNames.rdbuf(); |
| 33 | auto outputStr = output.str(); |
| 34 | configJson.Parse(outputStr.c_str()); |
| 35 | } |
| 36 | if (configJson.HasParseError()) { |
| 37 | MNN_ERROR("Invalid json\n"); |
| 38 | return 0; |
| 39 | } |
| 40 | |
| 41 | auto type = MNN_FORWARD_VULKAN; |
| 42 | auto creator = MNNGetExtraRuntimeCreator(type); |
| 43 | if (nullptr == creator) { |
| 44 | MNN_ERROR("Don't support %d\n", type); |
| 45 | return 0;; |
| 46 | } |
| 47 | MNN::Backend::Info info; |
| 48 | info.type = type; |
| 49 | BackendConfig user; |
| 50 | user.precision = BackendConfig::Precision_High; |
| 51 | info.user = &user; |
| 52 | std::shared_ptr<Runtime> runtime(creator->onCreate(info)); |
| 53 | std::shared_ptr<Backend> bn(runtime->onCreate(&user)); |
| 54 | |
| 55 | // Load Config |
| 56 | std::unique_ptr<MNN::OpT> op(new OpT); |
| 57 | op->type = OpType_Extra; |
| 58 | op->main.type = OpParameter_Extra; |
| 59 | op->main.value = new ExtraT; |
| 60 | std::vector<std::shared_ptr<MNN::Tensor>> inputs; |
| 61 | std::vector<std::shared_ptr<MNN::Tensor>> outputs; |
| 62 | if (configJson.HasMember("inputs")) { |
| 63 | auto inputArray = configJson["inputs"].GetArray(); |
| 64 | int pos = 0; |
| 65 | for (auto iter = inputArray.Begin(); iter != inputArray.End(); iter++) { |
| 66 | std::unique_ptr<AttributeT> attr(new AttributeT); |
| 67 | attr->key = "input"; |
| 68 | attr->list.reset(new ListValueT); |
| 69 | attr->i = (*iter)["binding"].GetInt(); |
| 70 | attr->list->i = {0, pos}; |
| 71 | attr->b = false; |
nothing calls this directly
no test coverage detected