Skip to content
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 src/relay/backend/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ inline relay::Function BindParamsByName(
for (auto arg : func->params) {
const auto& name = arg->name_hint();
if (name_dict.count(name)) {
repeat_var.insert(arg);
repeat_var.insert(name_dict[name]);
} else {
name_dict[name] = arg;
}
Expand Down
13 changes: 13 additions & 0 deletions tests/python/relay/test_ir_bind.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
# specific language governing permissions and limitations
# under the License.
""" test bind function."""
import pytest
import tvm
from tvm import te
from tvm import relay
from tvm import TVMError


def test_bind_params():
Expand All @@ -34,5 +36,16 @@ def test_bind_params():
assert tvm.ir.structural_equal(zbinded, zexpected)


def test_bind_duplicated_params():
a = relay.var("a", shape=(1,))
aa = relay.var("a", shape=(1,))
s = a + aa
func = relay.Function([a, aa], s)

with pytest.raises(TVMError):
relay.build_module.bind_params_by_name(func, {"a": [1.0]})


if __name__ == "__main__":
test_bind_params()
test_bind_duplicated_params()