-
Notifications
You must be signed in to change notification settings - Fork 99
1912/5 cartesian product #1919
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
base: 1912/4-operations-in-json
Are you sure you want to change the base?
1912/5 cartesian product #1919
Conversation
should we wrap it into "cartesian" to make it more clear and for future features?
|
I think your suggestion should be
since the operator is also part of the cartesian product. TBH, I find this a bit redundant, since the |
I was thinking whether it will give easier path when we would like to introduce specific combination. |
Could you be more specific about what you mean by specific combination? If you mean that we should allow cartesian products with keys that are not on the top-level (e.g. the |
no, whether we can provide like |
I think this is similar to what I mentioned above (although I meant the |
Side note: what you mention was also not possible before, so this isn't removing any existing functionality. |
benchmark/test/conversion.py
Outdated
stencil_input = generate_input(["coo", "csr"]) | ||
stencil_input_all = generate_input(["coo", "csr", "ell", "sellp", "hybrid"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stencil_input is equal to the oirignal one, but stencil_input_all will generate 5*5 kinds not 13 kinds, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it will be the good use case to think whether we should support this kind or just say users need to expand all by them self.
Something like the following might be doable?
"keyword*": [
{
"from": "csr"
"to": "coo"
},
{
"from": "coo"
"to": "coo"
}
]
when match keyword, we will not add the "keyword*" to the resulting list but just put the underlying ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding your first question, yes it will generate 5*5 operations. However, any operation that is not supported (e.g. ell -> hybrid) is just skipped.
Regarding your second point, sure it is probably possible, but I think it might be a bit too confusing to use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. could we still make this test as previous 13 kinds? it also check whether we still have the same ability as original.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test uses the same 13 conversions as before. You can check it in the conversion.all.stdout
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be all. The diff with develop shows no missing conversion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean that we only need to test exactly 13 kinds as previous one. cartesian product already be test via [csr, coo] x [csr, coo]
It only shows it is not supported with the new combination.
Also, keeping it as the original one can check whether we still support list input not cartesian product input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you perhaps rephrase your overall point in this comment chain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stencil_input = generate_input(["coo", "csr"]);
<- test cartesian product and all function are available
stencil_input_all = generate_input(["coo", "csr", "ell", "sellp", "hybrid"])
<- test more combination than the original test case but the additional functionality are not supported.
I think stencil_input_all
can stay as the same as the original one in develop branch.
i.e.
[
{// case 1},
{// case 2},
{// case 3},
{// functionality we actually support}
]
It will also be served as original array method check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added now an input file with the full list of supported conversions.
* values of the input dict. Any value that isn't a list will be converted into | ||
* a list of a single item. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* values of the input dict. Any value that isn't a list will be converted into | |
* a list of a single item. | |
* values of the input dict. Any value that isn't a list will be considered as | |
* a list of a single item during expanding. |
I was thinking it is produce "A": ["B"]
in the resulting file from "A": "B"
, but it is considered as "A": ["B"]
during processing and lead "A": "B" in all, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider this input:
{
"a": "b",
"c": ["d"]
}
it will produce
[
{
"a": "b",
"c": "d"
}
]
Does that answer your question?
auto [name, next_list] = lists[depth]; | ||
for (const auto& next_elem : next_list) { | ||
json combined_elem = elem; | ||
combined_elem[name] = next_elem; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here need to handle keyword if we allow the manual set
2f39d78
to
c8389c3
Compare
2e3e378
to
4420f25
Compare
c8389c3
to
e69b5ab
Compare
4420f25
to
afa7f79
Compare
This PR allows defining the benchmark JSON input via cartesian products. The original behavior of creating the cartesian product between the input json and the CLI flags such as
format
(spmv) oroperation
(blas) is now emulated. Here is an example for defining the input as a cartesian product:The cartesian product is taken between all top-level values of the input JSON. The JSON has to be a dict for this to work. Any value that is not an array will be transformed into an array with a single item.
Note that this allows for more combinations than before, since an arbitrary number of arrays can be used in the cartesian product.