Commit Graph

13 Commits

Author SHA1 Message Date
Kimish Patel
820410b505 Added upsample_neartest2d op for lite interpreter. (#32913)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/32913

This enables mobile detection and tracking models.

Test Plan: buck test caffe2/test/cpp/jit:jit -- JitTest.LiteInterpreterUpsampleNearest2d

Reviewed By: iseeyuan

Differential Revision: D19664502

fbshipit-source-id: 1c7270dcf394aba7b510c5aa80552c58a5038f24
2020-02-04 07:59:03 -08:00
Martin Yuan
f362cd510d Move prim ops from JIT registration to C10 (#30612)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/30612

The first version to move prim ops to c10 registration. After the reviewers are fine with the initial changes, more operators will be moved in the same style.

Test Plan: Imported from OSS

Differential Revision: D19237648

Pulled By: iseeyuan

fbshipit-source-id: c5a519604efffb80564a556536f17d829f71d9f9
2020-01-04 13:47:44 -08:00
Martin Yuan
c272758b43 Mobile module forward() pass input by value. (#30060)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/30060

Mobile forward() passed inputs by reference, which is different from JIT's script::module. To make it consistent, change it pass by value.

Test Plan: Imported from OSS

Differential Revision: D18587786

Pulled By: iseeyuan

fbshipit-source-id: fa398124fd0a5168f708733ff88f0ba327726f43
2019-11-18 22:33:38 -08:00
Martin Yuan
6980cb2519 Add overload name to JIT prim operators, version 2 (#29960)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/29960

Overload name is required in mobile operators with the same name but different schema. Since it's not used in JIT, it's safe to add overload names for JIT operators.

Test Plan: Imported from OSS

Differential Revision: D18555484

fbshipit-source-id: b451379af24e255d8b0c61b964ae32fd1a64ed34
2019-11-16 23:59:07 -08:00
Zachary DeVito
a5b4d78c6d Revert D18499600: Add overload name to JIT prim operators.
Test Plan: revert-hammer

Differential Revision:
D18499600

Original commit changeset: a1b49e64c908

fbshipit-source-id: 73e27b72f53799c0133850d2352ae8cd8a82d87c
2019-11-15 18:36:17 -08:00
Martin Yuan
ff4e782e79 Add overload name to JIT prim operators.
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/29656

Test Plan: Imported from OSS

Differential Revision: D18499600

fbshipit-source-id: a1b49e64c908d16d40a6ddb048182d7bbe80bcd6
2019-11-15 16:22:47 -08:00
Martin Yuan
3003c5f91b OPN ops TupleConstruct/Unpack and format. (#29635)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/29635

TupleConstruct/Unpack as OPN ops.

Test Plan: Imported from OSS

Differential Revision: D18499602

fbshipit-source-id: 389b21d3ea532ef6fa729d67ce34214d86700cd2
2019-11-15 16:22:42 -08:00
Martin Yuan
a4b872b65e Inline graph before writing the bytecode file. (#29421)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/29421

Inline graph before writing the bytecode file, so that all the instructions are emitted from the top-level methods.

Test Plan: Imported from OSS

Differential Revision: D18404180

fbshipit-source-id: 4759474a8dba3813616ebce8253bea09941f6bbb
2019-11-08 13:23:32 -08:00
Martin Yuan
977445b635 Disable TSAN test for LiteInterpreterConv (#27748)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/27748

There's TSAN test failure. From stack it's likely related to mkldnn (https://github.com/pytorch/pytorch/issues/27497). Before the issue is resolved, disable TSAN test.
ghstack-source-id: 91761706

Test Plan: buck test mode/dev-tsan caffe2/test/cpp/jit:jit -- 'JitTest\.LiteInterpreterConv' --run-disabled

Reviewed By: bddppq

Differential Revision: D17880082

fbshipit-source-id: 251d9b9577838146231c8e122f755936edd1c281
2019-10-11 14:05:33 -07:00
Edward Yang
2488c29129 Revert D17846079: [TSAN unittest] Disable TSAN test in LiteInterpreterConv
Test Plan: revert-hammer

Differential Revision:
D17846079

Original commit changeset: 669d63856902

fbshipit-source-id: 996d64f12efab52d571fc81a7c602d7f18da7255
2019-10-10 16:29:16 -07:00
Martin Yuan
829a5c8584 Disable TSAN test in LiteInterpreterConv
Summary: There's TSAN test failure. From stack it's likely related to mkldnn (https://github.com/pytorch/pytorch/issues/27497). Before the issue is resolved, disable TSAN test.

Test Plan: buck test mode/dev-tsan caffe2/test/cpp/jit:jit -- 'JitTest\.LiteInterpreterConv' --run-disabled

Reviewed By: bddppq

Differential Revision: D17846079

fbshipit-source-id: 669d6385690223d83996fb14051c39df0c521dfa
2019-10-10 08:50:59 -07:00
Martin Yuan
19ab5381c3 Add OPN instruction and vararg operator table (#27104)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/27104

* The use case here is to replace prim::ListConstruct, which requires Node, but Node is not available in mobile lite interpreter.
* (OPN, X, N), X is the index to the vararg operator-name and operator tables. N is number of inputs. For ListConstruct example, operator name can be "aten::listconstruct" and the overloaded name is the output type ("int", "float", "bool", "tensor" and "generic").
* A vararg operator table is built with void(int input_size, Stack& stack) functions.
## Unit test
LiteInterpreterConv covers OPN instruction and conv operator.

Test Plan: Imported from OSS

Differential Revision: D17762853

fbshipit-source-id: 475aa0c6678e3760cec805862a78510913a89c83
2019-10-04 09:35:53 -07:00
Martin Yuan
7fc06ea541 Bytecode export flow (#25187)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/25187

The bytecode export flow: dump the bytecode format for the light weighted interpreter.
* The bytecode is generated without input spec optimization. It would be more generic (input independent) with no obvious performance degradation (to be tested).
* Main API: torch::jit::script::Module::save(filename, extra_files, bool *bytecode_format* = false).
* Both bytecode and module object are exported in pickle format.
    * The module object (in data.pkl) is the same as the original JIT model.
    * The serializer is dependent on pickle only (no protobuf or Json).
    * The major functionality is forked in ScriptModuleSerializer2::serialize().
    * The test loader is test_bc_export.cpp.
* Simple APIs are added in Code and its implementation to get necessary information (instructions, operators and constants).
* Since there's no dependency on graph/node, GetAttr is promoted from an operator to first-class instruction (https://github.com/pytorch/pytorch/pull/25151) .
* Some definitions (instructions, writeArchive, etc) that are shared by full JIT and bytecode are pulled out of the local namespace (https://github.com/pytorch/pytorch/pull/25148).

The output layout looks like:

* folders of methods.
    * In each method folder (for example, forward/):
        * bytecode.pkl: instructions and operators
        * constants{.pkl,/}: constant list in constants.pkl. If there are tensors in constants, the binary tensor files in constants/ folder.
* data{.pkl,/}: the module object, with binary tensor files in data/ folder. The same as in torchscript.

Test Plan: Imported from OSS

Differential Revision: D17076411

fbshipit-source-id: 46eb298e7320d1e585b0101effc0fcfd09219046
2019-09-25 16:35:45 -07:00