message: enhancement - use static variable for checking static variable
diff: @@ -1821,15 +1821,21 @@ class MklPrimitiveFactory {
  /// For those legacy device(w/o AVX512 and AVX2),
  /// MKL-DNN GEMM will be used.
  static inline bool IsLegacyPlatform() {
  + static bool is_legacy_platform = [] {
  return (!port::TestCPUFeature(port::CPUFeature::AVX512F) &&
  !port::TestCPUFeature(port::CPUFeature::AVX2));
  + }();
  + return is_legacy_platform;
  }
  /// Function to check whether primitive memory optimization is enabled
  static inline bool IsPrimitiveMemOptEnabled() {
  - bool is_primitive_mem_opt_enabled = true;
  - TF_CHECK_OK(ReadBoolFromEnvVar("TF_MKL_OPTIMIZE_PRIMITIVE_MEMUSE", true,
  - &is_primitive_mem_opt_enabled));
  + static bool is_primitive_mem_opt_enabled = [] {
  + bool value = true;
  + TF_CHECK_OK(
  + ReadBoolFromEnvVar("TF_MKL_OPTIMIZE_PRIMITIVE_MEMUSE", true, &value));
  + return value;
  + }();
  return is_primitive_mem_opt_enabled;
  }
  