GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Techainer/torch-js: Node.js binding for PyTorch.

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

136 Commits
136 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
.vscode
.vscode
 
 
dist
dist
 
 
examples
examples
 
 
lib
lib
 
 
src
src
 
 
tests
tests
 
 
.dockerignore
.dockerignore
 
 
.editorconfig
.editorconfig
 
 
.eslintignore
.eslintignore
 
 
.eslintrc
.eslintrc
 
 
.gitignore
.gitignore
 
 
.npmignore
.npmignore
 
 
.prettierignore
.prettierignore
 
 
.prettierrc.json
.prettierrc.json
 
 
CMakeLists.txt
CMakeLists.txt
 
 
Dockerfile
Dockerfile
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
babel.config.js
babel.config.js
 
 
build.js
build.js
 
 
package.json
package.json
 
 
tsconfig.json
tsconfig.json
 
 
yarn.lock
yarn.lock
 
 

Repository files navigation

TorchJS

npm version CI publish-prebuild

TorchJS is a JS binding for PyTorch. Its primary objective is to allow running TorchScript inside Node.js program. Complete binding of libtorch is possible but is out-of-scope at the moment.

This fork is maintained by Techainer

Changes after fork

  • Add support for List (Javascript Array), Dict (Javascript Object), String, float (Javascript number) as inputs and outputs.

  • Add CUDA support.

  • Add ops from torchvision.

  • Add async support for forward function.

  • Add async support for call_scripted_function(function_name, **inputs) to call any method of the scripted module.

  • Provide prebuild binary for cross NVIDIA GPU from Pascal to Ampere

  • Fixed some weird conversion arround List[Tensor] input.

  • Updated libtorch to 1.8.1 and torchvision to 0.9.1

Install

To install the forked version, you can install it from npm:

yarn add torch-js@npm:@techainer1t/torch-js

Example

In tests/resources/torch_module.py, you will find the defination of our test module and the code to generate the trace file.

class TestModule(torch.nn.Module):
    def __init__(self):
        super(TestModule, self).__init__()

    def forward(self, input1, input2):
        return input1 + input2

Once you have the trace file, it may be loaded into NodeJS like this

const torch = require("torch-js");
const modelPath = `test_model.pt`;
const model = new torch.ScriptModule(testModelPath);
const inputA = torch.rand([1, 5]);
const inputB = torch.rand([1, 5]);
const res = await model.forward(inputA, inputB);

More examples regarding tensor creation, ScriptModule operations, and loading models can be found in our examples folder.

About

Node.js binding for PyTorch.

www.npmjs.com/package/@techainer1t/torch-js

Topics

horuslibtorchnodejspytorch

Resources

Readme
MIT license
Activity
Custom properties

Stars

18 stars

Watchers

1 watching

Forks

1 fork
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.