mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
avoid to declare an unknown bound array without any element (#156543)
Fixes #153180 Pull Request resolved: https://github.com/pytorch/pytorch/pull/156543 Approved by: https://github.com/jansel Co-authored-by: Xu Han <xu.han@outlook.com>
This commit is contained in:
committed by
PyTorch MergeBot
parent
4237ee3c33
commit
c60327ba74
@ -1503,6 +1503,13 @@ class CppWrapperCpu(PythonWrapperCodegen):
|
|||||||
# This is why writeline needs to explicitly passed in as a parameter.
|
# This is why writeline needs to explicitly passed in as a parameter.
|
||||||
var = f"int_array_{next(self.int_array_id)}"
|
var = f"int_array_{next(self.int_array_id)}"
|
||||||
ctype = "int64_t"
|
ctype = "int64_t"
|
||||||
|
if int_array == "{}":
|
||||||
|
# An array of unknown bound cannot be initialized with {}.
|
||||||
|
if known_statically:
|
||||||
|
writeline(f"static constexpr {ctype} *{var}=nullptr;")
|
||||||
|
else:
|
||||||
|
writeline(f"const {ctype} *{var}=nullptr;")
|
||||||
|
else:
|
||||||
if var not in self.declared_int_array_vars:
|
if var not in self.declared_int_array_vars:
|
||||||
self.declared_int_array_vars.add(var)
|
self.declared_int_array_vars.add(var)
|
||||||
if known_statically:
|
if known_statically:
|
||||||
|
Reference in New Issue
Block a user