Skip to content
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

Is custom initial parameters of function "read" needed? #96

Closed
yhmtsai opened this issue Aug 2, 2018 · 3 comments
Closed

Is custom initial parameters of function "read" needed? #96

yhmtsai opened this issue Aug 2, 2018 · 3 comments
Labels
is:idea Just a thought - if it's good, it could evolve into a proposal. mod:core This is related to the core module.

Comments

@yhmtsai
Copy link
Member

yhmtsai commented Aug 2, 2018

The function "read" of matrix computes the matrix parameter by itself.
For example, we cannot set customized stride for ell matrices when reading mtx file.
However, when we convert Dense matrix to another matrix format, we can set the custom initial parameters of the matrix.

How about we also allow custom initial parameters for function "read"?

@gflegar
Copy link
Member

gflegar commented Aug 3, 2018

Not sure I get what you mean. Are you referring to the global read function, or the read method of the ReadableFromMtx interface.

If it is the global function, then you can pass extra parameters to it - the method has a stream from which the matrix will be read, and a list of parameters passed to the create method of the matrix. Then, the method will create a new matrix using create and forwarding the extra parameters, call read_raw on the stream to obtain a mtx_data object, and finally call the method read of the matrix with that object to pass it in.

So, to set a custom stride for the ELL matrix you could do something like (assuming ELL's read method doesn't override the parameters set in the constructor):

auto A = gko::read(std::cin, exec, gko::dim<2>{}, elem_per_row, my_stride);

If you're talking about the read method from ReadableFromMtx interface, we cannot really add parameters to it, as it is an implementation of a polymorphic interface. What we can do is try to preserve as many parameters set in the constructor as possible when calling read. In a way, the extra parameters for the function are then stored in the implicitly passed this object.

@gflegar gflegar added mod:core This is related to the core module. is:idea Just a thought - if it's good, it could evolve into a proposal. labels Aug 3, 2018
@yhmtsai
Copy link
Member Author

yhmtsai commented Aug 3, 2018

I am mainly talking about the read method from ReadableFromMatrix.
The read method from ReadableFromMatrix of each format overrides the parameter list, so the resulting matrix from gko::read losses the parameter list.
The way you mentioned in the last is okay for me.

@upsj
Copy link
Member

upsj commented Jul 28, 2023

I think this is already addressed by the changes in #886, as it attempts to reset stride and similar parameters only if it involves reallocation.

@upsj upsj closed this as completed Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
is:idea Just a thought - if it's good, it could evolve into a proposal. mod:core This is related to the core module.
Projects
None yet
Development

No branches or pull requests

3 participants