blob: 8e3b4e6f73cc054b96b9099d81455fc7080b0408 [file] [log] [blame]
#include <string>
#include "third_party/absl/status/status.h"
#include "third_party/absl/status/statusor.h"
#include "third_party/llvm/llvm-project/mlir/include/mlir/IR/Attributes.h"
#include "third_party/llvm/llvm-project/mlir/include/mlir/IR/BuiltinAttributes.h"
#include "third_party/llvm/llvm-project/mlir/include/mlir/IR/Operation.h"
namespace xla::mosaic {
absl::StatusOr<std::string> CustomCallKernelName(mlir::Operation* op) {
mlir::Attribute kernel_name_attr = op->getAttr("kernel_name");
auto kernel_name = kernel_name_attr.dyn_cast_or_null<mlir::StringAttr>();
if (!kernel_name) {
return absl::InvalidArgumentError("Cannot find kernel_name");
}
return kernel_name.str();
}
} // namespace xla::mosaic