Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot resolve operator 'Cast' with opsets: ai.onnx v17 [Web] #21115

Open
SpadgerBoy opened this issue Jun 20, 2024 · 1 comment
Open

cannot resolve operator 'Cast' with opsets: ai.onnx v17 [Web] #21115

SpadgerBoy opened this issue Jun 20, 2024 · 1 comment
Labels
platform:web issues related to ONNX Runtime web; typically submitted using template stale issues that have not been addressed in a while; categorized by a bot

Comments

@SpadgerBoy
Copy link

Describe the issue

I am using https://github.com/microsoft/onnxruntime-web-demo When testing my model, this issue occurred. My onnx was exported from pytorch 2.1.0+cu11.8, and I am not sure if it is a version compatibility issue.
This issue occurs in the async initSession() function.
I am using https://github.com/microsoft/onnxruntime-inference-examples/blob/main/js/quick-start_onnxruntime-web-bundler The sample method in did not encounter this issue when loading my onnx model,
image

To reproduce

My onnx model has also been uploaded in zip。
model.zip
my initSession()function is following:
async initSession() {
const node_emb = [0.016612321138381958, 0.32479220628738403, -0.17480510473251343, 0.22171857953071594, -0.03362815082073212, -0.5541449189186096, -0.2134913206100464, 0.2579418420791626, 0.028158824890851974, -0.213491290807724, 0.2579419016838074, 0.028158817440271378, -0.29980212450027466, 0.05575799569487572, 0.13522188365459442, 0.0867883488535881, -0.236801415681839, -0.4331217110157013, 0.32896843552589417, 0.2346162348985672, -0.2873727083206177, -0.23857513070106506, -0.17035554349422455, 0.1389528214931488, -0.38259392976760864, 0.3879542648792267, 0.037937164306640625, 0.49905404448509216, 0.11682555079460144, 0.37333834171295166, -0.14307904243469238, -0.4935119152069092, 0.05580680072307587, 0.3595126271247864, 0.10027752816677094, 0.3577460050582886, -0.07288319617509842, -0.29953575134277344, 0.03781317174434662, 0.2026776224374771, -0.1408967673778534, 0.2797025144100189, -0.0728832334280014, -0.29953569173812866, 0.037813249975442886];
const node_level = [1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 4, 4];
const pos = [-0.6719708442687988, -0.17349961400032043, -0.07278412580490112, -0.4342332184314728, 0.565944254398346, 1.124698519706726, 1.1682472229003906, 0.679757833480835, 0.7840494513511658, 0.9343644380569458, 0.8223643898963928, 0.09227360785007477, -0.47061389684677124, 0.07232263684272766, -0.8676600456237793, -0.5899250507354736, -1.1705106496810913, 0.401921808719635, 0.01343536376953125, -0.16409379243850708, 0.678995668888092, -0.49010971188545227, -1.7985889911651611, -1.0793498754501343, -0.476369708776474, 0.26042065024375916, 0.16324150562286377, 0.22609102725982666, 1.3322205543518066, -0.8606394529342651];
const edge_index = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 3, 4, 5, 6, 7, 8, 10, 12, 13, 14, 0, 2, 4, 5, 6, 7, 8, 10, 12, 13, 14, 0, 2, 3, 5, 6, 7, 8, 10, 12, 13, 14, 0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 12, 13, 14, 0, 1, 2, 3, 4, 5, 8, 9, 10, 11, 13, 0, 1, 2, 3, 4, 5, 8, 9, 10, 12, 13, 14, 0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 12, 13, 14, 0, 1, 5, 6, 7, 8, 10, 11, 12, 13, 14, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 0, 1, 6, 9, 10, 13, 0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 13, 14, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 12, 13];
const edge_type = [2, 2, 2, 2, 3, 1, 3, 1, 2, 2, 3, 3, 3, 3, 2, 1, 1, 3, 3, 2, 2, 3, 3, 3, 3, 2, 2, 2, 3, 3, 3, 1, 2, 3, 3, 3, 2, 2, 2, 3, 3, 3, 1, 2, 3, 3, 3, 2, 2, 2, 3, 3, 1, 1, 2, 3, 3, 3, 3, 1, 3, 3, 3, 2, 2, 2, 3, 1, 2, 2, 2, 1, 1, 3, 3, 3, 2, 2, 1, 3, 2, 2, 3, 3, 3, 3, 1, 2, 2, 3, 1, 2, 2, 2, 1, 3, 1, 1, 1, 2, 2, 2, 3, 1, 2, 2, 2, 2, 2, 3, 1, 3, 3, 2, 1, 3, 1, 3, 2, 2, 2, 2, 2, 1, 3, 1, 1, 2, 3, 1, 1, 1, 3, 3, 2, 1, 3, 2, 3, 3, 3, 3, 3, 2, 2, 2, 3, 1, 2, 2, 3, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 2, 2, 2, 3, 1, 2, 2];

const N = 15;
const E = 176;

const node_emb_tensor = new Tensor('float32', node_emb, [N, 3]);
const node_level_tensor = new Tensor('int64', node_level, [N, 1]);
const pos_tensor = new Tensor('float32', pos, [N, 2]);
const edge_index_tensor = new Tensor('int64', edge_index, [2, E]);
const edge_type_tensor = new Tensor('int64', edge_type, [E]);

const datas = [node_emb_tensor, node_level_tensor, pos_tensor, edge_index_tensor, edge_type_tensor];
this.sessionRunning = false;
this.modelLoadingError = false;
if (this.sessionBackend === "webgl") {
  if (this.gpuSession) {
    this.session = this.gpuSession;
    return;
  }
  this.modelLoading = true;
  this.modelInitializing = true;
}
if (this.sessionBackend === "wasm") {
  if (this.cpuSession) {
    this.session = this.cpuSession;
    return;
  }
  this.modelLoading = true;
  this.modelInitializing = true;
}

try {
  if (this.sessionBackend === "webgl") {
    this.gpuSession = await runModelUtils.createModelGpu(this.modelFile);
    this.session = this.gpuSession;
  } else if (this.sessionBackend === "wasm") {
    this.cpuSession = await runModelUtils.createModelCpu(this.modelFile);
    this.session = this.cpuSession;
  }
} catch (e) {
  console.log('loading error:', e);
  this.modelLoading = false;
  this.modelInitializing = false;
  if (this.sessionBackend === "webgl") {
    this.gpuSession = undefined;
  } else {
    this.cpuSession = undefined;
  }
  throw new Error("Error: Backend not supported. ");
}
this.modelLoading = false;
// warm up session with a sample tensor. Use setTimeout(..., 0) to make it an async execution so that UI update can be done.
if (this.sessionBackend === "webgl") {
  setTimeout(() => {
    runModelUtils.warmupModel(this.session!, datas);
    // runModelUtils.warmupModel(this.session!, [1,3,this.imageSize,this.imageSize,]);
    this.modelInitializing = false;
  }, 0);
} else {
  await runModelUtils.warmupModel(this.session!, datas);
  // await runModelUtils.warmupModel(this.session!, [1,3,this.imageSize,this.imageSize,]);
  this.modelInitializing = false;
}

}

Urgency

I hope to receive help as soon as possible. I don't have much time left

ONNX Runtime Installation

Released Package

ONNX Runtime Version or Commit ID

"onnxruntime-web": "1.8.0-dev.20210708.0",

Execution Provider

'webgl' (WebGL), 'wasm'/'cpu' (WebAssembly CPU)

@SpadgerBoy SpadgerBoy added the platform:web issues related to ONNX Runtime web; typically submitted using template label Jun 20, 2024
Copy link
Contributor

This issue has been automatically marked as stale due to inactivity and will be closed in 30 days if no further activity occurs. If further support is needed, please provide an update and/or more details.

@github-actions github-actions bot added the stale issues that have not been addressed in a while; categorized by a bot label Jul 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform:web issues related to ONNX Runtime web; typically submitted using template stale issues that have not been addressed in a while; categorized by a bot
Projects
None yet
Development

No branches or pull requests

1 participant