A wrapper class for communicating with Android device Attributes: qnn_config: (QnnConfig): A config class that saves qnn lowering and execution configuration. pte_path (Union[str, list]): Path where executorch binary was stored. If there are multiple pte files, provide a li
| 203 | |
| 204 | |
| 205 | class SimpleADB: |
| 206 | """ |
| 207 | A wrapper class for communicating with Android device |
| 208 | |
| 209 | Attributes: |
| 210 | qnn_config: (QnnConfig): A config class that saves qnn lowering and execution configuration. |
| 211 | pte_path (Union[str, list]): Path where executorch binary was stored. If there are multiple pte files, provide a list of pte paths. |
| 212 | workspace (str): Folder for storing artifacts on android device |
| 213 | error_only (bool): Redirect stdio and leave error messages only |
| 214 | runner (str): Runtime executor binary |
| 215 | expected_input_shape (Tuple[torch.Size]): Input shape of dynamic graph |
| 216 | expected_output_shape (Tuple[torch.Size]): Output shape of dynamic graph |
| 217 | """ |
| 218 | |
| 219 | def __init__( |
| 220 | self, |
| 221 | qnn_config: QnnConfig, |
| 222 | pte_path: Union[str, list], |
| 223 | workspace, |
| 224 | error_only=False, |
| 225 | runner=None, |
| 226 | expected_input_shape=None, |
| 227 | expected_output_shape=None, |
| 228 | ): |
| 229 | if runner is None: |
| 230 | runner = ( |
| 231 | "examples/qualcomm/executor_runner/qnn_executor_runner" |
| 232 | if qnn_config.direct_build_folder is None |
| 233 | else "examples/qualcomm/direct_executor_runner/qnn_executor_direct_runner" |
| 234 | ) |
| 235 | self.runner = runner |
| 236 | if qnn_config.direct_build_folder: |
| 237 | required_env = [HEXAGON_SDK_ROOT, HEXAGON_TOOLS_ROOT] |
| 238 | assert all( |
| 239 | var in os.environ for var in required_env |
| 240 | ), f"Please ensure the following environment variables are set: {required_env}" |
| 241 | self.hexagon_sdk_root = os.getenv(HEXAGON_SDK_ROOT) |
| 242 | self.hexagon_tools_root = os.getenv(HEXAGON_TOOLS_ROOT) |
| 243 | logging.info(f"{HEXAGON_SDK_ROOT}={self.hexagon_sdk_root}") |
| 244 | logging.info(f"{HEXAGON_TOOLS_ROOT}={self.hexagon_tools_root}") |
| 245 | self.qnn_config = qnn_config |
| 246 | self.qnn_sdk = os.getenv("QNN_SDK_ROOT") |
| 247 | self.build_path = qnn_config.build_folder |
| 248 | self.direct_build_folder = qnn_config.direct_build_folder |
| 249 | self.pte_path = pte_path if isinstance(pte_path, list) else [pte_path] |
| 250 | if qnn_config.pre_gen_pte: |
| 251 | self.pte_path = [ |
| 252 | os.path.join(qnn_config.pre_gen_pte, os.path.basename(p)) |
| 253 | for p in self.pte_path |
| 254 | ] |
| 255 | assert all( |
| 256 | os.path.exists(p) for p in self.pte_path |
| 257 | ), f"{self.pte_path} not found. Please ensure there are pregenerated pte files under pre_gen_pte path." |
| 258 | logging.info( |
| 259 | f"Pregenerated pte path given. Using pre_gen_pte path: {self.pte_path}" |
| 260 | ) |
| 261 | self.workspace = workspace |
| 262 | self.device_id = qnn_config.device |
no outgoing calls
no test coverage detected