Skip to content

Tensor.Resize returns unexpected values when start is greater than 0 #128512

@prozolic

Description

@prozolic

Description

When it use Tensor.Resize with Tensor whose starting postion(start) is greater than 0, the resulting values differ from the expected value.
For example, resizing a Tensor created with Tensor.Create([1, 2, 3, 4, 5, 6], start: 2, lengths: [4], strides: []) produces a Tensor containing [5, 6, 0, 0] instead of [3, 4, 5, 6].

Reproduction Steps

Tensor<int> tensor = Tensor.Create([1, 2, 3, 4, 5, 6], start: 2, lengths: [4], strides: []);  // return [3, 4, 5, 6]
Tensor<int> resizedTensor = Tensor.Resize(tensor, [4]); // [5, 6, 0, 0] (should return [3, 4, 5, 6]) 

Expected behavior

The resized Tensor starts from _values[_start]

Actual behavior

The resized Tensor starts from _values[_start * 2] because _start is applied twice.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

I have created a pull request (#128511).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions