-
Notifications
You must be signed in to change notification settings - Fork 34
Rmsnorm #136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Rmsnorm #136
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9b74876
test 1
lee2716 5d499d4
test
lee2716 3499a64
Merge branch 'pulp-platform:devel' into rmsnorm
lee2716 30cfabb
add pow2_fp16,pow2_fp32,sqrt_fp16,sqrt_fp32, rmsnorm_fp32, rmsnorm_fp…
lee2716 360519c
Remove FP16 tests due to lack of native support
lee2716 fee8470
Removing FP16 tests in CI
lee2716 8f90620
Refactor Pow for float support, remove FP16, and cleanup parsers
lee2716 4834c2a
recover the teseRMSNorm and updated 128*128 version of testFloatRMSNorm
lee2716 e1785a8
Fix: Address review comments (dynamic types, vector Pow test, CI upda…
lee2716 8ecf929
remove the testFloatPow, which has been renamed to testFloatPowScalar
lee2716 2e857bd
add change log
lee2716 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diaconuccalin marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diaconuccalin marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # SPDX-FileCopyrightText: 2025 ETH Zurich and University of Bologna | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| from typing import Dict, List, Tuple | ||
|
|
||
| import numpy as np | ||
|
|
||
| from Deeploy.DeeployTypes import NetworkContext, NodeTemplate, OperatorRepresentation | ||
|
|
||
|
|
||
| class _PowTemplate(NodeTemplate): | ||
|
|
||
| def alignToContext(self, ctxt: NetworkContext, | ||
| operatorRepresentation: OperatorRepresentation) -> Tuple[NetworkContext, Dict, List[str]]: | ||
|
|
||
| # Get input and output tensors | ||
| data_in = ctxt.lookup(operatorRepresentation['data_in']) | ||
| data_out = ctxt.lookup(operatorRepresentation['data_out']) | ||
|
|
||
| # Get data type (fp32 or fp16) | ||
| data_type = data_in._type.typeName | ||
| operatorRepresentation['data_type'] = data_type | ||
|
|
||
| # Exponent must be a constant integer | ||
| if 'exponent' in operatorRepresentation: | ||
diaconuccalin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| exponent_input = operatorRepresentation['exponent'] | ||
| if isinstance(exponent_input, str): | ||
| # It's a tensor name - not supported for integer exponent version | ||
| raise ValueError("Tensor exponent not supported. Use constant integer exponent.") | ||
| else: | ||
| # Convert to integer | ||
diaconuccalin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| operatorRepresentation['exponent_value'] = int(exponent_input) | ||
|
|
||
| # Calculate size | ||
| operatorRepresentation['size'] = int(np.prod(data_in.shape)) | ||
|
|
||
| return ctxt, operatorRepresentation, [] | ||
diaconuccalin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| referenceTemplate = _PowTemplate(""" | ||
| // Pow (Name: ${nodeName}, Op: ${nodeOp}) | ||
| % if 'float32' in data_type: | ||
| Pow_fp32_int32_fp32(${data_in}, ${exponent_value}, ${data_out}, ${size}); | ||
| % elif 'float16' in data_type: | ||
| Pow_fp16_int32_fp16(${data_in}, ${exponent_value}, ${data_out}, ${size}); | ||
diaconuccalin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| % endif | ||
| """) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # SPDX-FileCopyrightText: 2025 ETH Zurich and University of Bologna | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| from typing import Dict, List, Tuple | ||
|
|
||
| import numpy as np | ||
|
|
||
| from Deeploy.DeeployTypes import NetworkContext, NodeTemplate, OperatorRepresentation | ||
|
|
||
|
|
||
| class _SqrtTemplate(NodeTemplate): | ||
|
|
||
| def alignToContext(self, ctxt: NetworkContext, | ||
| operatorRepresentation: OperatorRepresentation) -> Tuple[NetworkContext, Dict, List[str]]: | ||
|
|
||
| # Get input and output tensors | ||
| data_in = ctxt.lookup(operatorRepresentation['data_in']) | ||
| data_out = ctxt.lookup(operatorRepresentation['data_out']) | ||
|
|
||
| # Get data type (fp32 or fp16) | ||
| data_type = data_in._type.typeName | ||
| operatorRepresentation['data_type'] = data_type | ||
|
|
||
| # Calculate size | ||
| operatorRepresentation['size'] = int(np.prod(data_in.shape)) | ||
|
|
||
| return ctxt, operatorRepresentation, [] | ||
|
|
||
|
|
||
| referenceTemplate = _SqrtTemplate(""" | ||
| // Sqrt (Name: ${nodeName}, Op: ${nodeOp}) | ||
| % if 'float32' in data_type: | ||
| Sqrt_fp32_fp32(${data_in}, ${data_out}, ${size}); | ||
diaconuccalin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| % elif 'float16' in data_type: | ||
| Sqrt_fp16_fp16(${data_in}, ${data_out}, ${size}); | ||
diaconuccalin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| % endif | ||
| """) | ||
Binary file not shown.
Binary file not shown.
Binary file not shown.
diaconuccalin marked this conversation as resolved.
Show resolved
Hide resolved
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.