-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify loading lua classes: add `PyTorchHelpers.load_lua_class(lua_…
…filename, lua_classname)`
- Loading branch information
1 parent
dd5dd61
commit 96b1bae
Showing
3 changed files
with
20 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,7 +139,7 @@ def get_file_datetime(filepath): | |
|
||
setup( | ||
name='PyTorch', | ||
version='2.5.0', | ||
version='2.6.0', | ||
author='Hugh Perkins', | ||
author_email='[email protected]', | ||
description=( | ||
|
@@ -152,7 +152,7 @@ def get_file_datetime(filepath): | |
install_requires=['numpy'], | ||
scripts=[], | ||
ext_modules=ext_modules, | ||
py_modules=['floattensor', 'PyTorchAug'], | ||
py_modules=['floattensor', 'PyTorchAug', 'PyTorchHelpers'], | ||
package_dir={'': 'src'} | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import PyTorch | ||
import PyTorchAug | ||
|
||
def load_lua_class(lua_filename, lua_classname): | ||
module = lua_filename.replace('.lua', '') | ||
PyTorch.require(module) | ||
class LuaWrapper(PyTorchAug.LuaClass): | ||
def __init__(self, _fromLua=False): | ||
self.luaclass = lua_classname | ||
if not _fromLua: | ||
name = lua_classname | ||
super(self.__class__, self).__init__([name]) | ||
else: | ||
self.__dict__['__objectId'] = getNextObjectId() | ||
return LuaWrapper | ||
|