Skip to content

Commit

Permalink
Add EnzymeTypeTreeToString for debugging purposes (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
bytesnake authored and wsmoses committed May 17, 2021
1 parent ea6916f commit 26e5c62
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 9 additions & 1 deletion enzyme/Enzyme/CApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,4 +333,12 @@ void EnzymeTypeTreeShiftIndiciesEq(CTypeTreeRef CTT, const char *datalayout,
*(TypeTree *)CTT =
((TypeTree *)CTT)->ShiftIndices(DL, offset, maxSize, addOffset);
}
}
const char *EnzymeTypeTreeToString(CTypeTreeRef src) {
std::string tmp = ((TypeTree *)src)->str();
char *cstr = new char[tmp.length() + 1];
std::strcpy(cstr, tmp.c_str());

return cstr;
}
void EnzymeTypeTreeToStringFree(const char *cstr) { delete[] cstr; }
}
4 changes: 3 additions & 1 deletion enzyme/Enzyme/CApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ void EnzymeTypeTreeOnlyEq(CTypeTreeRef dst, int64_t x);
void EnzymeTypeTreeShiftIndiciesEq(CTypeTreeRef dst, const char *datalayout,
int64_t offset, int64_t maxSize,
uint64_t addOffset);
const char *EnzymeTypeTreeToString(CTypeTreeRef src);
void EnzymeTypeTreeToStringFree(const char *cstr);

struct CFnTypeInfo {
/// Types of arguments, assumed of size len(Arguments)
Expand Down Expand Up @@ -146,4 +148,4 @@ LLVMTypeRef EnzymeExtractTapeTypeFromAugmentation(EnzymeAugmentedReturnPtr ret);
}
#endif

#endif
#endif

0 comments on commit 26e5c62

Please sign in to comment.