Instantly share code, notes, and snippets.

View gist:4fc4f680dbd02c95cb058cb398468d93
import torch
def foo(tensor):
a = torch._dim_arange(tensor, -1)
return a
def foo2(tensor):
dim = tensor.size(-1)
a = torch.arange(0, dim)
return a
View gist:46536b4f1e62a49deb913499a1326b02
Traceback (most recent call last):
File "test/test_jit.py", line 2, in <module>
import torch
File "/Users/jamesreed/onnx-fairseq/pytorch/torch/__init__.py", line 301, in <module>
from . import _torch_docs, _tensor_docs, _storage_docs
File "/Users/jamesreed/onnx-fairseq/pytorch/torch/_tensor_docs.py", line 562, in <module>
""")
File "/Users/jamesreed/onnx-fairseq/pytorch/torch/_tensor_docs.py", line 9, in add_docstr_all
add_docstr(getattr(torch._C._TensorBase, method), docstr)
AttributeError: type object 'torch._C._TensorBase' has no attribute 'contiguous'
View contiguous.patch
diff --git a/aten/src/ATen/Declarations.cwrap b/aten/src/ATen/Declarations.cwrap
index 2ae1d649c..aee44d5a9 100644
--- a/aten/src/ATen/Declarations.cwrap
+++ b/aten/src/ATen/Declarations.cwrap
@@ -149,13 +149,6 @@
- THTensor* self
]]
[[
- name: contiguous
- cname: newContiguous
View gist:bb9fab69f69785239e6a6127638009c5
ERROR: test_async_script (__main__.TestAsync)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test/test_jit.py", line 8425, in test_async_script
y, y_hat = wait_script(x)
File "/Users/jamesreed/onnx-fairseq/pytorch/torch/nn/modules/module.py", line 477, in __call__
result = self.forward(*input, **kwargs)
RuntimeError: n->inBlockList() ASSERT FAILED at ../torch/csrc/jit/ir.h:549, please report a bug to PyTorch. (insertBefore at ../torch/csrc/jit/ir.h:549)
frame #0: torch::jit::Node::moveBefore(torch::jit::Node*) + 45 (0x126357edd in libtorch.dylib)
frame #1: torch::jit::(anonymous namespace)::desugarForkJoin(torch::jit::Block*) + 883 (0x1263535d3 in libtorch.dylib)
View gist:3c4227acdf28bf4841620c2308c2b25b
======================================================================
FAIL: test_alexnet (__main__.TestJit)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test/test_jit.py", line 1361, in test_alexnet
self.assertExpectedGraph(trace)
File "test/test_jit.py", line 266, in assertExpectedGraph
self.assertExpected(str(graph), *args, **kwargs)
File "/Users/jamesreed/onnx-fairseq/pytorch/test/common.py", line 551, in assertExpected
self.assertMultiLineEqual(expected, s)
View examine.diff
hexdump /mnt/homedir/psag/serialize-file-0 > hd0
hexdump /mnt/homedir/psag/serialize-file-1 > hd1
hexdump /mnt/homedir/psag/serialize-file-2 > hd2
git diff hd0 hd1
git diff hd0 hd2
git diff hd1 hd2
hexdump /mnt/homedir/psag/serialize-file-0 | cut -d " " -f 2- > hd0_clean
View gist:cf17b602af9e4edc3052745485063d52
FAILED: bin/converter_nomigraph_test
: && /usr/local/opt/ccache/libexec/g++ -msse4.1 -msse4.2 --std=c++11 -Wno-deprecated -fvisibility-inlines-hidden -Wno-deprecated-declarations -O2 -fPIC -Wno-narrowing -Wall -Wextra -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -Wno-invalid-partial-specialization -Wno-typedef-redefinition -Wno-unknown-warning-option -Wno-unused-private-field -Wno-inconsistent-missing-override -Wno-aligned-allocation-unavailable -Wno-c++14-extensions -Wno-constexpr-not-const -Wno-missing-braces -Qunused-arguments -faligned-new -Wno-unused-private-field -Wno-missing-braces -Wno-c++14-extensions -Wno-constexpr-not-const -DHAVE_AVX_CPU_DEFINITION -DHAVE_AVX2_CPU_DEFINITION -g -fno-omit-frame-pointer -O0
View gist:7aa9ae5c85fcb6647e4261777953c1e3
export CMAKE_PREFIX_PATH="$(dirname $(which conda))/../" # [anaconda root directory]
DEBUG=1 NO_CUDA=1 MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py build && DEBUG=1 NO_CUDA=1 MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py develop
View gist:d519d893af319ec2d6362f4fb684329d
Undefined symbols for architecture x86_64:
"torch::jit::NumberType::get()", referenced from:
caffe2::ATenOp2<caffe2::CPUContext>::convertToIValue(std::__1::shared_ptr<torch::jit::Type>, caffe2::Tensor const&) in aten_op.cc.o
"torch::jit::DynamicType::get()", referenced from:
torch::jit::Value::Value(torch::jit::Node*, unsigned long) in aten_op.cc.o
caffe2::ATenOp2<caffe2::CPUContext>::convertToIValue(std::__1::shared_ptr<torch::jit::Type>, caffe2::Tensor const&) in aten_op.cc.o
"torch::jit::parseSchema(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
caffe2::ATenOp2<caffe2::CPUContext>::ATenOp2(caffe2::OperatorDef const&, caffe2::Workspace*) in aten_op.cc.o
"torch::jit::getOperatorFor(torch::jit::Node const*)", referenced from:
caffe2::ATenOp2<caffe2::CPUContext>::ATenOp2(caffe2::OperatorDef const&, caffe2::Workspace*) in aten_op.cc.o
View gist:d8f2a1503a085e62b2973c138b9e8016
Attributes:
op_kind: "Aten"
node_kind "aten::foo(Tensor a, int b, Tensor[] c) -> Tensor"
class AtenOp {
AtenOp() {
Graph g;
schema_ = SchemaParser(node_kind).parseDeclaration();