microsoft / microsoft/onnxruntime

[Mobile] same model returns different result between java and android enviroment

Open
#16,472 9 comments 0 reactions 1 assignee View on GitHub

@wejoncy is already working on this.

Since Oct 3, 2023.

api:Java platform:mobile
Dominant language
C++
Stars
21.9k
Forks
4.2k
Avg merge
4d 8h
Merged PRs (30d)
179

Description

Describe the issue

I tried using onnxruntime to run chinese-clip model on android enviroment.
Because i am familiar with java, So I written the code in java first. And the result is as the same as the official python version.
When I transfer the code to android studio, I found that the result is different.
I hava already checked the input tensor, code dependencies, all that same.
Below is my core code fragments about onnx running.

        InputStream imgInput = this.getClass().getClassLoader().getResourceAsStream("img_quant.onnx");
        assert imgInput != null;
        OrtSession session = ortEnv.createSession(IOUtils.toByteArray(imgInput));
       ... ...
       Map<String, OnnxTensor> inputMap = new HashMap<>();
        String inputName = session.getInputNames().iterator().next();
        String outputName = session.getOutputNames().iterator().next();

        inputMap.put(inputName, inputTensor);
        OrtSession.Result result = session.run(inputMap);

the same input tensors: (saved the data and checked with vimdiff)
android studio
idea

different outputs:
android studio
idea

And the core dependencies are the same:

com.microsoft.onnxruntime:onnxruntime-android:1.15.0
org.nd4j:nd4j-native-platform:1.0.0-M2.1

Any thoughts or comments on this problem?

To reproduce

See above for details

Urgency

No response

Platform

Android

OS Version

android studio emulator arm64-v8a

ONNX Runtime Installation

Released Package

Compiler Version (if 'Built from Source')

No response

Package Name (if 'Released Package')

onnxruntime-android

ONNX Runtime Version or Commit ID

1.15.0

ONNX Runtime API

Java/Kotlin

Architecture

ARM64

Execution Provider

Default CPU

Execution Provider Library Version

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.