6
1
In review
Synced today
What it does
The full Triton Ascend example of the ReLU element by element operator. The standard mode for demonstrating vector 's element by element operation: 1D split, mask border processing, staggering. The code structure of this example can be consulted when generating the elementwise type operator.
Skill profile
Keep exploring
More options in Dev Tools.
Claude Code · Codex · OpenClaw
Python
Updated 7/31/2026
Agent compatibility
Compatibility has not been reviewed for this listing yet. Check the publisher documentation before installing.
Installation
npx skills add https://github.com/xchang1121/op-autoresearch --skill triton-ascend-example-reluReview source code and installation permissions before adding third-party tools to an agent.
triton-ascend-example-relu is organized in the Dev Tools category. Compare its source, install method, and compatibility before adding it to your workflow.
Third-party agent tools may access source code, credentials, or browser sessions. Read the source documentation and use the minimum permissions needed.
npx skills add https://github.com/xchang1121/op-autoresearch --skill triton-ascend-example-reluSKILL.md
---
name: triton-ascend-example-relu
description: "The full Triton Ascend example of the ReLU element by element operator. The standard mode for demonstrating vector 's element by element operation: 1D split, mask border processing, staggering. The code structure of this example can be consulted when generating the elementwise type operator."
category: example
version: "1.0.0"
metadata:
backend: ascend
dsl: triton_ascend
hardware: "Atlas A2, Atlas A3"
operator_type: "elementwise"
framework: torch
---
# ReLU - Triton Ascend
```python
import torch
import triton
import triton.language as tl
@triton.jit
def relu_kernel(
x_ptr, y_ptr,
n_elements,
BLOCK_SIZE: tl.constexpr, CORE_NUM: tl.constexpr,
):
pid = tl.program_id(0)
num_blocks = tl.cdiv(n_elements, BLOCK_SIZE)
for block_id in range(pid, num_blocks, CORE_NUM):
offsets = block_id * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)
mask = offsets < n_elements
x = tl.load(x_ptr + offsets, mask=mask, other=0.0)
y = tl.maximum(x, 0.0)
tl.store(y_ptr + offsets, y, mask=mask)
class ModelNew(torch.nn.Module):
def __init__(self):
super().__init__()
try:
import torch
import triton
device = torch.npu.current_device()
properties = triton.runtime.driver.active.utils.get_device_properties(device)
self.VEC_CORE_NUM = properties.get("num_vectorcore", 40)
except:
self.VEC_CORE_NUM = 40
def forward(self, x):
if not x.is_contiguous():
x = x.contiguous()
y = torch.empty_like(x)
n_elements = x.numel()
BLOCK_SIZE = 1024
grid = (self.VEC_CORE_NUM,)
relu_kernel[grid](x, y, n_elements, BLOCK_SIZE=BLOCK_SIZE, CORE_NUM=self.VEC_CORE_NUM)
return y
```
skill
mattpocock
A tool that automates setting up Husky pre-commit hooks with lint-staged, Prettier formatting, type checking, and tests in a code repository.