Commit Graph

25 Commits

Author SHA1 Message Date
Zachary DeVito
e43ff32192
Add a JIT interpreter (#3634)
* Add a JIT interpreter

The separate interpreter is used to graphs with a lower overhead than
converting them to autograd graphs. Some notes:

* does not support Handles/PythonOp/CppOp, these will be in a future commit
* jit_closure.cpp still exists and we fall back to it for now when
  cannot handle something because of PythonOp/CppOp
* In order to support retain_graph=True, the interpreter can be cloned,
  creating a copy that can be run with different arguments. This is
  assumed to be the non-standard case so cloning is not particularly optimized.
  No tensor _data_ is copied, but the at::Tensor list in the interpreter is.
  If we hit problems, there is a lot we could do (such as register allocation)
  to minimize the stuff that needs to be copied.
* Uses a pImpl pattern to keep implementation details out of its header file.
* Modifies the way getTensorOp works so that it reads/writes to already-existing
  vectors, this prevents needing to realloc these buffers each time.
* Timings are here: https://gist.github.com/zdevito/5a20ac29fb1b9e449e693b67dc478127
  This reduces overhead to about the same as running it in python.
  It is about 10us faster to run the same thing using ATen directly.

* Code Mod

Interpreter -> InterpreterState
Function -> Code

Add other requested comments.

* RegList -> ListHandle<T>

Change the RegList functions to be safer by identifying the type of
each argument list, and checking that list insert does not try
to add to two different lists at once.

* Use exactly equal for interp tests
2017-11-13 22:09:53 -08:00
Zachary DeVito
25d3c25f50 add more fusable nodes to the graph compiler (#3559) 2017-11-08 22:58:08 -05:00
gchanan
1d57a2d54c
[ATen][Scalars] Remove Scalar from return types of functions. (#3557)
* Add direct C-type scalar conversions from Tensor, e.g. toCFloat() as an alias for Scalar(x).toFloat()

* Provide tensor overloads for fill_, masked_fill_, index_fill_.

* Everythign up to scalar overload.

* Fix pytorch build for aten scalar return type changes.

* Use valid expression instead of dangling else.

* Simplify code generation.

* Fix test_jit (why didn't this compile locally?)
2017-11-08 11:29:56 -05:00
Sam Gross
afdf50cafe
Move jit/assert.h to csrc/assertions.h (#3442)
I've kept JIT_ASSERT as an alias to TORCH_ASSERT, which we can use throughout the C++ code.
2017-11-02 13:26:51 -04:00
Zachary DeVito
8cc30e4895 Fix the Fusion Pass (#3362)
* update fuser to match ATen-formatted JIT ops

* fix concat optimizations and add test

* allow onnx export to work with single-export functions

* fix onnx handling of multi-return nodes.

* nits, format, vision test update

* fix add constant

* fix driver init issues

* Add missing Neg symbolic.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>
2017-10-31 13:44:13 -04:00
albanD
2d6a880952 Fix jit attributes tests 2017-09-26 10:51:58 -04:00
Zach DeVito
a194e66186 allow Concat operators to be the final operator in a fusion group, and update the fusion compiler to support code that includes final concats 2017-09-20 12:24:27 -04:00
Zach DeVito
ab375e19aa size test 2017-09-19 10:53:32 -04:00
Edward Z. Yang
83e38d687b Add a comment about what is going on here 2017-09-19 10:53:32 -04:00
Zach DeVito
dd85947542 fix the fusion test WAR 2017-09-19 10:53:32 -04:00
Edward Z. Yang
a3ae136c25 Temporarily suppress buggy test case with relaxed test. (#2663)
Proper broadcasting in ATen uncovered a bug in our fusion
compiler where it outputs the wrong shaped tensor.  We're
tracking the issue in https://github.com/ezyang/pytorch/issues/206
but for now, rewrite the code so it does an "old style" comparison,
which works fine.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>
2017-09-07 11:50:17 -04:00
Zach DeVito
a60d9bd022 Bind Attributes in python ir, and add test for python ir binding 2017-09-05 17:48:55 -04:00
Zach DeVito
b606106c4d thread safe interned_strings 2017-09-05 17:48:55 -04:00
Zach DeVito
4a4739e048 remove most node subtypes 2017-09-05 17:48:55 -04:00
Zach DeVito
9f8a35c0b9 remove Primitive nodes. 2017-09-05 17:48:55 -04:00
Zach DeVito
24cdb897d6 starting removing nodes by removing Return 2017-09-05 17:48:55 -04:00
Zach DeVito
b037efa92c prep for removing node subtypes 2017-09-05 17:48:55 -04:00
Zach DeVito
1fa5b19ba4 Attributes object that mirrors Toffee, and interned string table, used by attributes for keys. 2017-09-05 17:48:55 -04:00
Edward Z. Yang
5b6bcf1ce4 Warning squishing.
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
2017-09-05 17:48:55 -04:00
Edward Z. Yang
3016f459d2 Partial lint pass.
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
2017-09-05 17:48:55 -04:00
Zach DeVito
348950dc74 cleanup jit_test 2017-09-05 17:48:55 -04:00
Adam Paszke
233a66dcbe Remove SimpleMap from JIT IR 2017-09-05 17:48:55 -04:00
Zach DeVito
f5e414862a cuda guards for fusion compiler 2017-09-05 17:48:55 -04:00
Edward Z. Yang
ea4aaa6b0b Document TemplateEnv & PR fixes 2017-09-05 17:48:55 -04:00
Zach DeVito
50e51eaa7f Fusion of simple map operations using nvrtc.
Approach is based on the approach of THC's pointwiseApply{1,2,3} family of kernels,
but doesn't have any dependencies on that code.

Adjacent contiguous dimensions of input tensors are compressed to reduce the complexity of indexing math.
For the completely contiguous case, the indexing logic simplifies to just the linear index.

In simple tests, this code matched or beat the equivalent from THC.
2017-09-05 17:48:55 -04:00