Commit Graph

4 Commits

Author SHA1 Message Date
cyy
1a73255102 Concat namespaces in jit code (#138976)
Fixes #ISSUE_NUMBER

Pull Request resolved: https://github.com/pytorch/pytorch/pull/138976
Approved by: https://github.com/Skylion007
2024-10-26 17:41:27 +00:00
Mikhail Zolotukhin
4503c45553 Remove registration of NNC backend. (#81160)
It looks like we sometimes try to register the backend more than once. Since
it's not actually used now, let's simply disable it.

@bypass-github-export-checks

Differential Revision: [D37734986](https://our.internmc.facebook.com/intern/diff/D37734986/)

**NOTE FOR REVIEWERS**: This PR has internal Facebook specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D37734986/)!

Differential Revision: [D37734986](https://our.internmc.facebook.com/intern/diff/D37734986)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/81160
Approved by: https://github.com/suo
2022-07-11 04:01:02 +00:00
Jiakai Liu
5824a866b7 [pytorch][nnc] support custom class parameters (#59466)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/59466

Change saved parameter type from at::Tensor to at::IValue to support custom
class parameters, e.g. `__torch__.torch.classes.xnnpack.Conv2dOpContext`.

The NNC produced kernels won't deal with custom class parameters directly.
They simply pass through to the external operators that take these custom
class parameters, e.g. `prepacked::conv2d_clamp_run`.

It will reuse the `__getstate__` and `__setstate__` methods on the custom class
to persist and restore the state of the parameters.

When calling into the kernel, it will pass in the untyped raw pointer of the custom
class objects to the kernel as `void*`. It's similar to the regular tensor parameters,
for which it will pass in the raw data pointer of the tensor storage. The generated
kernel needs to hardcode the expected type for each parameter and cast before
calling the external ops.
ghstack-source-id: 131897904

Test Plan: - unit tests

Reviewed By: kimishpatel

Differential Revision: D28902496

fbshipit-source-id: 4b2c0895dd28f0b7d344aa08183d42ad6a355dae
2021-06-19 06:11:01 -07:00
Jiakai Liu
b4a098f1fb [pytorch][nnc] mobile nnc backend skeleton (#56852)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/56852

This is part of the changes to enable NNC AOT compilation for mobile.
It introduced a custom backend for NNC, which uses the components defined in the stacked PRs to load and execute a NNC-compiled model.
ghstack-source-id: 128285801

Test Plan:
- On X86 host:
```
buck build //xplat/caffe2/fb/lite_predictor:lite_predictor_nnc
buck-out/last/lite_predictor_nnc --model xplat/pytorch_models/build/pytorch_dev_linear/v1/nnc/compiled.pt --print_output true --input_dims '4,4' --input_type float
```
- On Android:
```
buck build fbsource//fbandroid/mode/gnustl //xplat/caffe2/fb/lite_predictor:lite_predictor_nncAndroid#android-armv7
adb push buck-out/last/lite_predictor_nncAndroid#android-armv7 /data/local/tmp
adb push xplat/pytorch_models/build/pytorch_dev_linear/v1/nnc/compiled.pt /data/local/tmp
adb shell 'cd /data/local/tmp; ./lite_predictor_nncAndroid\#android-armv7 --model compiled.pt --print_output true --input_dims "4,4" --input_type float'
```

Reviewed By: kimishpatel, raziel

Differential Revision: D27897153

fbshipit-source-id: 8e039089d1602782582747adfd75b31496b525ca
2021-05-06 03:25:18 -07:00