@@ -76,12 +76,17 @@ def __init__(
7676 super ().__init__ (function_type , * args , loc = loc , ip = ip , ** kwargs )
7777
7878 if isinstance (sym_name , str ):
79- sym_name = StringAttr .get (str ( sym_name ) )
80- if sym_name is not None :
79+ self . attributes [ self . SYM_NAME_ATTR_NAME ] = StringAttr .get (sym_name )
80+ elif isinstance ( sym_name , StringAttr ) :
8181 self .attributes [self .SYM_NAME_ATTR_NAME ] = sym_name
82+ else :
83+ raise ValueError (
84+ "sym_name must be a string or a StringAttr"
85+ )
8286
8387 if kernel :
8488 self .attributes [self .KERNEL_ATTR_NAME ] = UnitAttr .get ()
89+
8590 if known_block_size is not None :
8691 if isinstance (known_block_size , Sequence ):
8792 self .attributes [self .KNOWN_BLOCK_SIZE_ATTR_NAME ] = (
@@ -119,6 +124,9 @@ def is_kernel(self) -> bool:
119124 return self .KERNEL_ATTR_NAME in self .attributes
120125
121126 def add_entry_block (self ) -> Block :
127+ if len (self .body .blocks ) > 0 :
128+ raise RuntimeError (f"Entry block already exists for { self .name .value } " )
129+
122130 function_type = self .function_type .value
123131 return self .body .blocks .append (
124132 * function_type .inputs ,
@@ -127,6 +135,11 @@ def add_entry_block(self) -> Block:
127135
128136 @property
129137 def entry_block (self ) -> Block :
138+ if len (self .body .blocks ) == 0 :
139+ raise RuntimeError (
140+ f"Entry block does not exist for { self .name .value } ." +
141+ " Do you need to call the add_entry_block() method on this GPUFuncOp?"
142+ )
130143 return self .body .blocks [0 ]
131144
132145 @property
0 commit comments