openxla / xla

A machine learning compiler for GPUs, CPUs, and ML accelerators
Apache License 2.0
2.39k stars 358 forks source link

[XLA:CPU] Don't create an MLIRContext if there are no attributes to parse. #14237

Closed copybara-service[bot] closed 5 days ago

copybara-service[bot] commented 5 days ago

[XLA:CPU] Don't create an MLIRContext if there are no attributes to parse.

FFI handlers can pass MLIR attributes via backend_config. Parsing these attributes require an MLIRContext instance, which is expensive to create and destroy.

Before this change, the MLIRContext is created regardless of whether backend_config contains any attribute, causing large and unnecessary overhead.