mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[inductor] Allow backends to register their own custom config object (#158254)
An out of tree backend can have its own configuration options that the user can enable to control inductor compilation. These config options need to be taken into account when calculating the key that is used to determine cache miss / hits. This PR allows out of tree backends to specify a custom config module that has the same type as `torch._inductor.config` that can be used to control codegen (in addition to the default config), and will be used when creating the cache key. Pull Request resolved: https://github.com/pytorch/pytorch/pull/158254 Approved by: https://github.com/eellison
This commit is contained in:
committed by
PyTorch MergeBot
parent
7d296d5c19
commit
d3d9bc1c31
@ -52,6 +52,7 @@ from torch._dynamo.exc import SkipFrame
|
||||
from torch._dynamo.utils import CompileEventLogger, counters, dynamo_timed
|
||||
from torch._inductor import config, exc, metrics
|
||||
from torch._inductor.codegen.common import (
|
||||
custom_backend_codegen_configs,
|
||||
custom_backend_passes,
|
||||
init_backend_registration,
|
||||
)
|
||||
@ -854,6 +855,13 @@ class FxGraphHashDetails:
|
||||
map(self._get_custom_pass_detail, custom_backend_passes.values())
|
||||
)
|
||||
|
||||
# Save custom inductor codegen configs
|
||||
self.custom_backend_codegen_configs = {
|
||||
device: custom_config.save_config_portable(ignore_private_configs=False)
|
||||
for device, custom_config in custom_backend_codegen_configs.items()
|
||||
if custom_config is not None
|
||||
}
|
||||
|
||||
# This is mainly added to handle these two inductor configs, which are (unfortunately)
|
||||
# sometimes cache safe:
|
||||
# - _pre_fusion_custom_pass
|
||||
|
Reference in New Issue
Block a user