Skip to content

Commit d85bf8f

Browse files
yzhang93geomin12
authored andcommitted
There are some attribute changes upstream: - TOSA: llvm/llvm-project#128115 - NVPTX: llvm/llvm-project#127736 --------- Signed-off-by: yzhang93 <zhyuhang88@gmail.com> Signed-off-by: geomin12 <geomin12@amd.com>
1 parent 3d05691 commit d85bf8f

File tree

3 files changed

+8
-19
lines changed

3 files changed

+8
-19
lines changed

compiler/plugins/target/CUDA/CUDATarget.cpp

+5-15
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "llvm/Passes/StandardInstrumentations.h"
3333
#include "llvm/Support/FileSystem.h"
3434
#include "llvm/Support/FileUtilities.h"
35+
#include "llvm/Support/FormatVariadic.h"
3536
#include "llvm/Support/MemoryBuffer.h"
3637
#include "llvm/Support/Program.h"
3738
#include "llvm/Support/TargetSelect.h"
@@ -530,18 +531,6 @@ class CUDATargetBackend final : public TargetBackend {
530531
// Sanitize the function name as PTX has strict requirements.
531532
llvmFunc->setName(sanitizeSymbolName(funcOp.getName()));
532533

533-
auto *annotations =
534-
llvmModule->getOrInsertNamedMetadata("nvvm.annotations");
535-
auto setMetadataValueI32 = [&](StringRef name, int value) {
536-
llvm::Metadata *llvmMetadata[] = {
537-
llvm::ValueAsMetadata::get(llvmFunc),
538-
llvm::MDString::get(llvmModule->getContext(), name),
539-
llvm::ValueAsMetadata::get(llvm::ConstantInt::get(
540-
llvm::Type::getInt32Ty(llvmModule->getContext()), value))};
541-
annotations->addOperand(
542-
llvm::MDNode::get(llvmModule->getContext(), llvmMetadata));
543-
};
544-
545534
// Mark the entry point as a kernel.
546535
llvmFunc->setCallingConv(llvm::CallingConv::PTX_Kernel);
547536

@@ -560,9 +549,10 @@ class CUDATargetBackend final : public TargetBackend {
560549
maxWorkgroupSize[0] = std::max(maxWorkgroupSize[0], workgroupSize[0]);
561550
maxWorkgroupSize[1] = std::max(maxWorkgroupSize[1], workgroupSize[1]);
562551
maxWorkgroupSize[2] = std::max(maxWorkgroupSize[2], workgroupSize[2]);
563-
setMetadataValueI32("maxntidx", workgroupSize[0]);
564-
setMetadataValueI32("maxntidy", workgroupSize[1]);
565-
setMetadataValueI32("maxntidz", workgroupSize[2]);
552+
std::string maxntid = llvm::formatv(
553+
"{0},{1},{2}", llvm::utostr(workgroupSize[0]),
554+
llvm::utostr(workgroupSize[1]), llvm::utostr(workgroupSize[2]));
555+
llvmFunc->addFnAttr("nvvm.maxntid", maxntid);
566556
}
567557
}
568558

tests/e2e/tosa_ops/transpose.mlir

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
func.func @test_transpose() {
22
%0 = arith.constant dense<[[[0, 1, 2], [3, 4, 5]]]> : tensor<1x2x3xi32>
3-
%1 = arith.constant dense<[1, 2, 0]> : tensor<3xi32>
4-
%2 = tosa.transpose %0, %1 : (tensor<1x2x3xi32>, tensor<3xi32>) -> (tensor<2x3x1xi32>)
5-
check.expect_eq_const(%2, dense<[[[0], [1], [2]], [[3], [4], [5]]]> : tensor<2x3x1xi32>) : tensor<2x3x1xi32>
3+
%1 = tosa.transpose %0 { perms = array<i32: 1, 2, 0> }: (tensor<1x2x3xi32>) -> (tensor<2x3x1xi32>)
4+
check.expect_eq_const(%1, dense<[[[0], [1], [2]], [[3], [4], [5]]]> : tensor<2x3x1xi32>) : tensor<2x3x1xi32>
65
return
76
}

third_party/llvm-project

Submodule llvm-project updated 838 files

0 commit comments

Comments
 (0)