From 55cd84c5191ef9d7b8de1850ce3c97ed6aa828f6 Mon Sep 17 00:00:00 2001 From: Benson Ma Date: Fri, 14 Jul 2023 18:21:49 -0700 Subject: [PATCH] Fix Python script error introduced in D47385306 Summary: - Update Python template to resolve the runtime error introduced in D47385306 Reviewed By: sryap Differential Revision: D47484716 fbshipit-source-id: ca7be407b7db3b3e0cebc0556928f54498f0d271 --- ..._embedding_codegen_lookup_invoker.template | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/fbgemm_gpu/codegen/split_embedding_codegen_lookup_invoker.template b/fbgemm_gpu/codegen/split_embedding_codegen_lookup_invoker.template index 874fc04ed..5af6e320f 100644 --- a/fbgemm_gpu/codegen/split_embedding_codegen_lookup_invoker.template +++ b/fbgemm_gpu/codegen/split_embedding_codegen_lookup_invoker.template @@ -34,11 +34,6 @@ torch.ops.load_library("//deeplearning/fbgemm/fbgemm_gpu:embedding_inplace_updat {%- endif %} -{%- if is_experimental_optimizer %} -_{{ optimizer }}_first_invocation = True -{%- endif %} - - def invoke( common_args: CommonArgs, optimizer_args: OptimizerArgs, @@ -65,17 +60,14 @@ def invoke( {%- endif %} ) -> torch.Tensor: {%- if is_experimental_optimizer %} - global _{{ optimizer }}_first_invocation - if _{{ optimizer }}_first_invocation: - warnings.warn( - f"""\033[93m - [FBGEMM_GPU] NOTE: The training optimizer '{{ optimizer }}' is marked as - EXPERIMENTAL and thus not optimized, in order to reduce code compilation - times and build sizes! - \033[0m""", - RuntimeWarning, - ) - _{{ optimizer }}_first_invocation = False + # By design, the warning only shows up once + warnings.warn( + f"""\033[93m + [FBGEMM_GPU] NOTE: The training optimizer '{{ optimizer }}' is marked as + EXPERIMENTAL and thus not optimized, in order to reduce code compilation + times and build sizes! + \033[0m""" + ) {%- endif %} {%- if has_cpu_support %}