Skip to content

Conversation

@shrit
Copy link
Member

@shrit shrit commented Jan 18, 2024

No description provided.

Copy link
Member Author

@shrit shrit left a comment

Choose a reason for hiding this comment

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

Comment on lines 86 to 87
MatType tmp = arma::conv_to<MatType>::from(U.unsafe_col(0));
NaiveConvolution<BorderMode>::Convolution(subOutput, tmp,
Copy link
Member Author

Choose a reason for hiding this comment

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

This is necessary since it was passing a Col and now only accepts MatType, which should always be a MatType. I do not think this should have some performance issue, hopefully not.

if you have a better proposal, please let me know

Copy link
Member

Choose a reason for hiding this comment

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

It doesn't work to just leave U.unsafe_col(0) here? That should return MatType (for Armadillo types).

There will later need to be a rethink here, since Bandicoot doesn't implement unsafe_col() and I'm not sure it makes sense for it to.

Copy link
Member

@rcurtin rcurtin left a comment

Choose a reason for hiding this comment

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

The changes look fine to me, but I think we should figure out the unsafe_col() issue before merge. 👍

Comment on lines 86 to 87
MatType tmp = arma::conv_to<MatType>::from(U.unsafe_col(0));
NaiveConvolution<BorderMode>::Convolution(subOutput, tmp,
Copy link
Member

Choose a reason for hiding this comment

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

It doesn't work to just leave U.unsafe_col(0) here? That should return MatType (for Armadillo types).

There will later need to be a rethink here, since Bandicoot doesn't implement unsafe_col() and I'm not sure it makes sense for it to.

@shrit
Copy link
Member Author

shrit commented Jan 22, 2024

@rcurtin I have tried, but the tests fail, because the Convultion function expects three MatType; in this case, one of them is arma::col, so it does not pass the tests.
This only fails when we are passing to template function parameters.
Up to you, we can merge it now and then figure out the solution for this later, or we can find a solution right now before merging, also I do not know the reason why we are using unsafe_col instead of using col directly

@rcurtin
Copy link
Member

rcurtin commented Jan 23, 2024

I think you should be able to solve this by adding more template parameters (one for each argument, for instance). That will allow the filter to take a different type, if needed.

I would suspect that the reason unsafe_col() was being used in the first place was just to avoid this exact problem. unsafe_col() just returns a Col that is an alias of the given column, instead of a subview. If each argument is its own template parameter, it should be possible to use .col() instead of .unsafe_col().

@shrit
Copy link
Member Author

shrit commented Jan 23, 2024

@rcurtin This is the real reason that unsafe_col is used

const eT* kernelPtr = filter.memptr();

Since it is not a real col, we can call memptr() as if it was a matrix.
If I try to use col() instead the compiler will complain that I need to use colptr instead of memptr

I would say, let us merge it in this state, technically, we need to find a nicer implementation for these functions with bandicoot, and I do not know the answer to this, adding overloads looks really ugly, it would be nice to have a generic function that would work with both libraries

@rcurtin
Copy link
Member

rcurtin commented Jan 24, 2024

Ah. I see, thanks for digging into that. That is indeed going to be more complicated than I thought. I agree with your assessment that we should save it for later then.

Copy link
Member

@rcurtin rcurtin 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 to me. Up to you if you want to revert 677287f before merge.

@shrit
Copy link
Member Author

shrit commented Jan 25, 2024

I will keep it like this because we will have to refactor this anyway so that we will come back to it.
I think this will save us one instruction as I will need to convert unsafe_col back to a temporary matrix

Copy link

@mlpack-bot mlpack-bot bot left a comment

Choose a reason for hiding this comment

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

Second approval provided automatically after 24 hours. 👍

@shrit shrit merged commit f72bd4f into mlpack:master Jan 26, 2024
This was referenced May 26, 2024
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