arithmetic: addSymInt32Tensors / Sub twin swap the tensor arguments on the unequal-scale path

Open Beginner friendly
#536 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
83/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c
Domain
backend

Research direction

Read src/arithmetic/Add.c and src/arithmetic/Sub.c at the cited lines, then check the argument order in Tensor.h:80 and the neighboring b call. Add the requested regression test with unequal-scale SYM_INT32 operands, comparing against the float reference and checking that aTensor is unchanged; run the relevant unit tests. Done when both callers use the documented order and the regression test passes.

Written by the indexing model from the issue text.

Description

bug

Bug

On the unequal-scale (float fallback) path, addSymInt32Tensors and its Sub twin pass the tensor arguments of setTensorValuesForConversion in the wrong order for operand a:

  • src/arithmetic/Add.c:183: setTensorValuesForConversion(aFloatData, &floatQ, &aFloat, aTensor);
  • src/arithmetic/Sub.c:170: same pattern.

The signature is (data, q, originalTensor, newTensor) (Tensor.h:80), and the b line right below it (Add.c:188) uses that order. With a swapped, the caller's aTensor is re-pointed at a stack buffer with FLOAT32 quantization, and aFloat is left uninitialised. The following convertTensor(aTensor, &aFloat, rs) then reads the wrong tensor.

Impact

addSymInt32Tensors / the Sub twin have no caller in src/ or examples/; only two unit tests call them. No training path is affected today. A future SYM merge (Add node, #329 follow-up) would land exactly on this branch, since a SYM Add almost always sees unequal scales.

Fix

Swap the two arguments on the a line in both files. Add a RED test with two SYM_INT32 operands of unequal scale, checked against the float reference, and assert the caller's aTensor is unchanged.

Dominant language
C
Stars
2
Forks
3
Avg merge
13h 6m
Merged PRs (30d)
9

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from es-ude/OnDeviceTraining

All issues in es-ude/OnDeviceTraining

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.