From 2cfde9de8da05ce8606d033b69cebd6b84e762e4 Mon Sep 17 00:00:00 2001 From: strint Date: Fri, 18 Aug 2023 04:48:35 +0000 Subject: [PATCH 1/5] change for sd torch graph compile --- oneflow/api/python/framework/device.cpp | 7 ++++--- python/oneflow/nn/graph/graph.py | 1 + python/oneflow/nn/modules/module.py | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/oneflow/api/python/framework/device.cpp b/oneflow/api/python/framework/device.cpp index 445b953aac4..bb662f50793 100644 --- a/oneflow/api/python/framework/device.cpp +++ b/oneflow/api/python/framework/device.cpp @@ -31,9 +31,10 @@ ONEFLOW_API_PYBIND11_MODULE("", m) { .def(py::init([](const std::string& type_or_type_with_device_id) { return Device::ParseAndNew(type_or_type_with_device_id).GetOrThrow(); })) - .def(py::init([](const std::string& type, int64_t device_id) { - return Device::New(type, device_id).GetOrThrow(); - })) + .def(py::init([](const std::string& type, int64_t index) { + return Device::New(type, index).GetOrThrow(); + }), + py::arg("type"), py::arg("index")) .def(py::init([](const Symbol& other_device) { return other_device; })) .def_property_readonly("type", [](const Symbol& d) { return d->type(); }) .def_property_readonly("index", [](const Symbol& d) { return d->device_id(); }) diff --git a/python/oneflow/nn/graph/graph.py b/python/oneflow/nn/graph/graph.py index 2b6aca3627c..3b4c97f7a2a 100644 --- a/python/oneflow/nn/graph/graph.py +++ b/python/oneflow/nn/graph/graph.py @@ -274,6 +274,7 @@ def __call__(self, *args, **kwargs): Donot override this function. """ # For cache cache graphs with dynamic input shape. + print(self.name, " called.") if self._run_with_cache == True: return self._dynamic_input_graph_cache(*args, **kwargs) diff --git a/python/oneflow/nn/modules/module.py b/python/oneflow/nn/modules/module.py index 3bdf4d63ca7..7196549e045 100644 --- a/python/oneflow/nn/modules/module.py +++ b/python/oneflow/nn/modules/module.py @@ -1842,9 +1842,9 @@ def __repr__(self): def _shallow_repr(self): extra_lines = [] - extra_repr = self.extra_repr() - if extra_repr: - extra_lines = extra_repr.split("\n") + #extra_repr = self.extra_repr() + # if extra_repr: + # extra_lines = extra_repr.split("\n") lines = extra_lines main_str = self._get_name() + "(" if lines: From f04cc42dbb73d3186004ee424bdc68e745db639d Mon Sep 17 00:00:00 2001 From: oneflow-ci-bot Date: Fri, 18 Aug 2023 04:51:54 +0000 Subject: [PATCH 2/5] auto format by CI --- oneflow/api/python/framework/device.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/oneflow/api/python/framework/device.cpp b/oneflow/api/python/framework/device.cpp index bb662f50793..df7278a2dd1 100644 --- a/oneflow/api/python/framework/device.cpp +++ b/oneflow/api/python/framework/device.cpp @@ -32,9 +32,9 @@ ONEFLOW_API_PYBIND11_MODULE("", m) { return Device::ParseAndNew(type_or_type_with_device_id).GetOrThrow(); })) .def(py::init([](const std::string& type, int64_t index) { - return Device::New(type, index).GetOrThrow(); - }), - py::arg("type"), py::arg("index")) + return Device::New(type, index).GetOrThrow(); + }), + py::arg("type"), py::arg("index")) .def(py::init([](const Symbol& other_device) { return other_device; })) .def_property_readonly("type", [](const Symbol& d) { return d->type(); }) .def_property_readonly("index", [](const Symbol& d) { return d->device_id(); }) From c30278e74a04a19a25f55e5b540b91c6d8491a71 Mon Sep 17 00:00:00 2001 From: Xiaoyu Xu Date: Fri, 18 Aug 2023 15:42:53 +0800 Subject: [PATCH 3/5] Update python/oneflow/nn/graph/graph.py Co-authored-by: Houjiang Chen --- python/oneflow/nn/graph/graph.py | 1 - 1 file changed, 1 deletion(-) diff --git a/python/oneflow/nn/graph/graph.py b/python/oneflow/nn/graph/graph.py index 3b4c97f7a2a..2b6aca3627c 100644 --- a/python/oneflow/nn/graph/graph.py +++ b/python/oneflow/nn/graph/graph.py @@ -274,7 +274,6 @@ def __call__(self, *args, **kwargs): Donot override this function. """ # For cache cache graphs with dynamic input shape. - print(self.name, " called.") if self._run_with_cache == True: return self._dynamic_input_graph_cache(*args, **kwargs) From b0d72a3b82a28b56985a7ad100c27c29fb90c9bc Mon Sep 17 00:00:00 2001 From: oneflow-ci-bot Date: Fri, 18 Aug 2023 07:44:42 +0000 Subject: [PATCH 4/5] auto format by CI --- python/oneflow/nn/modules/module.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/oneflow/nn/modules/module.py b/python/oneflow/nn/modules/module.py index 7196549e045..c64a6eb3321 100644 --- a/python/oneflow/nn/modules/module.py +++ b/python/oneflow/nn/modules/module.py @@ -1842,7 +1842,7 @@ def __repr__(self): def _shallow_repr(self): extra_lines = [] - #extra_repr = self.extra_repr() + # extra_repr = self.extra_repr() # if extra_repr: # extra_lines = extra_repr.split("\n") lines = extra_lines From ed27149a92b801ce9a3349fb1b1c532c74d6b282 Mon Sep 17 00:00:00 2001 From: strint Date: Fri, 18 Aug 2023 12:18:18 +0000 Subject: [PATCH 5/5] restore md --- python/oneflow/nn/modules/module.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/oneflow/nn/modules/module.py b/python/oneflow/nn/modules/module.py index c64a6eb3321..3bdf4d63ca7 100644 --- a/python/oneflow/nn/modules/module.py +++ b/python/oneflow/nn/modules/module.py @@ -1842,9 +1842,9 @@ def __repr__(self): def _shallow_repr(self): extra_lines = [] - # extra_repr = self.extra_repr() - # if extra_repr: - # extra_lines = extra_repr.split("\n") + extra_repr = self.extra_repr() + if extra_repr: + extra_lines = extra_repr.split("\n") lines = extra_lines main_str = self._get_name() + "(" if lines: