未验证 提交 df311526 编写于 作者: R ronnywang 提交者: GitHub

[CustomDevice] add custom device support for Variable.set_value (#55272)

上级 33730ae7
...@@ -640,6 +640,8 @@ void BindPlace(pybind11::module &m) { // NOLINT ...@@ -640,6 +640,8 @@ void BindPlace(pybind11::module &m) { // NOLINT
.def("ipu_device_id", [](platform::Place &self) { return self.device; }) .def("ipu_device_id", [](platform::Place &self) { return self.device; })
.def("custom_device_id", .def("custom_device_id",
[](platform::Place &self) { return self.device; }) [](platform::Place &self) { return self.device; })
.def("custom_device_type",
[](platform::Place &self) { return self.GetDeviceType(); })
.def("set_place", .def("set_place",
[](platform::Place &self, const platform::Place &other) { [](platform::Place &self, const platform::Place &other) {
self = other; self = other;
......
...@@ -2456,6 +2456,12 @@ class Variable(metaclass=VariableMetaClass): ...@@ -2456,6 +2456,12 @@ class Variable(metaclass=VariableMetaClass):
p = core.Place() p = core.Place()
p.set_place(t._place()) p.set_place(t._place())
place = core.XPUPlace(p.xpu_device_id()) place = core.XPUPlace(p.xpu_device_id())
elif p.is_custom_place():
p = core.Place()
p.set_place(t._place())
place = core.CustomPlace(
p.custom_device_type(), p.custom_device_id()
)
else: else:
p = core.Place() p = core.Place()
p.set_place(t._place()) p.set_place(t._place())
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册