You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] Identity comparison ('is') on JSON data strings in examples/44 multi-gemm codegen #3910
Describe the bug
In examples/44_multi_gemm_ir_and_codegen, configuration data structures are parsed from JSON inputs via json.load(infile). The codegen scripts then perform is identity comparisons against string literals to check formatting/types (e.g. self.fuse_gemm_info[i]['B_format'] is 'Row').
Under Python (CPython 3.8+), using is with string literals produces a SyntaxWarning: "is" with a literal. Did you mean "=="?. More critically, strings decoded by json.load / json.loads are dynamically allocated and fail identity comparison with interned string literals, causing layout branches to never be entered.
Steps/Code to reproduce bug
importjsond=json.loads('{"B_format": "Row"}')
print(d['B_format'] is'Row') # Evaluates to False, emitting SyntaxWarningprint(d['B_format'] =='Row') # Evaluates to True
Expected behavior
Strings parsed from JSON should be compared for equality using ==.
Environment details:
Tested on Python 3.10 / 3.12, current main (HEAD: dc6ae46)
Proposed Solution
Replace is with == across examples/44_multi_gemm_ir_and_codegen/ir_gen/:
--- a/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_turing_and_volta.py+++ b/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_turing_and_volta.py@@ -81,3 +81,3 @@ class GeneratorTuringAndVolta(Generator):
for i in range(len(self.fuse_gemm_info)):
- if self.fuse_gemm_info[i]['B_format'] is 'Row':+ if self.fuse_gemm_info[i]['B_format'] == 'Row':
Activity