-
Notifications
You must be signed in to change notification settings - Fork 2
Add Neureka v2 support #19
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
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
bdefff9
Add cmake to the test app
lukamac a149b08
Add neureka_v2 to cmake scripts
lukamac da325f0
Fix clang warnings
lukamac 8e210c3
Add neureka_v2 hal
lukamac 6db90ed
Add neureka_v2 implementation of NnxWeight and NnxTestConf
lukamac 556e951
Add NnxBuildFlow and CmakeBuildFlow
lukamac 873a734
Fix toolchain url for neureka
lukamac 9f01125
Use fixtures instead of parametrization for options
lukamac bb411ff
Use gcc toolchain for testing
lukamac 9d209d5
Remove unused timeout
lukamac e86201a
Remove unused imports
lukamac e904704
Remove wmem from json
lukamac c8cb8e4
Add wmem flag to tests
lukamac fb5815a
Remove wmem validation from testconf and add it in NnxWeight
lukamac 9b05820
Add neureka_v2 tests
lukamac d507d99
Add wmem to neureka test and add neureka_v2 tests to CI
lukamac 7cbe533
Fix formatting
lukamac 4ff9f1c
Fix import formatting
lukamac 06e0384
Fix formatting
lukamac bffefb6
Update readmes
lukamac 9e12f7b
Replace subtile_input_channel and subtile_output_channel with single …
lukamac 85c4009
Update changelog
lukamac 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: Test Neureka v2 | ||
on: push | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
container: ghcr.io/pulp-platform/pulp-nnx:main-test | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Run test | ||
shell: bash | ||
working-directory: test | ||
run: | | ||
pytest test.py -T tests -R -A neureka_v2 --build-flow=cmake --wmem=mram |
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
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,65 @@ | ||
/* | ||
* Luka Macan <[email protected]> | ||
* | ||
* Copyright 2023 ETH Zurich and University of Bologna | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include "neureka_v2.h" | ||
#include "neureka_v2_siracusa_bsp.h" | ||
#include "neureka_v2_task.h" | ||
#include <stdint.h> | ||
|
||
/* PULP-NNX interface */ | ||
|
||
void neureka_v2_nnx_init(const neureka_v2_dev_t *dev, | ||
neureka_v2_siracusa_conf_t *conf); | ||
void neureka_v2_nnx_term(const neureka_v2_dev_t *dev); | ||
|
||
/** neureka_v2_nnx_dispatch_check | ||
* | ||
* Check whether you can dispatch to the accelerator. | ||
*/ | ||
int neureka_v2_nnx_dispatch_check(const neureka_v2_dev_t *dev); | ||
|
||
/** neureka_v2_nnx_dispatch_wait | ||
* | ||
* Block until you can dispatch to the accelerator. | ||
*/ | ||
void neureka_v2_nnx_dispatch_wait(const neureka_v2_dev_t *dev); | ||
|
||
/** neureka_v2_nnx_dispatch | ||
* | ||
* Dispatch a task to the accelerator. | ||
* Fails with return code 1 if the task cannot be dispatched. Otherwise returns | ||
* 0. | ||
*/ | ||
int neureka_v2_nnx_dispatch(const neureka_v2_dev_t *dev, | ||
neureka_v2_task_t *task); | ||
|
||
/** neureka_v2_nnx_resolve_check | ||
* | ||
* Check whether the task has been resolved. | ||
*/ | ||
int neureka_v2_nnx_resolve_check(const neureka_v2_dev_t *dev, | ||
neureka_v2_task_t *task); | ||
|
||
/** neureka_v2_nnx_resolve_wait | ||
* | ||
* Block until you can resolve the task. | ||
*/ | ||
void neureka_v2_nnx_resolve_wait(const neureka_v2_dev_t *dev, | ||
neureka_v2_task_t *task); |
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,37 @@ | ||
# Neureka v2 | ||
|
||
## Docs | ||
|
||
Gvsoc model repo [link](https://github.com/lukamac/gvsoc-pulp/tree/fix-vectorload). | ||
|
||
## Implemented features | ||
|
||
- [x] Convolution w/ kernel shape 1x1 | ||
- [x] Convolution w/ kernel shape 3x3 | ||
- [x] Depthwise convolution w/ kernel shape 3x3 | ||
- [ ] Normalization and quantization | ||
- [x] With | ||
- [ ] Without | ||
- [x] Relu (w/ and w/o) | ||
- [x] Bias (w/ and w/o) | ||
- [ ] Per-channel shift | ||
- [x] Per-layer shift | ||
- [x] Input type | ||
- [x] uint8 | ||
- [x] int8 | ||
- [x] Output type | ||
- [x] int8 | ||
- [x] uint8 (only w/ Relu) | ||
- [ ] int32 | ||
- [x] Scale type | ||
- [x] int8 | ||
- [ ] int32 | ||
- [x] Bias type | ||
- [x] int32 | ||
- [ ] Weight type | ||
- [x] int8 | ||
- [ ] int2-7 | ||
- [ ] Weight memory | ||
- [ ] Shared TCDM | ||
- [x] Private SRAM | ||
- [x] Private MRAM |
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,78 @@ | ||
/* | ||
* Luka Macan <[email protected]> | ||
* | ||
* Copyright 2023 ETH Zurich and University of Bologna | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include "neureka_v2_siracusa_bsp.h" | ||
#include <pmsis.h> | ||
|
||
#define NEUREKA_V2_SIRACUSA_CLUSTER_CTRL_BASE_ADDR (0x00200000) | ||
#define NEUREKA_V2_SIRACUSA_CLUSTER_CTRL_HWPE_OFFS 0x18 | ||
#define NEUREKA_V2_SIRACUSA_CLUSTER_CTRL_HWPE_ADDR \ | ||
(NEUREKA_V2_SIRACUSA_CLUSTER_CTRL_BASE_ADDR + \ | ||
NEUREKA_V2_SIRACUSA_CLUSTER_CTRL_HWPE_OFFS) | ||
#define NEUREKA_V2_SIRACUSA_CLUSTER_CTRL_HWPE_MASK_HCI_PRIO 0x100 | ||
#define NEUREKA_V2_SIRACUSA_CLUSTER_CTRL_HWPE_MASK_HCI_MAXSTALL 0xff | ||
#define NEUREKA_V2_SIRACUSA_MAX_STALL (8) | ||
#define NEUREKA_V2_SIRACUSA_EVENT (1 << 12) | ||
#define NEUREKA_V2_SIRACUSA_BASE_ADDR (0x00201000) | ||
#define NEUREKA_V2_SIRACUSA_WEIGHT_MEM_BASE_ADDR (0x10400000) | ||
#define NEUREKA_V2_SIRACUSA_WEIGHT_MEM_MRAM_OFFSET (0x00000000) | ||
#define NEUREKA_V2_SIRACUSA_WEIGHT_MEM_SRAM_OFFSET (0x00400000) | ||
|
||
void neureka_v2_siracusa_hci_setpriority_neureka_v2() { | ||
*(volatile uint32_t *)NEUREKA_V2_SIRACUSA_CLUSTER_CTRL_HWPE_ADDR |= | ||
NEUREKA_V2_SIRACUSA_CLUSTER_CTRL_HWPE_MASK_HCI_PRIO; | ||
} | ||
|
||
void neureka_v2_siracusa_hci_setpriority_core() { | ||
*(volatile uint32_t *)NEUREKA_V2_SIRACUSA_CLUSTER_CTRL_HWPE_ADDR &= | ||
~NEUREKA_V2_SIRACUSA_CLUSTER_CTRL_HWPE_MASK_HCI_PRIO; | ||
} | ||
|
||
void neureka_v2_siracusa_hci_reset_max_stall() { | ||
*(volatile uint32_t *)NEUREKA_V2_SIRACUSA_CLUSTER_CTRL_HWPE_ADDR &= | ||
~NEUREKA_V2_SIRACUSA_CLUSTER_CTRL_HWPE_MASK_HCI_MAXSTALL; | ||
} | ||
|
||
void neureka_v2_siracusa_hci_set_max_stall(uint32_t max_stall) { | ||
*(volatile uint32_t *)NEUREKA_V2_SIRACUSA_CLUSTER_CTRL_HWPE_ADDR |= | ||
max_stall & NEUREKA_V2_SIRACUSA_CLUSTER_CTRL_HWPE_MASK_HCI_MAXSTALL; | ||
} | ||
|
||
void neureka_v2_siracusa_open(neureka_v2_siracusa_conf_t *conf) { | ||
neureka_v2_siracusa_hci_setpriority_neureka_v2(); | ||
neureka_v2_siracusa_hci_set_max_stall(conf->max_stall); | ||
} | ||
|
||
void neureka_v2_siracusa_close() { | ||
neureka_v2_siracusa_hci_reset_max_stall(); | ||
neureka_v2_siracusa_hci_setpriority_core(); | ||
} | ||
|
||
void neureka_v2_siracusa_event_wait_and_clear() { | ||
eu_evt_maskWaitAndClr(NEUREKA_V2_SIRACUSA_EVENT); | ||
} | ||
|
||
static const neureka_v2_dev_t neureka_v2_siracusa_dev = { | ||
.hwpe_dev = (struct hwpe_dev_t){ | ||
.base_addr = (volatile uint32_t *)NEUREKA_V2_SIRACUSA_BASE_ADDR}}; | ||
|
||
const neureka_v2_dev_t *neureka_v2_siracusa_get_dev() { | ||
return &neureka_v2_siracusa_dev; | ||
} |
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,67 @@ | ||
/* | ||
* Luka Macan <[email protected]> | ||
* | ||
* Copyright 2023 ETH Zurich and University of Bologna | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef __NEUREKA_V2_SIRACUSA_BSP_H__ | ||
#define __NEUREKA_V2_SIRACUSA_BSP_H__ | ||
|
||
#include "neureka_v2.h" | ||
#include <stdint.h> | ||
|
||
/** | ||
* neureka_v2_siracusa_setpriority_neureka_v2 | ||
* | ||
* Set HCI interconnect bus priority to prioritize neureka_v2. | ||
*/ | ||
void neureka_v2_siracusa_hci_setpriority_neureka_v2(); | ||
|
||
/** | ||
* neureka_v2_siracusa_setpriority_core | ||
* | ||
* Set HCI bus priority to prioritize cores. | ||
*/ | ||
void neureka_v2_siracusa_hci_setpriority_core(); | ||
|
||
/** | ||
* neureka_v2_siracusa_hci_reset_maxstall | ||
* | ||
* Reset the HCI bus maxstall parameter. | ||
* TODO: Check if it disables it also or just resets? | ||
*/ | ||
void neureka_v2_siracusa_hci_reset_max_stall(); | ||
|
||
/** | ||
* neureka_v2_siracusa_hci_set_maxstall | ||
* | ||
* Set the HCI bus maxstall. Maxstall defines how many cycles | ||
* will the HCI bus stall the lower priority master, i.e. neureka_v2 or core, | ||
* before letting it do a transaction. | ||
*/ | ||
void neureka_v2_siracusa_hci_set_max_stall(uint32_t max_stall); | ||
|
||
typedef struct neureka_v2_siracusa_conf_t { | ||
int max_stall; | ||
} neureka_v2_siracusa_conf_t; | ||
|
||
void neureka_v2_siracusa_open(neureka_v2_siracusa_conf_t *conf); | ||
void neureka_v2_siracusa_close(); | ||
void neureka_v2_siracusa_event_wait_and_clear(); | ||
const neureka_v2_dev_t *neureka_v2_siracusa_get_dev(); | ||
|
||
#endif // !__NEUREKA_V2_SIRACUSA_BSP_H__ |
Oops, something went wrong.
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.