Revert "Validate input types for torch.nn.Linear and torch.nn.Bilinear (#135596)"

This reverts commit e157ce3ebbb3f30d008c15914e82eb74217562f0.

Reverted https://github.com/pytorch/pytorch/pull/135596 on behalf of https://github.com/malfet due to It's too restrictive, should allow other int-like types, such as `numpy.int64` ([comment](https://github.com/pytorch/pytorch/pull/135596#issuecomment-2349714104))
This commit is contained in:
PyTorch MergeBot
2024-09-13 18:06:56 +00:00
parent deee21cb78
commit b6d6aa49b8
2 changed files with 0 additions and 82 deletions

View File

@ -3180,66 +3180,6 @@ rnn_gru_lstm_module_info_decorators = (
# Start of module error inputs functions.
def module_error_inputs_torch_nn_Linear(module_info, device, dtype, requires_grad, training, **kwargs):
make_input = partial(make_tensor, device=device, dtype=dtype, requires_grad=requires_grad)
samples = [
ErrorModuleInput(
ModuleInput(
constructor_input=FunctionInput("10", 20),
forward_input=FunctionInput(make_input(3, 10)),
),
error_on=ModuleErrorEnum.CONSTRUCTION_ERROR,
error_type=TypeError,
error_regex=r"Expected int for in_features but got <class 'str'>"
),
ErrorModuleInput(
ModuleInput(
constructor_input=FunctionInput(10, 20.7),
forward_input=FunctionInput(make_input(3, 10)),
),
error_on=ModuleErrorEnum.CONSTRUCTION_ERROR,
error_type=TypeError,
error_regex=r"Expected int for out_features but got <class 'float'>"
),
]
return samples
def module_error_inputs_torch_nn_Bilinear(module_info, device, dtype, requires_grad, training, **kwargs):
make_input = partial(make_tensor, device=device, dtype=dtype, requires_grad=requires_grad)
samples = [
ErrorModuleInput(
ModuleInput(
constructor_input=FunctionInput("10", 20, 30),
forward_input=FunctionInput(make_input(3, 10), make_input(3, 20)),
),
error_on=ModuleErrorEnum.CONSTRUCTION_ERROR,
error_type=TypeError,
error_regex=r"Expected int for in1_features but got <class 'str'>"
),
ErrorModuleInput(
ModuleInput(
constructor_input=FunctionInput(10, 20.7, 30),
forward_input=FunctionInput(make_input(3, 10), make_input(3, 20)),
),
error_on=ModuleErrorEnum.CONSTRUCTION_ERROR,
error_type=TypeError,
error_regex=r"Expected int for in2_features but got <class 'float'>"
),
ErrorModuleInput(
ModuleInput(
constructor_input=FunctionInput(10, 20, "30"),
forward_input=FunctionInput(make_input(3, 10), make_input(3, 20)),
),
error_on=ModuleErrorEnum.CONSTRUCTION_ERROR,
error_type=TypeError,
error_regex=r"Expected int for out_features but got <class 'str'>"
),
]
return samples
def module_error_inputs_torch_nn_RNN_GRU_Cell(module_info, device, dtype, requires_grad, training, **kwargs):
make_input = partial(make_tensor, device=device, dtype=dtype, requires_grad=requires_grad)
samples = [
@ -3892,14 +3832,12 @@ module_db: List[ModuleInfo] = [
)),
ModuleInfo(torch.nn.Linear,
module_inputs_func=module_inputs_torch_nn_Linear,
module_error_inputs_func=module_error_inputs_torch_nn_Linear,
skips=(
# No channels_last support for Linear currently.
DecorateInfo(unittest.skip("Skipped!"), 'TestModule', 'test_memory_format'),)
),
ModuleInfo(torch.nn.Bilinear,
module_inputs_func=module_inputs_torch_nn_Bilinear,
module_error_inputs_func=module_error_inputs_torch_nn_Bilinear,
decorators=[
DecorateInfo(
toleranceOverride({