{"id":20373518,"url":"https://github.com/megengine/invis","last_synced_at":"2026-02-19T12:02:16.639Z","repository":{"id":103459535,"uuid":"509397605","full_name":"MegEngine/invis","owner":"MegEngine","description":"invisible megengine API","archived":false,"fork":false,"pushed_at":"2022-08-08T04:14:08.000Z","size":142,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-26T19:38:26.343Z","etag":null,"topics":["deep-learning","megengine","python","pytorch"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MegEngine.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-07-01T09:33:35.000Z","updated_at":"2023-03-02T02:01:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"ebb16954-eb8b-461d-b50f-071f5e99b947","html_url":"https://github.com/MegEngine/invis","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MegEngine/invis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MegEngine%2Finvis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MegEngine%2Finvis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MegEngine%2Finvis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MegEngine%2Finvis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MegEngine","download_url":"https://codeload.github.com/MegEngine/invis/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MegEngine%2Finvis/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29612509,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T10:52:55.328Z","status":"ssl_error","status_checked_at":"2026-02-19T10:52:26.323Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deep-learning","megengine","python","pytorch"],"created_at":"2024-11-15T01:18:49.704Z","updated_at":"2026-02-19T12:02:16.614Z","avatar_url":"https://github.com/MegEngine.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n### Invisible MegEngine\n\nGoal: bridging the gap between megengine and torch.\n\n只需要把所有torch相关的code转换成invis就行了\n\n比如：\n\n```python\nimport invis as torch\nimport invis.nn.functional as F\n```\n\nEnjoy!\n\n#### Installation\n\n```shell\ngit clone git@github.com:MegEngine/invis.git\ncd invis\n```\n\n个人建议使用[venv](https://docs.python.org/3/library/venv.html)，如果不想用，可以跳过这一步\n\n```shell\npython3 -m venv invis_venv ~/invis_venv\nsource ~/invis_venv/bin/activate\n```\n\n使用pip进行安装\n\n```shell\npip3 install -r requirements.txt\npip3 install -v -e .\n```\n\n#### Features\n\n* invis.nn.Moudle不会把builtin 的 dict 和 list 看做ModuleDict和 ModuleList了，你可以放心的往Module里塞入Tenor和Module而不用担心state_dict里面多出来一些奇怪的东西了\n* 每个Module终于可以自定义load_state_dict的逻辑了\n* 诸如 x.abs().sigmoid() 终于可以用了，抛弃掉诸如F.sigmoid(F.abs(x))的调用吧\n* 增加了一些方法，诸如meshgrid、where、pixel_shuffle等\n* 修复mge里面一些支持不全的功能，比如pad(x, (-2, -2, -2, -2))这种\n\n#### Examples\n\n作为对invis的磨练，我转换了一些基本的模型。\n\n* 大部分模型来自于直接对torchvision的转换，使用的版本为0.12.0\n* 检测部分写了YOLOX是因为相对来说YOLOX的写法还是有一部分的复杂性的(而且自己也很熟)\n* realcu-gan纯粹是个人兴趣所在(谁不想看到高清的老番呢)\n\n##### 分类模型\n\n* [alexnet](./examples/alexnet)\n* [densenet](./examples/densenet)\n* [googlenet](./examples/googlenet)\n* [inception](./examples/inception)\n* [resnet](./examples/resnet)\n* [shufflenet](./examples/shufflenet)\n* [squeezenet](./examples/squeezenet)\n* [SwinTransformer](./examples/swin_transformer)\n\n##### 检测模型\n\n* [YOLOX](./examples/yolox)\n\n##### 分割网络\n\n* [FCN](./examples/fcn)\n\n##### GAN\n\n* [realcu-GAN](./examples/realcu-gan)\n\n#### Why invis ?\n\ninvis的初衷还是为了减少复杂度(complexity)，准确来说是R可控的复杂度。我已经厌倦了告诉别人：\n* mge BatchNorm的momentum和torch的不一样，如果torch的是0.9，那么mge的是0.1\n* 转权重的时候，group conv 和 torch 也是不一样的，bias也不一样。\n* Linear的初始化也不太一样，之前我们复现DETR也因为这个差了一些点。\n\n现在，我只需要告诉他，这个坑在invis里面有，你可以去看一下。\n\n除此之外，还有一些其他可能的使用场景：\n\n* 对inference结果\n* 将torch代码尽量快地转成trace module\n* 需要一个torch训练好的backbone来做预训练，但是懒得转weight\n\n**invis的用户有多少，并不取决于我的算子包的多好，而是用户将代码从torch切到megengine之后，能享受到什么好处。**\n\n#### Contribution\n\ninvis仅仅在一个小范围内进行了打磨，而且一些corner case未必支持地完全，任何MR/PR和issue都是欢迎的。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmegengine%2Finvis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmegengine%2Finvis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmegengine%2Finvis/lists"}