vinx13 commented on a change in pull request #8851:
URL: https://github.com/apache/tvm/pull/8851#discussion_r698798169



##########
File path: python/tvm/autotvm/measure/measure_methods.py
##########
@@ -114,53 +114,43 @@ def build(self, measure_inputs):
                 futures.append(ret)
 
             for future in futures:
-                res = future.get()
-
-                if isinstance(res, Exception):
-                    # timeout or fleet error, return MeasureResult directly
+                try:
+                    res = future.result()
+                    results.append(res)
+                except TimeoutError as ex:
                     results.append(
                         MeasureResult(
-                            (res,), MeasureErrorNo.BUILD_TIMEOUT, 
self.timeout, time.time()
+                            (ex,), MeasureErrorNo.BUILD_TIMEOUT, self.timeout, 
time.time()
                         )
                     )
-                elif res.error is not None:
-                    # instantiation error
-                    if isinstance(res.error, InstantiationError):
-                        results.append(
-                            MeasureResult(
-                                (res.error,),
-                                MeasureErrorNo.INSTANTIATION_ERROR,
-                                res.time_cost,
-                                time.time(),
-                            )
+                except ChildProcessError as ex:
+                    results.append(
+                        MeasureResult(
+                            (ex,),
+                            MeasureErrorNo.RUNTIME_DEVICE,
+                            self.timeout,
+                            time.time(),
                         )
-                    else:
-                        if "InstantiationError" in str(res.error):
-                            msg = str(res.error)
-                            try:
-                                msg = msg.split("\n")[-2].split(": ")[1]
-                            except Exception:  # pylint: disable=broad-except
-                                pass
-                            results.append(
-                                MeasureResult(
-                                    (InstantiationError(msg),),
-                                    MeasureErrorNo.INSTANTIATION_ERROR,
-                                    res.time_cost,
-                                    time.time(),
-                                )
-                            )
-                        else:  # tvm error
-                            results.append(
-                                MeasureResult(
-                                    (res.error,),
-                                    MeasureErrorNo.COMPILE_HOST,
-                                    res.time_cost,
-                                    time.time(),
-                                )
-                            )
-                else:
-                    # return BuildResult
-                    results.append(res)
+                    )
+                except InstantiationError as ex:

Review comment:
       these parts are handled in 
https://github.com/apache/tvm/blob/421dbf14f44c390bda56ba82e0d992b9ece14bf4/python/tvm/autotvm/measure/measure_methods.py#L516-L517,
 we can keep the original handling. We only need to handle `TimeoutError` and 
`ChildProcessError` here

##########
File path: python/tvm/autotvm/measure/measure_methods.py
##########
@@ -114,53 +114,43 @@ def build(self, measure_inputs):
                 futures.append(ret)
 
             for future in futures:
-                res = future.get()
-
-                if isinstance(res, Exception):
-                    # timeout or fleet error, return MeasureResult directly
+                try:
+                    res = future.result()
+                    results.append(res)
+                except TimeoutError as ex:
                     results.append(
                         MeasureResult(
-                            (res,), MeasureErrorNo.BUILD_TIMEOUT, 
self.timeout, time.time()
+                            (ex,), MeasureErrorNo.BUILD_TIMEOUT, self.timeout, 
time.time()
                         )
                     )
-                elif res.error is not None:
-                    # instantiation error
-                    if isinstance(res.error, InstantiationError):
-                        results.append(
-                            MeasureResult(
-                                (res.error,),
-                                MeasureErrorNo.INSTANTIATION_ERROR,
-                                res.time_cost,
-                                time.time(),
-                            )
+                except ChildProcessError as ex:
+                    results.append(
+                        MeasureResult(
+                            (ex,),
+                            MeasureErrorNo.RUNTIME_DEVICE,
+                            self.timeout,
+                            time.time(),
                         )
-                    else:
-                        if "InstantiationError" in str(res.error):
-                            msg = str(res.error)
-                            try:
-                                msg = msg.split("\n")[-2].split(": ")[1]
-                            except Exception:  # pylint: disable=broad-except
-                                pass
-                            results.append(
-                                MeasureResult(
-                                    (InstantiationError(msg),),
-                                    MeasureErrorNo.INSTANTIATION_ERROR,
-                                    res.time_cost,
-                                    time.time(),
-                                )
-                            )
-                        else:  # tvm error
-                            results.append(
-                                MeasureResult(
-                                    (res.error,),
-                                    MeasureErrorNo.COMPILE_HOST,
-                                    res.time_cost,
-                                    time.time(),
-                                )
-                            )
-                else:
-                    # return BuildResult
-                    results.append(res)
+                    )
+                except InstantiationError as ex:

Review comment:
       these parts (L135-L153) are handled in 
https://github.com/apache/tvm/blob/421dbf14f44c390bda56ba82e0d992b9ece14bf4/python/tvm/autotvm/measure/measure_methods.py#L516-L517,
 we can keep the original handling. We only need to handle `TimeoutError` and 
`ChildProcessError` here




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to