pypto-case-loss-crossentropy

Compute cross-entropy loss for batched Pypto kernels with two-stage tiling.

258|48|Updated Jun 22, 2020
One-click install
npx skills add https://github.com/mindspore-ai/akg --skill pypto-case-loss-crossentropy-mindspore-ai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pypto-case-loss-crossentropy
Source: https://github.com/mindspore-ai/akg/tree/main/akg_agents/python/akg_agents/op/resources/skills/pypto/cases/pypto-case-loss-crossentropy
Command: npx skills add https://github.com/mindspore-ai/akg --skill pypto-case-loss-crossentropy-mindspore-ai

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Compute cross-entropy loss for multi-input Pypto kernels by implementing two-stage tiling and a scalar output.

Core Features & Use Cases

  • Two-phase computation: per-sample softmax + gather, followed by batch reduction to a scalar.
  • Supports explicit two tile configurations and type-casting between INT64 targets and INT32 indices.
  • Demonstrates Pypto front-end usage with decorator-based kernel definitions and a scalar output for training-style loss.

Quick Start

Instantiate the CrossEntropy kernel with a batch size and number of classes, then run it on 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 compute cross-entropy loss using a multi-stage Pypto kernel?

Cross-entropy loss is computed by implementing a multi-stage Pypto kernel that performs per-sample softmax and gather operations. This is followed by a batch-wide reduction to output a final scalar tensor representing the averaged loss.

What is two-stage tiling for cross-entropy loss in Pypto?

Two-stage tiling in Pypto splits cross-entropy loss computation into two explicit tile configurations. The first phase handles per-sample softmax and gather, while the second phase performs the batch reduction to generate the final scalar output.

Can I use Pypto decorators to define a cross-entropy kernel with a scalar output?

Yes, Pypto supports decorator-based kernel definitions to compute cross-entropy loss. You can instantiate the kernel with batch size and class count, run it on predictions and targets, and obtain a scalar tensor output for training.

How do I handle integer targets and index gathering in a Pypto classification kernel?

Pypto classification kernels handle integer targets through explicit type-casting between INT64 targets and INT32 indices. The kernel performs index-based gathering after per-sample softmax to extract the relevant prediction scores before batch reduction.

Does Pypto support cross-entropy loss for batched classification with multiple inputs?

Pypto supports cross-entropy loss for batched classification by processing multiple input predictions alongside integer targets. The kernel applies two-stage tile configurations to manage the per-sample operations and final batch-wide reduction efficiently.

When should I use a multi-stage tiling approach for cross-entropy loss computation?

Multi-stage tiling for cross-entropy loss is appropriate when building Pypto-based kernels that require explicit type annotations and decorator usage. It structurally separates per-sample softmax and gather operations from the final batch-wide reduction.