diff --git a/bin/triton-tensor-layout.cpp b/bin/triton-tensor-layout.cpp index 7b82fad6cce2..b70abe322bf3 100644 --- a/bin/triton-tensor-layout.cpp +++ b/bin/triton-tensor-layout.cpp @@ -39,29 +39,32 @@ using namespace mlir; // CLI options //===--------------------------------------------------------------------===// -cl::OptionCategory PrinterCategory("Available Print Options", - "Options for the tensor layout printing."); +static cl::OptionCategory &getPrinterCategory() { + static cl::OptionCategory PrinterCategory( + "Available Print Options", "Options for the tensor layout printing."); + return PrinterCategory; +} static cl::opt InputFile( "i", cl::desc("File that contains the tensor data layout attributes"), - cl::init(""), cl::value_desc("filename"), cl::cat(PrinterCategory)); + cl::init(""), cl::value_desc("filename"), cl::cat(getPrinterCategory())); static cl::opt OutputFile("o", cl::desc("Output file to write the layout into"), cl::init(""), cl::value_desc("filename"), - cl::cat(PrinterCategory)); + cl::cat(getPrinterCategory())); static cl::opt DataLayoutStr("l", cl::desc("Tensor data layout attribute in string"), cl::value_desc("layout-string"), cl::init(""), - cl::cat(PrinterCategory)); + cl::cat(getPrinterCategory())); static cl::list AliasName("alias-names", cl::desc("A list of alias names (separated by comma) of the " "layout attributes in the input file"), cl::value_desc("name1,name2,name3,..."), cl::CommaSeparated, - cl::ZeroOrMore, cl::cat(PrinterCategory)); + cl::ZeroOrMore, cl::cat(getPrinterCategory())); static cl::opt UseHWPointOfView( "use-hw-view", @@ -69,11 +72,11 @@ static cl::opt UseHWPointOfView( "Print the layout in hardware point of view. This means the output is " "from the warp's perspective. Otherwise, the output is from the " "tensor's perspective (e.g., each element maps to xxx thread)."), - cl::init(false), cl::cat(PrinterCategory)); + cl::init(false), cl::cat(getPrinterCategory())); static cl::opt TensorStr( "t", cl::desc("Tensor shape and element type (e.g., tensor<2x2xf32>)"), - cl::init(""), cl::value_desc("tensor-type"), cl::cat(PrinterCategory)); + cl::init(""), cl::value_desc("tensor-type"), cl::cat(getPrinterCategory())); //===--------------------------------------------------------------------===// // Helper functions @@ -180,7 +183,7 @@ static LogicalResult printLayoutFromString(MLIRContext *context, //===--------------------------------------------------------------------===// int main(int argc, char **argv) { - cl::HideUnrelatedOptions(PrinterCategory); + cl::HideUnrelatedOptions(getPrinterCategory()); cl::ParseCommandLineOptions(argc, argv, "tensor layout printer\n"); DialectRegistry registry;