    def run(self) -> AITInterpreterResult:
        """
        Build AITemplate engine
        Returns:
        Compiled AITemplate engine packaged as AITInterpreterResult
        """
        run_module_start_time = datetime.now()
        output_tensors = super().run()
        _LOGGER.info(
            f"Run Module elapsed time: {datetime.now() - run_module_start_time}"
        )
        # FX2AIT name if composed as MODULE_NAME/submodule_name, we put all profile file on
        # parent dir of submodule_name to share across submodules.
        profile_dir = (
            os.path.join(self.workdir, self.name[0 : self.name.rindex("/")])
            if self.name.find("/") != -1
            else self.workdir
        )
        args = {
            "tensor": output_tensors,
            "target": self.hardware_target,
            "workdir": self.workdir,
            "test_name": self.name,
            "profile_devs": self.profile_devs,
            "dynamic_profiling_strategy": self.dynamic_profile_strategy,
            "dll_name": self.dll_name,
            "profile_dir": profile_dir,
            "do_optimize_graph": self.do_optimize_graph,
            "profile_timeout": self.profile_timeout,
        }
        if self.dump_ait_dir:
            dump_ait_path = os.path.join(self.dump_ait_dir, self.name + ".py")
            random_constants = not self.keep_constants
            dump_program(
                output_tensors, dump_ait_path, random_constants=random_constants
            )
            _LOGGER.info(f"Dumped AIT model to {dump_ait_path}")

        if self.load_ait_dir:
            load_ait_path = os.path.join(self.load_ait_dir, self.name + ".py")
            _LOGGER.info(f"Loaded AIT model from {load_ait_path}")
            output_tensors, _ = get_program(load_ait_path)
            if isinstance(output_tensors, AITTensor):
                output_tensors = (output_tensors,)
            args["tensor"] = output_tensors

        self.engine = compile_model(**args)
        ait_input_names = [
            n._attrs["name"]
            for n in self.engine.debug_sorted_graph
            if n._attrs["is_input"]
        ]
        ait_input_dtypes = {
            n._attrs["name"]: n._attrs["dtype"]
            for n in self.engine.debug_sorted_graph
            if n._attrs["is_input"]
        }
        for name in ait_input_names:
            assert (
                self._fx_input_names.count(name) == 1
            ), f"Cannot find AIT's compiled input: {name} in fx graph!"

        for name in self._fx_input_names:
            if name in ait_input_names:
                self._input_names.append(name)
                self._input_dtypes.append(ait_input_dtypes[name])

        for i, input_name in enumerate(self._fx_input_names):
            _LOGGER.info("Set input{}: {}".format(i, input_name))

        if self.engine is None:
            raise RuntimeError("Engine is missing!")

        if self.save_remote_cache:
            self._upload_profile_cache(self.hardware_target)

        return AITInterpreterResult(
            self.engine,
            self._input_names,
            self._output_names,
            self._fx_input_names,
            self._input_dtypes,
            self._output_dtypes,
        )
Build AITemplate engine
Returns:
Compiled AITemplate engine packaged as AITInterpreterResult
fx2ait/fx2ait/fx2ait.py