De-prioritise Dimname and DimnameList in python overload resolution#51350
De-prioritise Dimname and DimnameList in python overload resolution#51350peterbell10 wants to merge 10 commits intogh/peterbell10/48/basefrom
Conversation
`None` being a valid `Dimname` is awkward for optional `dim` arguments, as found on NumPy's reduction functions like `std` and `var`. In this cases `dim=None` should mean an all-reduction, but instead you get an error "Please look up dimensions by name". I've also had to fix `FunctionParameter::check` to actually check the first element of `INT_LIST` arguments and reject non-int types. Otherwise, the dim names end up calling the `int[]` overload and fail. [ghstack-poisoned]
💊 CI failures summary and remediationsAs of commit cc322e2 (more details on the Dr. CI page): 💚 💚 Looks good so far! There are no failures yet. 💚 💚 This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions to the (internal) Dr. CI Users group. |
…esolution" `None` being a valid `Dimname` is awkward for optional `dim` arguments, as found on NumPy's reduction functions like `std` and `var`. In these cases `dim=None` should mean an all-reduction, but instead you get an error "Please look up dimensions by name". I've also had to fix `FunctionParameter::check` to actually check the first element of `INT_LIST` arguments and reject non-int types. Otherwise, the dim names end up calling the `int[]` overload and fail. [ghstack-poisoned]
…esolution" `None` being a valid `Dimname` is awkward for optional `dim` arguments, as found on NumPy's reduction functions like `std` and `var`. In these cases `dim=None` should mean an all-reduction, but instead you get an error "Please look up dimensions by name". I've also had to fix `FunctionParameter::check` to actually check the first element of `INT_LIST` arguments and reject non-int types. Otherwise, the dim names end up calling the `int[]` overload and fail. [ghstack-poisoned]
…esolution" `None` being a valid `Dimname` is awkward for optional `dim` arguments, as found on NumPy's reduction functions like `std` and `var`. In these cases `dim=None` should mean an all-reduction, but instead you get an error "Please look up dimensions by name". I've also had to fix `FunctionParameter::check` to actually check the first element of `INT_LIST` arguments and reject non-int types. Otherwise, the dim names end up calling the `int[]` overload and fail. [ghstack-poisoned]
|
@bhosmer I think you're the correct reviewer for this change? |
bhosmer
left a comment
There was a problem hiding this comment.
Given the awkwardness of Dimname scooping up None values, this seems like a reasonable solution for the eager binding layer. I think we'll need to do something similar for the JIT though. cc @eellison for confirmation - Elias, do we support Dimname overloads on the JIT side?
| PySequence_GetItem(obj, 0)); | ||
| // NOTE: JIT tracer allows arbitrary scalar tensors to act as ints | ||
| // in an intlist argument Even float or complex scalars | ||
| return (THPVariable_Check(item.ptr()) || THPUtils_checkIndex(item.ptr())); |
There was a problem hiding this comment.
Be good to factor this out now that it's nontrivial, a la is_float_or_complex_list() just below
bhosmer
left a comment
There was a problem hiding this comment.
Given the awkwardness of Dimname scooping up None values, this seems like a reasonable solution for the eager binding layer. I think we'll need to do something similar for the JIT though. cc @eellison for confirmation - Elias, do we support Dimname overloads on the JIT side?
…esolution" `None` being a valid `Dimname` is awkward for optional `dim` arguments, as found on NumPy's reduction functions like `std` and `var`. In these cases `dim=None` should mean an all-reduction, but instead you get an error "Please look up dimensions by name". I've also had to fix `FunctionParameter::check` to actually check the first element of `INT_LIST` arguments and reject non-int types. Otherwise, the dim names end up calling the `int[]` overload and fail. [ghstack-poisoned]
…esolution" `None` being a valid `Dimname` is awkward for optional `dim` arguments, as found on NumPy's reduction functions like `std` and `var`. In these cases `dim=None` should mean an all-reduction, but instead you get an error "Please look up dimensions by name". I've also had to fix `FunctionParameter::check` to actually check the first element of `INT_LIST` arguments and reject non-int types. Otherwise, the dim names end up calling the `int[]` overload and fail. [ghstack-poisoned]
…esolution" `None` being a valid `Dimname` is awkward for optional `dim` arguments, as found on NumPy's reduction functions like `std` and `var`. In these cases `dim=None` should mean an all-reduction, but instead you get an error "Please look up dimensions by name". I've also had to fix `FunctionParameter::check` to actually check the first element of `INT_LIST` arguments and reject non-int types. Otherwise, the dim names end up calling the `int[]` overload and fail. [ghstack-poisoned]
|
@bhosmer i dont think dimname is supported, the schemas with dimname dont get attempted to be matched to in JIT. it probably wouldnt be too hard to add just no one has done it :/ |
Ah got it. Well, I don't think observing this overload ordering will add any difficulty once someone does, at least. Thanks for the info! |
…esolution" `None` being a valid `Dimname` is awkward for optional `dim` arguments, as found on NumPy's reduction functions like `std` and `var`. In these cases `dim=None` should mean an all-reduction, but instead you get an error "Please look up dimensions by name". I've also had to fix `FunctionParameter::check` to actually check the first element of `INT_LIST` arguments and reject non-int types. Otherwise, the dim names end up calling the `int[]` overload and fail. [ghstack-poisoned]
…esolution" `None` being a valid `Dimname` is awkward for optional `dim` arguments, as found on NumPy's reduction functions like `std` and `var`. In these cases `dim=None` should mean an all-reduction, but instead you get an error "Please look up dimensions by name". I've also had to fix `FunctionParameter::check` to actually check the first element of `INT_LIST` arguments and reject non-int types. Otherwise, the dim names end up calling the `int[]` overload and fail. [ghstack-poisoned]
…esolution" `None` being a valid `Dimname` is awkward for optional `dim` arguments, as found on NumPy's reduction functions like `std` and `var`. In these cases `dim=None` should mean an all-reduction, but instead you get an error "Please look up dimensions by name". I've also had to fix `FunctionParameter::check` to actually check the first element of `INT_LIST` arguments and reject non-int types. Otherwise, the dim names end up calling the `int[]` overload and fail. [ghstack-poisoned]
…ytorch#51350) Summary: Pull Request resolved: pytorch#51350 `None` being a valid `Dimname` is awkward for optional `dim` arguments, as found on NumPy's reduction functions like `std` and `var`. In these cases `dim=None` should mean an all-reduction, but instead you get an error "Please look up dimensions by name". I've also had to fix `FunctionParameter::check` to actually check the first element of `INT_LIST` arguments and reject non-int types. Otherwise, the dim names end up calling the `int[]` overload and fail. Test Plan: Imported from OSS Reviewed By: ngimel Differential Revision: D26756208 Pulled By: mruberry fbshipit-source-id: 44221ca0f4822ec2c1f62b092466fd4f779eb45a
…ytorch#51350) Summary: Pull Request resolved: pytorch#51350 `None` being a valid `Dimname` is awkward for optional `dim` arguments, as found on NumPy's reduction functions like `std` and `var`. In these cases `dim=None` should mean an all-reduction, but instead you get an error "Please look up dimensions by name". I've also had to fix `FunctionParameter::check` to actually check the first element of `INT_LIST` arguments and reject non-int types. Otherwise, the dim names end up calling the `int[]` overload and fail. Test Plan: Imported from OSS Reviewed By: ngimel Differential Revision: D26756208 Pulled By: mruberry fbshipit-source-id: 44221ca0f4822ec2c1f62b092466fd4f779eb45a
…ytorch#51350) Summary: Pull Request resolved: pytorch#51350 `None` being a valid `Dimname` is awkward for optional `dim` arguments, as found on NumPy's reduction functions like `std` and `var`. In these cases `dim=None` should mean an all-reduction, but instead you get an error "Please look up dimensions by name". I've also had to fix `FunctionParameter::check` to actually check the first element of `INT_LIST` arguments and reject non-int types. Otherwise, the dim names end up calling the `int[]` overload and fail. Test Plan: Imported from OSS Reviewed By: ngimel Differential Revision: D26756208 Pulled By: mruberry fbshipit-source-id: 44221ca0f4822ec2c1f62b092466fd4f779eb45a
Stack from ghstack:
Nonebeing a validDimnameis awkward for optionaldimarguments, as foundon NumPy's reduction functions like
stdandvar. In these casesdim=Noneshould mean an all-reduction, but instead you get an error
"Please look up dimensions by name".
I've also had to fix
FunctionParameter::checkto actually check the firstelement of
INT_LISTarguments and reject non-int types. Otherwise, the dimnames end up calling the
int[]overload and fail.Differential Revision: D26756208