Skip to content

Fix visual observation tensor indexing for Unity inference #6239

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

pglagol
Copy link

@pglagol pglagol commented Aug 18, 2025

Summary

  • Fix tensor indexing in Unity inference to use correct CHW layout
  • Fixed erroneous behavior of the agent on the Unity side when there is more than one visual channel

Problem

The indexing formula was calculating HWC layout while Unity's visual sensors write data in CHW format.

Solution

Corrected TensorExtensions.Index() to properly calculate CHW tensor indices that match Unity's observation writer
format.

This change corrects the tensor indexing calculation in TensorExtensions.Index()
to properly support CHW (channels-height-width) format used by both Unity's
observation writers and ONNX models during inference.
Copy link

@robinDLFM robinDLFM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solved it for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants