pypto-case-loss-crossentropy

Implement and evaluate a CrossEntropyLoss kernel with per-sample softmax and gather in Pypto.

6|1|Updated Apr 19, 2026
One-click install
npx skills add https://github.com/xchang1121/AutoResearch-CC-hook --skill pypto-case-loss-crossentropy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pypto-case-loss-crossentropy
Source: https://github.com/xchang1121/AutoResearch-CC-hook/tree/main/skills/pypto/cases/pypto-case-loss-crossentropy
Command: npx skills add https://github.com/xchang1121/AutoResearch-CC-hook --skill pypto-case-loss-crossentropy

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

模式 D 示例:Loss — CrossEntropyLoss,展示多输入 kernel、两段 tile、softmax+gather+sum、标量输出

Core Features & Use Cases

  • 两阶段 tile 配置:不同阶段用不同 tile 设置
  • per-sample softmax + gather:按 targets 的索引选取对数概率并求和
  • 标量输出:最终输出一个标量损失用于回传

Quick Start

Follow this pattern to instantiate a cross-entropy loss kernel and run it on a batch of predictions and targets to obtain the averaged loss.

Frequently Asked Questions about pypto-case-loss-crossentropy

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement a cross-entropy loss kernel with multi-input setups in Pypto?

A cross-entropy loss kernel in Pypto handles multi-input setups by applying per-sample softmax, gathering log probabilities by target indices, and reducing the batch to output a scalar loss. It uses two-phase tiling to configure different tile settings across execution stages.

What is two-phase tile configuration and when do I need it for loss calculations?

Two-phase tile configuration allows different tile settings across execution stages of a cross-entropy loss kernel. You need it when running multi-input setups in Pypto to optimize per-sample softmax and batch reduction operations for scalar loss output.

How do I compute per-sample softmax and gather target indices for cross-entropy loss?

You compute per-sample softmax and gather target indices by applying softmax across individual sample logits, then selecting corresponding log probabilities using target indices. The kernel sums these gathered values and performs batch reduction to compute the averaged scalar loss.

Does Pypto runtime support scalar output for cross-entropy loss backpropagation?

Yes, Pypto runtime supports scalar output for cross-entropy loss backpropagation. The kernel computes a single scalar loss value from batch reduction of gathered log probabilities, which can be used directly for backpropagation in your model.

Can I use different tile settings for softmax and gather operations in a single kernel?

Yes, you can use different tile settings for softmax and gather operations within a single cross-entropy loss kernel. Pypto's two-phase tiling mechanism allows configuring distinct tile parameters for different stages of the multi-input kernel execution.

Why does my cross-entropy loss kernel require multi-input setups for batch processing?

Cross-entropy loss kernels require multi-input setups to handle both predictions and targets simultaneously during batch processing. The kernel accesses both input tensors to perform per-sample softmax on predictions and gather operations using target indices for accurate loss computation.