es-ude / es-ude/OnDeviceTraining

userApi/tensor: promote requantizeTensorInPlace from example code to TensorApi when a second consumer appears

Open
#387 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
1
Forks
3
Avg merge
1d 1h
Merged PRs (30d)
8

Description

## Context

The #270 resolution (PR #378) settled that public factories keep the FLOAT32 param-storage gate, and **FLOAT32-init + requantize is the documented public-API path** to SYM_INT32-native weights/bias. The requantize step itself, however, lives as a ~15-line static helper in the example:

```c
static void requantizeTensorInPlace(tensor_t *t, quantization_t *targetQ); /* examples/mixed_width_mlp/train_c.c:116 */
```

built purely from public primitives (`getQLike`, `getDataLike`, converter dispatch). Every future consumer of the documented path has to copy it.

## Trigger (per the #270 PR-body decision)

Promote to `TensorApi` **when a second consumer copies it** — not speculatively before. This issue exists so the trigger is tracked instead of rediscovered.

## Design notes for when it fires

- Home: `src/userApi/tensor` (allocation locality: the helper allocates replacement data/qconfig and frees the old — legal only in src/userApi/).
- Decide in-place-realloc vs caller-provided destination: project preference is caller-owned buffers in user APIs, but the factory-init use case (swap a param's storage under a live layer config) is inherently in-place. Possibly offer both, thin wrapper over one core.
- Migrate `mixed_width_mlp` onto the API in the same PR (removes the only copy, keeps the example as the usage reference).

## Relations

#270 / PR #378 (decision + soft-cost assessment), examples/mixed_width_mlp (only consumer today).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Contributor guide

Open the contributing guide

Research direction

Start by reading examples/mixed_width_mlp/train_c.c and the decision in #270/PR #378; the helper there is currently the only consumer. When a second consumer appears, design the API in src/userApi/tensor and migrate mixed_width_mlp to it. Done means the example no longer carries a copied helper and uses the shared API.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
backend-api-design, embedded-iot
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.