From 765a41b274e677f00a4fb82e733fc45629b6842d Mon Sep 17 00:00:00 2001 From: yalue Date: Thu, 14 Nov 2024 08:21:57 -0500 Subject: [PATCH] Remove more training API stuff - Removed testing data that was used only with onnxruntime_training_test.go, which was already removed. - Renamed legacy_types.go to legacy_code.go, since it's now a parking ground for legacy code that's not just "types". - Fixed some references to the training API in CONTRIBUTING.md. --- CONTRIBUTING.md | 7 +-- legacy_types.go => legacy_code.go | 5 +- onnxruntime_go.go | 3 +- test_data/generate_training_assets.py | 55 ------------------ test_data/training_test/checkpoint | Bin 464 -> 0 bytes test_data/training_test/eval_model.onnx | Bin 1673 -> 0 bytes test_data/training_test/optimizer_model.onnx | Bin 538 -> 0 bytes test_data/training_test/training_model.onnx | Bin 6525 -> 0 bytes test_data/training_test/training_network.onnx | Bin 1111 -> 0 bytes 9 files changed, 6 insertions(+), 64 deletions(-) rename legacy_types.go => legacy_code.go (98%) delete mode 100644 test_data/generate_training_assets.py delete mode 100644 test_data/training_test/checkpoint delete mode 100644 test_data/training_test/eval_model.onnx delete mode 100644 test_data/training_test/optimizer_model.onnx delete mode 100644 test_data/training_test/training_model.onnx delete mode 100644 test_data/training_test/training_network.onnx diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 422d755..fae78a9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -41,8 +41,7 @@ Tests ----- - All new features and bugfixes must include a basic unit test (in - `onnxruntime_test.go` or `onnxruntime_training_test.go`) to serve as a - sanity check. + `onnxruntime_test.go`) to serve as a sanity check. - If a test is for a platform-dependent or execution-provider-dependent feature, the test must be skipped if run on an unsupported system. @@ -62,8 +61,8 @@ Adding New Files - Apart from testing data, try not to add new source files. - - Do not add third-party code or headers. The only exceptions for now are - `onnxruntime_c_api.h` and `onnxruntime_training_c_api.h`. + - Do not add third-party code or headers. The only exception for now is + `onnxruntime_c_api.h`. - No C++ at all. Developing Go-to-C wrappers is annoying enough as it is. diff --git a/legacy_types.go b/legacy_code.go similarity index 98% rename from legacy_types.go rename to legacy_code.go index 5408647..b3462ef 100644 --- a/legacy_types.go +++ b/legacy_code.go @@ -1,8 +1,7 @@ package onnxruntime_go -// This file contains Session types that we maintain for compatibility -// purposes; the main onnxruntime_go.go file is dedicated to AdvancedSession -// now. +// This file contains code and types that we maintain for compatibility +// purposes, but is not expected to be regularly maintained or udpated. import ( "fmt" diff --git a/onnxruntime_go.go b/onnxruntime_go.go index b5ed546..2ebddee 100644 --- a/onnxruntime_go.go +++ b/onnxruntime_go.go @@ -882,8 +882,7 @@ func (t *CustomDataTensor) GetData() []byte { // Scalar is like a tensor but the underlying go slice is of length 1 and it // has no dimension. It was introduced for use with the training API, but -// remains supported since it conceivable will have use outside of the training -// API. +// remains supported since it may be useful apart from the training API. type Scalar[T TensorData] struct { data []T dataSize uintptr diff --git a/test_data/generate_training_assets.py b/test_data/generate_training_assets.py deleted file mode 100644 index 5e623d8..0000000 --- a/test_data/generate_training_assets.py +++ /dev/null @@ -1,55 +0,0 @@ -import torch -from torch.nn.functional import relu -from pathlib import Path -import onnx -import onnxruntime.training.artifacts as artifacts - -class SumAndDiffModel(torch.nn.Module): - """ Just a standard, fairly minimal, pytorch model for generating the NN. - """ - def __init__(self): - super().__init__() - # We'll do four 1x4 convolutions to make the network more interesting. - self.conv = torch.nn.Conv1d(1, 4, 4) - # We'll follow the conv with a FC layer to produce the outputs. The - # input to the FC layer are the 4 conv outputs concatenated with the - # original input. - self.fc = torch.nn.Linear(8, 2) - - def forward(self, data): - batch_size = data.shape[0] - conv_out = relu(self.conv(data)) - conv_flattened = torch.flatten(conv_out, start_dim=1) - data_flattened = torch.flatten(data, start_dim=1) - combined = torch.cat((conv_flattened, data_flattened), dim=1) - output = relu(self.fc(combined)) - output = output.view(batch_size, 1, 2) - return output - -def main(): - model = SumAndDiffModel() - - # Export the model to ONNX. - training_artifacts_path = Path(".", "training_test") - training_artifacts_path.mkdir(exist_ok=True, parents=True) - model_name = "training_network" - torch.onnx.export(model, torch.zeros(10, 1, 4), - Path(".", "training_test", f"{model_name}.onnx").__str__(), - input_names=["input"], output_names=["output"]) - - # Load the onnx model and generate artifacts - onnx_model = onnx.load(Path("training_test", "training_network.onnx")) - requires_grad = ["conv.weight", "conv.bias", "fc.weight", "fc.bias"] - model.train() - - # Generate the training artifacts. - artifacts.generate_artifacts( - onnx_model, - requires_grad=requires_grad, - frozen_params=[], - loss=artifacts.LossType.L1Loss, - optimizer=artifacts.OptimType.AdamW, - artifact_directory=Path(".", "training_test")) - -if __name__ == "__main__": - main() \ No newline at end of file diff --git a/test_data/training_test/checkpoint b/test_data/training_test/checkpoint deleted file mode 100644 index a44f236501fcbb146ba47f7d85915dc910bd0a09..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 464 zcmd;KU|{ff32_Ee3}62L|1SWfnShvsfd`0LfEdJvU?2q)VPKG8WMDV~q#dAqHmE+J zFoOsX%K$M*&(()}_uf}!wgriU%me{;AWloxOUg_vX0Suj=K~Z^0AdFqp8jf`-B!s+ zJELH>8(EwS5j`_8^Iae@0z zNXOZM+z;|M2!PB;&d)1@_<#@SUyu$+Sn&Z_ARb6P$UiAS>;S}D0;laOXkNL`LRMnm zx?}D8mOR+JZ-EV?-2(3Swkryp_buq0Vasshob8^4-}ddebii(bzsSD6x9|4tIO@Bv a=8X0}W}q1``$1-d0F2KKWP{xU^%Ved9Bz&P diff --git a/test_data/training_test/eval_model.onnx b/test_data/training_test/eval_model.onnx deleted file mode 100644 index 7d1cb1b24c8a40fb32e7a52825740ccef176de7a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1673 zcma)6%Wl&^6pbAxp4_G-ovNY=2!SaJylChHge(D}l|Vvb(+UY?6OEl|;xw@>Kl)(B zcd+Uw@(JAWBa_4i5y_dEd+z(58A7NY+{J$AOuCJugX4ok>vtP|DbR4eAcFcj7Q4O|^_6=?H`~w{hkg?5 z;Yl@jpnb(dkI#nDgay2>36)LI0yc{JwSG+;w?L2L&>iv20~|qBaJtny=d(m6(@4*T zCZuo%YcSpJeZstA?nw($hzvc)%ni`ktsAAu!uz}_SbSl7D6K&X|6>0g%0aP~vM<^Z zjdfToz3aKeXlBT2W_M7sfYzl`%uUB_I<@WIrPKS&=X2?p6e2?tfcXF#Y!*z|Zmst7 z!@Z(l`!$=#^1KPnIAmUQnlW-dE@_BrtR1_4&%v&n5wU8O4Kur@G z*KC$>^9iYU^e=l*%YI6}s`+}aXmEjjSc?o5foLD#!{?k847RM--8|lTihV`QvfdaVk2qd(#d$Dt=TTZ6g*kJ* z;W%W$WbmjUIE4;TXd6@l_$l~lgU5^V%cwedw(?R?siG|$JY0T100>49poU>3SLqhC z5g-Vt_>sXbEZ8e;RC^!((FWQC4V~1cFRPylnVl#v&2YM3dLgQ`o>yGqrIb^5(-+m3 zT2_{+8Rbj6=88;3ywdGjb)-&(qczsAIZ~%jEAN5msGd%tE_zi#>!nE+R8XbrDlu0Z QCRn3lTmNHDr)p>W4~}}Y)&Kwi diff --git a/test_data/training_test/optimizer_model.onnx b/test_data/training_test/optimizer_model.onnx deleted file mode 100644 index 4ff2d97508c6a0089d84395616b2730c0d560a35..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 538 zcmaKoO-=$a6o4rXFgyXFIBH~}VJ8cA2Gfm^3%E34Gbz)~&}61<+8WS}J1^mei|CcS zg2Rj&j)<0jB|zxDP%&vkKm&U?UYlqi9q2E1H({o-0-jnPDarOJ9w;eSgiuDa<@i~%d@c*)lqQ5sF3-#4L!Nwk)J|mL zl^a6thMj#h>OylfA^(f<3$#Yn(FxROsuwhfxZJ^42fgkTT*G0<+sX4A_|JE-ShHMg+JpTI LyJ+e`rQ7=f7uJ~l diff --git a/test_data/training_test/training_model.onnx b/test_data/training_test/training_model.onnx deleted file mode 100644 index 66e5e28fb72beddc7afc89f6ac91e9c14c3a0f4a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6525 zcmcgxUvJw~6pz!ianIT=bz9nb8|%CwSP)5@b_hjcv>9U>(f~CRLPf%I95->6*p}_I z-Gs)UCnP=sLK+ehZ%BLrBwl#pLvilCwqsx0Y1jjkHaqtopYuECo^$T+-ie}AcAojR ztM}#kMs2UQ+x&AE{t#f^w4AXImvq}Yt(_TWukXVm{n0TsPg<*!_xgSON43X3imE#@ zOa_$_nW`>B$zAOha!Q;qqhMI1S49l-8E9~t$ z5f{*q<+WH=g+CAJa$#PUI)<-p6bj#d@KO+}mtkHTI{jz>_Azw44U7^^t=J-zgOMP; z+K8VM0g1#5GsTJpcY*njppOh%2ueA4A?dFThxXZX!?h_^cn<<`^hk4ihA*wzmUZ52 zdgD&uf3vwOFR{V)xYKMllsSCD`;a9Wey(-A=<~hs^TUqUZ0;*__=HjTc|ua!W`>T8 z?pQY-8=BQ@zRQZIZ9X@;>KF2jsS;R1B_he!%!_PuH}jQ|f+Y5)Afh$9KU2+q4FPVK zdNxAOqWIiZd)OVMTlrY1>!gKT98ya%{{DunRe((UQEx-^HTttHW-?%`UJm+C5jM@PE$nMI471I>4rp9Po+0$iMN z(iZb2Q5ZBu=GG9jxcHDfhS4npe3Ux`Q4ef|GhwMrj@662I;lb z4l{v46;MV(kdhbTb@LElBoOn3G-`ytWsP=T8X#_v$vjfo-z{b?;HUk1Tn=hB7$Kntia?aHicy8gWr&&@PVso zx;`F_*^#)`8K0aOE~LT>mxtQ(XV|bk!)NinIb9JZsk~0YZQ`za7@Dx%U1j}|^%*(Z z#Rflb@ZtDH0EHTe7Bmwlx9DkN4c!`PS|W3ppsV@%3qU`z@mmE>XEn++r3{iuF= z6cf8#8sGJN1$pT9XF?~z2oLlmot%EPA?X%DIQ->XD$J;NW&y_Zo`ybDlI?><5uX@;o`nVt%hpf zfs0xUFFq|4SWgM@w_$qm#f1lN<kh^O diff --git a/test_data/training_test/training_network.onnx b/test_data/training_test/training_network.onnx deleted file mode 100644 index 614d9e9a381b2e8785c17d8e904fcf4c962123ae..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1111 zcmZ`&PiWIn7;mz4dHwdsESs!$Di}~PLc2c-B5f=kC=`awp-z#Ntj*eBmV_kToQMb> zoEJ}`;wgh6>R}fr?BJdrRCX91gq;+02M-GBO++ugw27JP47|Me{l548`+eU-h-b|i z$FPc(M6^FSknB5(5!|OBs_JIdftI47PbH@nwOnx^Rujfm+2%V_-Z?c$eg&iIkgJ8> z1cac#cq);DSV`4nM>TXiOSu#)wnDUQ8C5e*BwFl*){BazD_X&>$flBIyen-Fm`t=L3yg=tAZ$|e9jW6aFGtZs3lu;C>+8f8 zVB|}xT}u`upA=GjVA~g3LkRxIeiRyml3E&l@tj9&QFcP_td9uIbcQB0jsCMQG3D1ZdUQ;6FjDr;s%-X4iuJLXapp`RI7oKS9qX2+6sJ69*= z5GiW2Q<8tJ7aQ1NeZ=p_X`c5AvK?99P-N^cCZIqoiV&TWwW=cSMok=>k3*#XQT|T* zyGt=JLU`B|8MX+-H`hltfynLJ;0dgM@FrH)G-LX*Vi|EVe>4x1vZ@!#mTXqUvxq?y zVmK`1O-XLc_sm0c5W6?;Wg;tYGSB9I;H9@O zB==+&zV-DRUV1fzudE)#;+~q*@PXyIY?~u3zI%^X$A&iS&&PoGwbo%y%tN1r} zSlV~yS4QkcG;tXWNFJ@NFE4-C+mt!q6AU{K9HRJEpb?Nok;RPf1fM~^QA_7&uHz48 Ca#hm+