Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

onnxruntime-common

Package Overview
Dependencies
Maintainers
0
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

onnxruntime-common

ONNXRuntime JavaScript API library

  • 1.20.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created

What is onnxruntime-common?

The onnxruntime-common npm package provides common utilities and types for the ONNX Runtime JavaScript API. It is typically used in conjunction with other ONNX Runtime packages to facilitate the loading, running, and managing of ONNX models in JavaScript environments.

What are onnxruntime-common's main functionalities?

Model Management

This feature allows you to load an ONNX model into an inference session. The code sample demonstrates how to create an inference session from a model file.

const { InferenceSession } = require('onnxruntime-common');

async function loadModel(modelPath) {
  const session = await InferenceSession.create(modelPath);
  console.log('Model loaded successfully');
  return session;
}

loadModel('path/to/model.onnx');

Inference

This feature allows you to run inference on an ONNX model. The code sample demonstrates how to create a tensor from input data, feed it into the model, and retrieve the inference results.

const { InferenceSession, Tensor } = require('onnxruntime-common');

async function runInference(session, inputData) {
  const inputTensor = new Tensor('float32', inputData, [1, inputData.length]);
  const feeds = { input: inputTensor };
  const results = await session.run(feeds);
  console.log('Inference results:', results);
  return results;
}

(async () => {
  const session = await InferenceSession.create('path/to/model.onnx');
  const inputData = new Float32Array([1.0, 2.0, 3.0, 4.0]);
  await runInference(session, inputData);
})();

Tensor Management

This feature allows you to create and manage tensors, which are the primary data structure used in ONNX models. The code sample demonstrates how to create a tensor from a data array and dimensions.

const { Tensor } = require('onnxruntime-common');

function createTensor(data, dims) {
  const tensor = new Tensor('float32', data, dims);
  console.log('Tensor created:', tensor);
  return tensor;
}

const data = new Float32Array([1.0, 2.0, 3.0, 4.0]);
const dims = [2, 2];
createTensor(data, dims);

Other packages similar to onnxruntime-common

Keywords

FAQs

Package last updated on 22 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc