Skip to content

Conversation

fastbodin
Copy link
Contributor

@fastbodin fastbodin commented Oct 10, 2025

Closes #160

@fastbodin fastbodin marked this pull request as ready for review October 10, 2025 00:40
@fastbodin fastbodin force-pushed the feauture/transpose_symbol branch from dc1df20 to f7cbaa2 Compare October 10, 2025 02:02
// transpose indices
std::reverse(multi_index.begin(), multi_index.end());
// convert multidimensional transpose indices to transpose flat index
transpose_update.index = ravel_multi_index(multi_index, node_shape);
Copy link
Contributor Author

@fastbodin fastbodin Oct 10, 2025

Choose a reason for hiding this comment

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

Just realized there should be a way to condense the unravel_index, the reverse, and the ravel_multi_index into one and make this faster. Will inspect tomorrow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There was a way but it is a bit of a brain twister

@fastbodin fastbodin marked this pull request as draft October 10, 2025 05:39
@arcondello arcondello added the enhancement New feature or request label Oct 10, 2025
Copy link
Member

@arcondello arcondello left a comment

Choose a reason for hiding this comment

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

Looks good! Happy to review changes to indexing if any come down. Or merge as-is.

Finished C++ code and tests.
Added test for dynamic vector. Ensured that min(), max(), and integral()
are stored in ValuesInfo and attached to node.
@fastbodin fastbodin force-pushed the feauture/transpose_symbol branch 2 times, most recently from 011143a to 2e91c12 Compare October 10, 2025 22:35
@fastbodin fastbodin force-pushed the feauture/transpose_symbol branch from 2e91c12 to 65302e0 Compare October 10, 2025 22:39
@fastbodin fastbodin marked this pull request as ready for review October 10, 2025 22:40
Comment on lines +1210 to +1219
transpose_diff.reserve(array_ptr_->size_diff(state));

for (const Update& update : pred_diff) {
// make a copy of the update
Update transpose_update = update;
// convert the index to the transpose index
transpose_update.index = convert_predecessor_index(update.index);
// save the converted update
transpose_diff.emplace_back(transpose_update);
}
Copy link
Member

Choose a reason for hiding this comment

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

I think you could also replace this with something like

transpose_diff.assign(pred_diff.begin(), pred_diff.end());
std::transform(
        transpose_diff.cbegin(),
        transpose_diff.cend(),
        transpose_diff.begin(),
        [this](const Update& u) { return Update(convert_predecessor_index(u.index), u.old, u.value; }
);

or let convert_predecessor_index take an Update to make it even shorter.

}
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

I think you should also add a test for a scalar (0-d) array?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider adding Transpose symbol or similar

3 participants