Including collections abstract base classes
classDiagram
AbstractSet <-- FrozenSet
AbstractSet <-- KeysView
AbstractSet <-- MutableSet
MutableSet <-- Set
def solve_Ax_eq_zero(A): | |
_, _, vh = np.linalg.svd(A) | |
x = vh.T[:, -1] | |
return x |
# mypy: disable-error-code="misc,arg-type,type-arg,valid-type,assignment,return-value" |
In [3]: def foo(*a): print(a) | |
In [4]: class Test: | |
...: func = foo | |
...: def bar(self): | |
...: self.func(42) | |
...: | |
In [5]: Test().bar() | |
(<__main__.Test object at 0x106751ab0>, 42) |
Allow imports at the module toplevel only, unless (1) it is too expensive to load the module or (2) module may not be available.
# https://github.com/pytorch/pytorch/pull/106984/files | |
retry () { | |
"$@" || (sleep 10 && "$@") || (sleep 20 && "$@") || (sleep 40 && "$@") | |
} |
import torch | |
from torch import nn | |
import onnx | |
class LlamaMSRotaryEmbedding(nn.Module): | |
def __init__(self, hidden_size, num_heads, max_sequence_length): | |
super().__init__() | |
self.hidden_size = hidden_size |
import torch | |
import onnx | |
class Model(torch.nn.Module): | |
def forward(self, x): | |
return torch.nn.functional.hardsigmoid(x) | |
exported = torch.onnx.dynamo_export(Model(), torch.randn(1, 3, 224, 224)) | |
print(onnx.printer.to_text(exported.model_proto)) |
# onnxscript/tests/function_libs/torch_lib/dynamo_export_test.py | |
import copy | |
import inspect | |
import itertools | |
import sys | |
import unittest | |
import torch | |
from torch.onnx import ExportOptions |
# https://aiinfra.visualstudio.com/PublicPackages/_artifacts/feed/ORT-Nightly/PyPI/ort-nightly/overview | |
--index-url=https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/ORT-Nightly/pypi/simple/ | |
ort-nightly==1.17.0.dev20240118001 |