Skip to content

Commit efe9608

Browse files
committed
Merge remote-tracking branch 'origin/develop' into migraphx_attention
2 parents 9882402 + aa19b50 commit efe9608

34 files changed

Lines changed: 2196 additions & 97 deletions
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
name: Codecov Report
2+
3+
on:
4+
schedule:
5+
# Runs every Monday at 09:00 UTC.
6+
# The job skips odd ISO weeks so the effective cadence is biweekly.
7+
- cron: '0 9 * * 1'
8+
workflow_dispatch:
9+
10+
jobs:
11+
codecov-teams-report:
12+
name: Codecov coverage report to Teams
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 10
15+
16+
permissions:
17+
contents: read
18+
19+
steps:
20+
- name: Biweekly gate
21+
id: gate
22+
run: |
23+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
24+
echo "skip=false" >> "$GITHUB_OUTPUT"
25+
echo "Manual trigger — always run."
26+
else
27+
WEEK=$(date +%V)
28+
if [ $((10#$WEEK % 2)) -eq 0 ]; then
29+
echo "skip=false" >> "$GITHUB_OUTPUT"
30+
echo "Even ISO week ($WEEK) — running."
31+
else
32+
echo "skip=true" >> "$GITHUB_OUTPUT"
33+
echo "Odd ISO week ($WEEK) — skipping."
34+
fi
35+
fi
36+
37+
- name: Fetch Codecov data and notify Teams
38+
if: steps.gate.outputs.skip != 'true'
39+
env:
40+
MLIR_TEAM_CONVERSATION: ${{ secrets.MLIR_TEAM_CONVERSATION }}
41+
MLIR_CI_CHANNEL: ${{ secrets.MLIR_CI_CHANNEL }}
42+
run: |
43+
set -euo pipefail
44+
45+
OWNER="ROCm"
46+
REPO="rocMLIR"
47+
API="https://api.codecov.io/api/v2/github/${OWNER}/repos/${REPO}"
48+
49+
# ── 1. Fetch repo-level data from Codecov ─────────────────
50+
echo "::group::Repository coverage"
51+
repo_json=$(curl -sf "$API/") \
52+
|| { echo "::error::Failed to fetch repo data from Codecov API"; exit 1; }
53+
echo "$repo_json" | jq .
54+
echo "::endgroup::"
55+
56+
# ── 2. Parse overall totals ─────────────────────────────────
57+
coverage=$(echo "$repo_json" | jq -r '.totals.coverage // "N/A"')
58+
hits=$(echo "$repo_json" | jq -r '.totals.hits // "N/A"')
59+
lines=$(echo "$repo_json" | jq -r '.totals.lines // "N/A"')
60+
misses=$(echo "$repo_json" | jq -r '.totals.misses // "N/A"')
61+
branches=$(echo "$repo_json" | jq -r '.totals.branches // "N/A"')
62+
echo "Overall line coverage: ${coverage}%"
63+
64+
# ── 3. Determine colour for the headline number ─────────────
65+
cov_color=$(echo "$coverage" | jq -Rr '
66+
(tonumber? // 0) as $v |
67+
if $v >= 70 then "Good"
68+
elif $v >= 50 then "Warning"
69+
else "Attention"
70+
end')
71+
72+
TIMESTAMP=$(date -u '+%Y-%m-%d %H:%M UTC')
73+
CODECOV_URL="https://app.codecov.io/gh/${OWNER}/${REPO}"
74+
RUN_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
75+
76+
# ── 4. Assemble the Adaptive Card ───────────────────────────
77+
payload=$(jq -n \
78+
--arg cov "$coverage" \
79+
--arg cov_color "$cov_color" \
80+
--arg hits "$hits" \
81+
--arg lines "$lines" \
82+
--arg misses "$misses" \
83+
--arg branches "$branches" \
84+
--arg ts "$TIMESTAMP" \
85+
--arg cov_url "$CODECOV_URL" \
86+
--arg run_url "$RUN_URL" \
87+
'{
88+
"attachments": [{
89+
"contentType": "application/vnd.microsoft.card.adaptive",
90+
"content": {
91+
"type": "AdaptiveCard",
92+
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
93+
"version": "1.5",
94+
"body": [
95+
{
96+
"type": "TextBlock",
97+
"text": "Codecov Report 📊",
98+
"weight": "bolder",
99+
"size": "extraLarge",
100+
"separator": true
101+
},
102+
{
103+
"type": "TextBlock",
104+
"text": "rocMLIR — \($ts)",
105+
"isSubtle": true
106+
},
107+
{
108+
"type": "ColumnSet",
109+
"columns": [
110+
{
111+
"type": "Column",
112+
"width": "auto",
113+
"items": [{
114+
"type": "TextBlock",
115+
"text": "\($cov)%",
116+
"size": "extraLarge",
117+
"weight": "bolder",
118+
"color": $cov_color
119+
}]
120+
},
121+
{
122+
"type": "Column",
123+
"width": "stretch",
124+
"items": [
125+
{
126+
"type": "TextBlock",
127+
"text": "Overall Line Coverage",
128+
"weight": "bolder"
129+
},
130+
{
131+
"type": "FactSet",
132+
"facts": [
133+
{"title": "Lines", "value": $lines},
134+
{"title": "Hits", "value": $hits},
135+
{"title": "Misses", "value": $misses},
136+
{"title": "Branches", "value": $branches}
137+
]
138+
}
139+
]
140+
}
141+
]
142+
},
143+
{
144+
"type": "TextBlock",
145+
"text": "Generated: \($ts)",
146+
"size": "small",
147+
"isSubtle": true,
148+
"spacing": "medium"
149+
}
150+
],
151+
"actions": [
152+
{"type": "Action.OpenUrl", "url": $cov_url, "title": "Open Codecov Dashboard 📈"},
153+
{"type": "Action.OpenUrl", "url": $run_url, "title": "View Workflow Run 🔗"}
154+
]
155+
}
156+
}]
157+
}')
158+
159+
echo "::group::Teams payload"
160+
echo "$payload" | jq .
161+
echo "::endgroup::"
162+
163+
# ── 5. POST to each configured Teams webhook ────────────────
164+
send_to_teams() {
165+
local url="$1" label="$2"
166+
if [ -z "$url" ]; then
167+
echo "Skipping ${label} (URL not set)."
168+
return 0
169+
fi
170+
resp=$(curl -s -w '\n%{http_code}' -X POST "$url" \
171+
-H 'Content-Type: application/json; charset=utf-8' \
172+
-d "$payload")
173+
http_code=$(echo "$resp" | tail -1)
174+
body=$(echo "$resp" | sed '$d')
175+
echo "Teams webhook (${label}): HTTP ${http_code}${body:+ body=${body}}"
176+
if [ "$http_code" != "200" ] && [ "$http_code" != "202" ]; then
177+
echo "::warning::Teams notification (${label}) may have failed (expected 200/202, got ${http_code})"
178+
return 1
179+
fi
180+
}
181+
182+
send_to_teams "$MLIR_TEAM_CONVERSATION" "MLIR_TEAM_CONVERSATION"
183+
send_to_teams "$MLIR_CI_CHANNEL" "MLIR_CI_CHANNEL"
184+
echo "Done."

external/mlir-hal/lib/Conversion/MHALToCPU/MHALToCPU.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ struct LaunchRewritePattern : public OpRewritePattern<mhal::LaunchOp> {
5959
if (auto func = getCalledFunc(op)) {
6060
// Replace the original `async.execute` with a call to outlined
6161
// function.
62-
rw.create<func::CallOp>(loc, *func, op.getArgOperands());
62+
func::CallOp::create(rw, loc, *func, op.getArgOperands());
6363

6464
Value empty;
6565
op->replaceAllUsesWith(ValueRange(empty));

external/mlir-hal/lib/Conversion/MHALToGPU/MHALToGPU.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ struct LaunchRewritePattern : public OpRewritePattern<mhal::LaunchOp> {
8787

8888
Value makeWait(OpBuilder b, Location loc, ArrayRef<Value> deps = {}) const {
8989
auto tokenType = b.getType<gpu::AsyncTokenType>();
90-
return b.create<gpu::WaitOp>(loc, tokenType, deps).getAsyncToken();
90+
return gpu::WaitOp::create(b, loc, tokenType, deps).getAsyncToken();
9191
}
9292

9393
template <typename T> bool isOnDevice(const T &oprUsers) const {
@@ -121,17 +121,17 @@ struct LaunchRewritePattern : public OpRewritePattern<mhal::LaunchOp> {
121121

122122
Value allocWait = makeWait(bAlloc, loc);
123123
Type gpuMemType = opr.getType();
124-
auto dst = bAlloc.create<gpu::AllocOp>(loc, gpuMemType, tokenType,
125-
ValueRange{allocWait}, ValueRange{},
126-
ValueRange{});
124+
auto dst =
125+
gpu::AllocOp::create(bAlloc, loc, gpuMemType, tokenType,
126+
ValueRange{allocWait}, ValueRange{}, ValueRange{});
127127
Value dstMem = dst.getResult(0);
128128
Value dstToken = dst.getResult(1);
129129

130130
auto makeCopy = [&]() {
131131
// always copy to device, even if it's read_access only
132132
// this way we initialize with whatever was provided by the user
133-
auto memcpyToken = b.create<gpu::MemcpyOp>(
134-
loc, tokenType, ValueRange{dstToken}, dstMem, opr);
133+
auto memcpyToken = gpu::MemcpyOp::create(
134+
b, loc, tokenType, ValueRange{dstToken}, dstMem, opr);
135135
dstToken = memcpyToken.getResult(0);
136136
if (writeAccess) {
137137
// copy from device
@@ -191,8 +191,8 @@ struct LaunchRewritePattern : public OpRewritePattern<mhal::LaunchOp> {
191191
auto binaryOp = module.lookupSymbol<gpu::BinaryOp>(binaryName);
192192
if (!binaryOp) {
193193
OpBuilder b(ctx);
194-
binaryOp = b.create<gpu::BinaryOp>(floc, binaryName, nullptr,
195-
ArrayRef<Attribute>({binary}));
194+
binaryOp = gpu::BinaryOp::create(b, floc, binaryName, nullptr,
195+
ArrayRef<Attribute>({binary}));
196196

197197
SymbolTable symbolTable(module);
198198
symbolTable.insert(binaryOp);
@@ -250,8 +250,8 @@ struct LaunchRewritePattern : public OpRewritePattern<mhal::LaunchOp> {
250250
}
251251

252252
// Make gpu.launch_func
253-
auto gpuLaunchOp = rw.create<gpu::LaunchFuncOp>(
254-
loc,
253+
auto gpuLaunchOp = gpu::LaunchFuncOp::create(
254+
rw, loc,
255255
SymbolRefAttr::get(getContext(), binaryName,
256256
{FlatSymbolRefAttr::get(getContext(), funcName)}),
257257
gpu::KernelDim3{gridSizeIdx, oneIdx, oneIdx},
@@ -266,8 +266,8 @@ struct LaunchRewritePattern : public OpRewritePattern<mhal::LaunchOp> {
266266
auto dst = operands[diff + pair.index()];
267267
if (gpuMem.getDefiningOp<memref::AllocOp>())
268268
std::swap(gpuMem, dst);
269-
auto memcpy = rw.create<gpu::MemcpyOp>(loc, tokenType,
270-
ValueRange{token}, dst, gpuMem);
269+
auto memcpy = gpu::MemcpyOp::create(rw, loc, tokenType,
270+
ValueRange{token}, dst, gpuMem);
271271
tokens.push_back(memcpy.getResult(0));
272272
}
273273
}
@@ -304,7 +304,7 @@ struct AwaitRewritePattern : public OpRewritePattern<mhal::AwaitOp> {
304304
if (input.getType() == tokenType) {
305305
// mhal.await with token type should never have a result type
306306
assert(op.getResultType() == std::nullopt);
307-
rw.create<gpu::WaitOp>(op.getLoc(), Type(), input);
307+
gpu::WaitOp::create(rw, op.getLoc(), Type(), input);
308308
rw.eraseOp(op);
309309
return success();
310310
}

external/mlir-hal/lib/Dialect/MHAL/Transforms/EmulateNarrowType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ void mlir::mhal::populateMHalNarrowTypeEmulationConversions(
117117
Value input = inputs.front();
118118
if (input.getType() == illegalType)
119119
return input;
120-
return builder.create<UnrealizedConversionCastOp>(loc, illegalType, input)
120+
return UnrealizedConversionCastOp::create(builder, loc, illegalType, input)
121121
.getResult(0);
122122
};
123123
typeConverter.addSourceMaterialization(materializer);

external/mlir-hal/lib/Dialect/MHAL/Transforms/Prefill.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ void MHALPrefillPass::insertPrefillOps(OpBuilder &builder,
7979
auto elementType = type.getElementType();
8080
builder.setInsertionPoint(launchOp->getBlock(),
8181
--Block::iterator(launchOp));
82-
auto initConstant = builder.create<arith::ConstantOp>(loc, elementType,
83-
attr.getInitValue());
84-
builder.create<gpu::MemsetOp>(loc, mlir::Type{}, mlir::ValueRange{}, arg,
85-
initConstant);
82+
auto initConstant = arith::ConstantOp::create(builder, loc, elementType,
83+
attr.getInitValue());
84+
gpu::MemsetOp::create(builder, loc, mlir::Type{}, mlir::ValueRange{}, arg,
85+
initConstant);
8686
}
8787
}
8888

mlir/include/mlir/Dialect/MIGraphX/IR/MIGraphX.td

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,12 @@ def MIGraphX_ClipOp : MIGraphX_Op<"clip", [Elementwise]>,
111111

112112
// Note: when lowering to kernel calls, MIGraphX represents booleans as i8.
113113
// Keep that logic here.
114-
def MIGraphX_WhereOp : MIGraphX_Op<"where", [Elementwise]>,
115-
Arguments<(ins MIXRShapedOf<[I8, SI8, UI8]>:$cond,
116-
AnyMIXRShaped:$inA, AnyMIXRShaped:$inB)>,
117-
Results<(outs AnyMIXRShaped:$output)> {
114+
def MIGraphX_WhereOp
115+
: MIGraphX_Op<"where", [Elementwise, AllElementTypesMatch<["inA", "inB", "output"]>,
116+
AllShapesMatch<["inA", "inB", "output", "cond"]>]>,
117+
Arguments<(ins MIXRShapedOf<[I8, SI8, UI8]>:$cond, AnyMIXRShaped:$inA,
118+
AnyMIXRShaped:$inB)>,
119+
Results<(outs AnyMIXRShaped:$output)> {
118120
let summary = "Elementwise select";
119121
let description = [{
120122
output[x] = cond[x] ? inA[x] : inB[x]
@@ -158,6 +160,8 @@ def MIGraphX_ErfOp :
158160
let description = [{
159161
compute gauss error function
160162
}];
163+
let arguments = (ins MIXRShapedOf<[AnyFloat]>:$inA);
164+
let results = (outs MIXRShapedOf<[AnyFloat]>:$output);
161165
}
162166
def MIGraphX_ExpOp :
163167
MIGraphX_ElementwiseUnaryOp<"exp">;
@@ -180,6 +184,7 @@ def MIGraphX_SigmoidOp :
180184
let description = [{
181185
Sigmoid function, aka 1 / (1 + exp(-x)).
182186
}];
187+
let hasVerifier = 1;
183188
}
184189
def MIGraphX_SqrtOp :
185190
MIGraphX_ElementwiseUnaryOp<"sqrt">;

mlir/include/mlir/Dialect/Rock/Passes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ namespace rock {
4242
#define GEN_PASS_DECL_ROCKVIEWTOTRANSFORMPASS
4343
#define GEN_PASS_DECL_ROCKDETECTFLASHDECODINGPASS
4444
#define GEN_PASS_DECL_ROCKLOWERREDUCEPASS
45+
#define GEN_PASS_DECL_ROCKREMOVEREDUNDANTCASTSPASS
4546
#define GEN_PASS_DECL_ROCKPREPARELLVMPASS
4647
#define GEN_PASS_DECL_ROCKCHECKRESIDENCYPASS
4748
#define GEN_PASS_DECL_ROCKVECTORIZEFUSIONSPASS

mlir/include/mlir/Dialect/Rock/Passes.td

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,20 @@ def RockLowerReducePass : Pass<"rock-lower-reduce", "::mlir::func::FuncOp"> {
182182
let dependentDialects = ["rock::RockDialect", "func::FuncDialect", "gpu::GPUDialect"];
183183
}
184184

185+
def RockRemoveRedundantCastsPass
186+
: Pass<"rock-remove-redundant-casts", "::mlir::LLVM::LLVMFuncOp"> {
187+
let summary = "Remove redundant fptrunc/fpext pairs through buffers at LLVM "
188+
"dialect level";
189+
let description = [{
190+
Detects patterns at the LLVM dialect level where wider float values are
191+
truncated (llvm.fptrunc) to a narrower type, stored to a buffer, then loaded
192+
and extended (llvm.fpext) back to the original wider type. This pass
193+
redirects the loads to read the wide values directly, eliminating the
194+
fpext and preserving precision.
195+
}];
196+
let dependentDialects = ["LLVM::LLVMDialect"];
197+
}
198+
185199
def RockPrepareLLVMPass : Pass<"rock-prepare-llvm", "::mlir::LLVM::LLVMFuncOp"> {
186200
let summary = "prepare the generated code for llvm";
187201
let dependentDialects = ["ROCDL::ROCDLDialect"];

0 commit comments

Comments
 (0)