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

Improve error messages #8309

Merged
merged 1 commit into from
Jun 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion torch/csrc/autograd/functions/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void check_input_variables(const char* name, const variable_list& inputs, int ar
for (int i = 0; i < required_args; ++i) {
if (!inputs[i].defined()) {
std::stringstream ss;
ss << name << ": expected Variable at argument " << i << " (got None)";
ss << name << ": expected Tensor at argument " << i << " (got None)";
throw std::runtime_error(ss.str());
}
}
Expand Down
6 changes: 3 additions & 3 deletions torch/csrc/utils/python_arg_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ inline at::Tensor PythonArgs::tensor(int i) {
// a test for Py_None here; instead, you need to mark the argument
// as *allowing none*; you can do this by writing 'Tensor?' instead
// of 'Tensor' in the ATen metadata.
throw TypeError("expected Variable as argument %d, but got %s", i,
throw TypeError("expected Tensor as argument %d, but got %s", i,
Py_TYPE(args[i])->tp_name);
}
return reinterpret_cast<THPVariable*>(args[i])->cdata;
Expand Down Expand Up @@ -208,7 +208,7 @@ inline std::vector<at::Tensor> PythonArgs::tensorlist(int i) {
for (int idx = 0; idx < size; idx++) {
PyObject* obj = tuple ? PyTuple_GET_ITEM(arg, idx) : PyList_GET_ITEM(arg, idx);
if (!THPVariable_Check(obj)) {
throw TypeError("expected Variable as element %d in argument %d, but got %s",
throw TypeError("expected Tensor as element %d in argument %d, but got %s",
idx, i, Py_TYPE(args[i])->tp_name);
}
res[idx] = reinterpret_cast<THPVariable*>(obj)->cdata;
Expand All @@ -229,7 +229,7 @@ inline std::array<at::Tensor, N> PythonArgs::tensorlist_n(int i) {
for (int idx = 0; idx < size; idx++) {
PyObject* obj = tuple ? PyTuple_GET_ITEM(arg, idx) : PyList_GET_ITEM(arg, idx);
if (!THPVariable_Check(obj)) {
throw TypeError("expected Variable as element %d in argument %d, but got %s",
throw TypeError("expected Tensor as element %d in argument %d, but got %s",
idx, i, Py_TYPE(args[i])->tp_name);
}
res[idx] = reinterpret_cast<THPVariable*>(obj)->cdata;
Expand Down