-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Assert atmos to not have UnionAll types
- Loading branch information
1 parent
06a3da7
commit a716d02
Showing
3 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
""" | ||
has_DataType_or_UnionAll(::Any) | ||
Returns a Bool (and prints warnings if) the given | ||
data structure has an instance of `DataType` or | ||
`UnionAll` type, both of which are not `isbits` | ||
and therefore cannot be broadcasted through a | ||
gpu kernel. | ||
""" | ||
function has_DataType_or_UnionAll(obj, name, pc = ()) | ||
for pn in propertynames(obj) | ||
prop = getproperty(obj, pn) | ||
pc_full = (pc..., ".", pn) | ||
pc_string = name * string(join(pc_full)) | ||
if prop isa DataType | ||
@warn "$pc_string::$(typeof(prop)) is a DataType" | ||
return true | ||
elseif prop isa UnionAll | ||
@warn "$pc_string::$(typeof(prop)) is a UnionAll" | ||
return true | ||
else | ||
has_DataType_or_UnionAll(prop, name, pc_full) | ||
end | ||
end | ||
return false | ||
end | ||
macro has_DataType_or_UnionAll(obj) | ||
return :(has_DataType_or_UnionAll($(esc(obj)), $(string(obj)))) | ||
end |