Merge branch 'openpilot/master' into sync-20250108

# Conflicts:
#	common/base.py
#	common/comma_connect.py
#	opendbc_repo
#	panda
This commit is contained in:
Jason Wen
2025-01-08 23:40:36 -05:00
160 changed files with 854 additions and 9384 deletions

View File

@@ -1,15 +0,0 @@
---
name: Bug fix
about: For openpilot bug fixes
title: ''
labels: 'bugfix'
assignees: ''
---
**Description**
<!-- A description of the bug and the fix. Also link the issue if it exists. -->
**Verification**
<!-- Explain how you tested this bug fix. -->

View File

@@ -1,19 +0,0 @@
---
name: Car Bug fix
about: For vehicle/brand specific bug fixes
title: ''
labels: 'car bug fix'
assignees: ''
---
**Description**
<!-- A description of the bug and the fix. Also link the issue if it exists. -->
**Verification**
<!-- Explain how you tested this bug fix. -->
**Route**
Route: [a route with the bug fix]

View File

@@ -1,15 +0,0 @@
---
name: Car port
about: For new car ports
title: ''
labels: 'car port'
assignees: ''
---
**Checklist**
- [ ] added entry to CAR in selfdrive/car/*/values.py and ran `selfdrive/car/docs.py` to generate new docs
- [ ] test route added to [routes.py](https://github.com/commaai/openpilot/blob/master/selfdrive/car/tests/routes.py)
- [ ] route with openpilot:
- [ ] route with stock system:
- [ ] car harness used (if comma doesn't sell it, put N/A):

View File

@@ -1,13 +0,0 @@
---
name: Fingerprint
about: For adding fingerprints to existing cars
title: ''
labels: 'fingerprint'
assignees: ''
---
**Car**
Which car (make, model, year) this fingerprint is for
**Route**
A route with the fingerprint

View File

@@ -1,15 +0,0 @@
---
name: Refactor
about: For code refactors
title: ''
labels: 'refactor'
assignees: ''
---
**Description**
<!-- A description of the refactor, including the goals it accomplishes. -->
**Verification**
<!-- Explain how you tested the refactor for regressions. -->

View File

@@ -1,31 +0,0 @@
---
name: Tuning
about: For openpilot tuning changes
title: ''
labels: 'tuning'
assignees: ''
---
**Description**
<!-- A description of what is wrong with the current tuning and how the PR addresses this. -->
**Verification**
<!-- To verify tuning, capture the following scenarios (broadly, not exactly), with current tune and this tune.
Use the PlotJuggler tuning layout to compare planned versus actual behavior.
Run ./juggle.py <route> --layout layouts/tuning.xml , screenshot the full tab of interest, and paste into this PR.
Longitudinal:
* Maintaining speed at 25, 40, 65mph
* Driving up and down hills
* Accelerating from a stop
* Decelerating to a stop
* Following large changes in set speed
* Coming to a stop behind a lead car
Lateral:
* Straight driving at ~25, ~45 and ~65mph
* Turns driving at ~25, ~45 and ~65mph
-->

30
.github/build.py vendored
View File

@@ -1,30 +0,0 @@
import pathlib
GITHUB_FOLDER = pathlib.Path(__file__).parent
PULL_REQUEST_TEMPLATES = (GITHUB_FOLDER / "PULL_REQUEST_TEMPLATE")
order = ["fingerprint", "car_bugfix", "bugfix", "car_port", "refactor"]
def create_pull_request_template():
with open(GITHUB_FOLDER / "pull_request_template.md", "w") as f:
f.write("<!-- Please copy and paste the relevant template -->\n\n")
for t in order:
template = PULL_REQUEST_TEMPLATES / f"{t}.md"
text = template.read_text()
# Remove metadata for GitHub
start = text.find("---")
end = text.find("---", start+1)
text = text[end + 4:]
# Remove comments
text = text.replace("<!-- ", "").replace("-->", "")
f.write(f"<!--- ***** Template: {template.stem.replace('_', ' ').title()} *****\n")
f.write(text)
f.write("\n\n")
f.write("-->\n\n")
create_pull_request_template()

View File

@@ -49,10 +49,6 @@ AddOption('--ccflags',
default='',
help='pass arbitrary flags over the command line')
AddOption('--snpe',
action='store_true',
help='use SNPE on PC')
AddOption('--external-sconscript',
action='store',
metavar='FILE',

View File

@@ -1,49 +0,0 @@
using Cxx = import "./include/c++.capnp";
$Cxx.namespace("cereal");
@0xa086df597ef5d7a0;
# Geometry
struct Point {
x @0: Float64;
y @1: Float64;
z @2: Float64;
}
struct PolyLine {
points @0: List(Point);
}
# Map features
struct Lane {
id @0 :Text;
leftBoundary @1 :LaneBoundary;
rightBoundary @2 :LaneBoundary;
leftAdjacentId @3 :Text;
rightAdjacentId @4 :Text;
inboundIds @5 :List(Text);
outboundIds @6 :List(Text);
struct LaneBoundary {
polyLine @0 :PolyLine;
startHeading @1 :Float32; # WRT north
}
}
# Map tiles
struct TileSummary {
version @0 :Text;
updatedAt @1 :UInt64; # Millis since epoch
level @2 :UInt8;
x @3 :UInt16;
y @4 :UInt16;
}
struct MapTile {
summary @0 :TileSummary;
lanes @1 :List(Lane);
}

View File

@@ -133,7 +133,6 @@ std::unordered_map<std::string, uint32_t> keys = {
{"GsmRoaming", PERSISTENT | BACKUP},
{"HardwareSerial", PERSISTENT},
{"HasAcceptedTerms", PERSISTENT},
{"IMEI", PERSISTENT},
{"InstallDate", PERSISTENT},
{"IsDriverViewEnabled", CLEAR_ON_MANAGER_START},
{"IsEngaged", PERSISTENT},

View File

@@ -255,6 +255,29 @@ bool ends_with(const std::string& s, const std::string& suffix) {
strcmp(s.c_str() + (s.size() - suffix.size()), suffix.c_str()) == 0;
}
std::string strip(const std::string &str) {
auto should_trim = [](unsigned char ch) {
// trim whitespace or a null character
return std::isspace(ch) || ch == '\0';
};
size_t start = 0;
while (start < str.size() && should_trim(static_cast<unsigned char>(str[start]))) {
start++;
}
if (start == str.size()) {
return "";
}
size_t end = str.size() - 1;
while (end > 0 && should_trim(static_cast<unsigned char>(str[end]))) {
end--;
}
return str.substr(start, end - start + 1);
}
std::string check_output(const std::string& command) {
char buffer[128];
std::string result;

View File

@@ -74,6 +74,7 @@ float getenv(const char* key, float default_val);
std::string hexdump(const uint8_t* in, const size_t size);
bool starts_with(const std::string &s1, const std::string &s2);
bool ends_with(const std::string &s, const std::string &suffix);
std::string strip(const std::string &str);
// ***** random helpers *****
int random_int(int min, int max);

View File

@@ -4,7 +4,7 @@
A supported vehicle is one that just works when you install a comma device. All supported cars provide a better experience than any stock system. Supported vehicles reference the US market unless otherwise specified.
# 289 Supported Cars
# 290 Supported Cars
|Make|Model|Supported Package|ACC|No ACC accel below|No ALC below|Steering Torque|Resume from stop|<a href="##"><img width=2000></a>Hardware Needed<br>&nbsp;|Video|
|---|---|---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
@@ -56,6 +56,7 @@ A supported vehicle is one that just works when you install a comma device. All
|Genesis|GV60 (Performance Trim) 2022-23[<sup>5</sup>](#footnotes)|All|openpilot available[<sup>1</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 Hyundai K connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Genesis&model=GV60 (Performance Trim) 2022-23">Buy Here</a></sub></details>||
|Genesis|GV70 (2.5T Trim, without HDA II) 2022-23[<sup>5</sup>](#footnotes)|All|Stock|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 Hyundai L connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Genesis&model=GV70 (2.5T Trim, without HDA II) 2022-23">Buy Here</a></sub></details>||
|Genesis|GV70 (3.5T Trim, without HDA II) 2022-23[<sup>5</sup>](#footnotes)|All|Stock|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 Hyundai M connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Genesis&model=GV70 (3.5T Trim, without HDA II) 2022-23">Buy Here</a></sub></details>||
|Genesis|GV70 Electrified (Australia Only) 2022[<sup>5</sup>](#footnotes)|All|openpilot available[<sup>1</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 Hyundai Q connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Genesis&model=GV70 Electrified (Australia Only) 2022">Buy Here</a></sub></details>||
|Genesis|GV70 Electrified (with HDA II) 2023[<sup>5</sup>](#footnotes)|Highway Driving Assist II|openpilot available[<sup>1</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 Hyundai Q connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Genesis&model=GV70 Electrified (with HDA II) 2023">Buy Here</a></sub></details>||
|Genesis|GV80 2023[<sup>5</sup>](#footnotes)|All|Stock|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 Hyundai M connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Genesis&model=GV80 2023">Buy Here</a></sub></details>||
|GMC|Sierra 1500 2020-21|Driver Alert Package II|openpilot available[<sup>1</sup>](#footnotes)|0 mph|6 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-empty.svg)](##)|<details><summary>Parts</summary><sub>- 1 GM connector<br>- 1 comma 3X<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=GMC&model=Sierra 1500 2020-21">Buy Here</a></sub></details>|<a href="https://youtu.be/5HbNoBLzRwE" target="_blank"><img height="18px" src="assets/icon-youtube.svg"></img></a>|
@@ -79,7 +80,7 @@ A supported vehicle is one that just works when you install a comma device. All
|Honda|Odyssey 2018-20|Honda Sensing|openpilot|26 mph|0 mph|[![star](assets/icon-star-empty.svg)](##)|[![star](assets/icon-star-empty.svg)](##)|<details><summary>Parts</summary><sub>- 1 Honda Nidec connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Honda&model=Odyssey 2018-20">Buy Here</a></sub></details>||
|Honda|Passport 2019-23|All|openpilot|26 mph|12 mph|[![star](assets/icon-star-empty.svg)](##)|[![star](assets/icon-star-empty.svg)](##)|<details><summary>Parts</summary><sub>- 1 Honda Nidec connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Honda&model=Passport 2019-23">Buy Here</a></sub></details>||
|Honda|Pilot 2016-22|Honda Sensing|openpilot|26 mph|12 mph|[![star](assets/icon-star-empty.svg)](##)|[![star](assets/icon-star-empty.svg)](##)|<details><summary>Parts</summary><sub>- 1 Honda Nidec connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Honda&model=Pilot 2016-22">Buy Here</a></sub></details>||
|Honda|Ridgeline 2017-24|Honda Sensing|openpilot|26 mph|12 mph|[![star](assets/icon-star-empty.svg)](##)|[![star](assets/icon-star-empty.svg)](##)|<details><summary>Parts</summary><sub>- 1 Honda Nidec connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Honda&model=Ridgeline 2017-24">Buy Here</a></sub></details>||
|Honda|Ridgeline 2017-25|Honda Sensing|openpilot|26 mph|12 mph|[![star](assets/icon-star-empty.svg)](##)|[![star](assets/icon-star-empty.svg)](##)|<details><summary>Parts</summary><sub>- 1 Honda Nidec connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Honda&model=Ridgeline 2017-25">Buy Here</a></sub></details>||
|Hyundai|Azera 2022|All|openpilot available[<sup>1</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 Hyundai K connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Hyundai&model=Azera 2022">Buy Here</a></sub></details>||
|Hyundai|Azera Hybrid 2019|All|openpilot available[<sup>1</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 Hyundai C connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Hyundai&model=Azera Hybrid 2019">Buy Here</a></sub></details>||
|Hyundai|Azera Hybrid 2020|All|openpilot available[<sup>1</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 Hyundai K connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Hyundai&model=Azera Hybrid 2020">Buy Here</a></sub></details>||
@@ -91,7 +92,7 @@ A supported vehicle is one that just works when you install a comma device. All
|Hyundai|Elantra Hybrid 2021-23|Smart Cruise Control (SCC)|openpilot available[<sup>1</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 Hyundai K connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Hyundai&model=Elantra Hybrid 2021-23">Buy Here</a></sub></details>|<a href="https://youtu.be/_EdYQtV52-c" target="_blank"><img height="18px" src="assets/icon-youtube.svg"></img></a>|
|Hyundai|Genesis 2015-16|Smart Cruise Control (SCC)|Stock|19 mph|37 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-empty.svg)](##)|<details><summary>Parts</summary><sub>- 1 Hyundai J connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Hyundai&model=Genesis 2015-16">Buy Here</a></sub></details>||
|Hyundai|i30 2017-19|Smart Cruise Control (SCC)|Stock|0 mph|32 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 Hyundai E connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Hyundai&model=i30 2017-19">Buy Here</a></sub></details>||
|Hyundai|Ioniq 5 (Non-US only) 2022-24[<sup>5</sup>](#footnotes)|All|openpilot available[<sup>1</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 Hyundai Q connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Hyundai&model=Ioniq 5 (Non-US only) 2022-24">Buy Here</a></sub></details>||
|Hyundai|Ioniq 5 (Southeast Asia and Europe only) 2022-24[<sup>5</sup>](#footnotes)|All|openpilot available[<sup>1</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 Hyundai Q connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Hyundai&model=Ioniq 5 (Southeast Asia and Europe only) 2022-24">Buy Here</a></sub></details>||
|Hyundai|Ioniq 5 (with HDA II) 2022-24[<sup>5</sup>](#footnotes)|Highway Driving Assist II|openpilot available[<sup>1</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 Hyundai Q connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Hyundai&model=Ioniq 5 (with HDA II) 2022-24">Buy Here</a></sub></details>||
|Hyundai|Ioniq 5 (without HDA II) 2022-24[<sup>5</sup>](#footnotes)|Highway Driving Assist|openpilot available[<sup>1</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 Hyundai K connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Hyundai&model=Ioniq 5 (without HDA II) 2022-24">Buy Here</a></sub></details>||
|Hyundai|Ioniq 6 (with HDA II) 2023-24[<sup>5</sup>](#footnotes)|Highway Driving Assist II|Stock|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 Hyundai P connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Hyundai&model=Ioniq 6 (with HDA II) 2023-24">Buy Here</a></sub></details>||
@@ -294,7 +295,7 @@ A supported vehicle is one that just works when you install a comma device. All
|Volkswagen|Teramont 2018-22|Adaptive Cruise Control (ACC) & Lane Assist|openpilot available[<sup>1,12</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 USB-C coupler<br>- 1 VW J533 connector<br>- 1 comma 3X<br>- 1 harness box<br>- 1 long OBD-C cable<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Volkswagen&model=Teramont 2018-22">Buy Here</a></sub></details>||
|Volkswagen|Teramont Cross Sport 2021-22|Adaptive Cruise Control (ACC) & Lane Assist|openpilot available[<sup>1,12</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 USB-C coupler<br>- 1 VW J533 connector<br>- 1 comma 3X<br>- 1 harness box<br>- 1 long OBD-C cable<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Volkswagen&model=Teramont Cross Sport 2021-22">Buy Here</a></sub></details>||
|Volkswagen|Teramont X 2021-22|Adaptive Cruise Control (ACC) & Lane Assist|openpilot available[<sup>1,12</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 USB-C coupler<br>- 1 VW J533 connector<br>- 1 comma 3X<br>- 1 harness box<br>- 1 long OBD-C cable<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Volkswagen&model=Teramont X 2021-22">Buy Here</a></sub></details>||
|Volkswagen|Tiguan 2018-24|Adaptive Cruise Control (ACC) & Lane Assist|openpilot available[<sup>1,12</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 USB-C coupler<br>- 1 VW J533 connector<br>- 1 comma 3X<br>- 1 harness box<br>- 1 long OBD-C cable<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Volkswagen&model=Tiguan 2018-24">Buy Here</a></sub></details>||
|Volkswagen|Tiguan 2018-23|Adaptive Cruise Control (ACC) & Lane Assist|openpilot available[<sup>1,12</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 USB-C coupler<br>- 1 VW J533 connector<br>- 1 comma 3X<br>- 1 harness box<br>- 1 long OBD-C cable<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Volkswagen&model=Tiguan 2018-23">Buy Here</a></sub></details>||
|Volkswagen|Tiguan eHybrid 2021-23|Adaptive Cruise Control (ACC) & Lane Assist|openpilot available[<sup>1,12</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 USB-C coupler<br>- 1 VW J533 connector<br>- 1 comma 3X<br>- 1 harness box<br>- 1 long OBD-C cable<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Volkswagen&model=Tiguan eHybrid 2021-23">Buy Here</a></sub></details>||
|Volkswagen|Touran 2016-23|Adaptive Cruise Control (ACC) & Lane Assist|openpilot available[<sup>1,12</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 USB-C coupler<br>- 1 VW J533 connector<br>- 1 comma 3X<br>- 1 harness box<br>- 1 long OBD-C cable<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Volkswagen&model=Touran 2016-23">Buy Here</a></sub></details>||

2
panda

Submodule panda updated: 0d4b79a3c7...781af8b4f1

View File

@@ -103,7 +103,6 @@ dev = [
"lru-dict",
"matplotlib",
"parameterized >=0.8, <0.9",
#"pprofile",
"pyautogui",
"pyopencl; platform_machine != 'aarch64'", # broken on arm64
"pytools < 2024.1.11; platform_machine != 'aarch64'", # pyopencl use a broken version
@@ -112,13 +111,10 @@ dev = [
"tabulate",
"types-requests",
"types-tabulate",
# this is only pinned since 5.15.11 is broken
"pyqt5 ==5.15.2; platform_machine == 'x86_64'", # no aarch64 wheels for macOS/linux
]
tools = [
"metadrive-simulator @ https://github.com/commaai/metadrive/releases/download/MetaDrive-minimal/metadrive_simulator-0.4.2.3-py3-none-any.whl ; (platform_machine != 'aarch64')",
"metadrive-simulator @ https://github.com/commaai/metadrive/releases/download/MetaDrive-minimal-0.4.2.4/metadrive_simulator-0.4.2.4-py3-none-any.whl ; (platform_machine != 'aarch64')",
"rerun-sdk >= 0.18",
]

View File

@@ -1,39 +0,0 @@
#!/usr/bin/env bash
set -ex
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
cd $DIR
# git clone --mirror
SRC=/tmp/openpilot.git/
OUT=/tmp/smallpilot/
echo "starting size $(du -hs .git/)"
rm -rf $OUT
cd $SRC
git remote update
# copy contents
#rsync -a --exclude='.git/' $DIR $OUT
cp -r $SRC $OUT
cd $OUT
# remove all tags
git tag -l | xargs git tag -d
# remove non-master branches
BRANCHES="release2 release3 devel master-ci nightly"
for branch in $BRANCHES; do
git branch -D $branch
git branch -D ${branch}-staging || true
done
#git gc
git reflog expire --expire=now --all
git gc --prune=now
git gc --aggressive --prune=now
echo "new one is $(du -hs .)"

View File

@@ -1,54 +0,0 @@
#!/usr/bin/env python3
import os
import ast
import stat
import subprocess
fouts = {x.decode('utf-8') for x in subprocess.check_output(['git', 'ls-files']).strip().split()}
pyf = []
for d in ["cereal", "common", "scripts", "selfdrive", "tools"]:
for root, _, files in os.walk(d):
for f in files:
if f.endswith(".py"):
pyf.append(os.path.join(root, f))
imps: set[str] = set()
class Analyzer(ast.NodeVisitor):
def visit_Import(self, node):
for alias in node.names:
imps.add(alias.name)
self.generic_visit(node)
def visit_ImportFrom(self, node):
imps.add(node.module)
self.generic_visit(node)
tlns = 0
carlns = 0
scriptlns = 0
testlns = 0
for f in sorted(pyf):
if f not in fouts:
continue
xbit = bool(os.stat(f)[stat.ST_MODE] & stat.S_IXUSR)
src = open(f).read()
lns = len(src.split("\n"))
tree = ast.parse(src)
Analyzer().visit(tree)
print(f"{lns:5d} {f} {xbit}")
if 'test' in f:
testlns += lns
elif f.startswith(('tools/', 'scripts/', 'selfdrive/debug')):
scriptlns += lns
elif f.startswith('selfdrive/car'):
carlns += lns
else:
tlns += lns
print(f"{tlns} lines of openpilot python")
print(f"{carlns} lines of car ports")
print(f"{scriptlns} lines of tools/scripts/debug")
print(f"{testlns} lines of tests")
#print(sorted(list(imps)))

View File

@@ -1,11 +0,0 @@
#!/usr/bin/env python3
from collections import Counter
from pprint import pprint
from opendbc.car.docs import get_all_car_docs
if __name__ == "__main__":
cars = get_all_car_docs()
make_count = Counter(l.make for l in cars)
print("\n", "*" * 20, len(cars), "total", "*" * 20, "\n")
pprint(make_count)

View File

@@ -1,391 +0,0 @@
#!/usr/bin/env bash
set -e
SRC=/tmp/openpilot/
SRC_CLONE=/tmp/openpilot-clone/
OUT=/tmp/openpilot-tiny/
REWRITE_IGNORE_BRANCHES=(
dashcam3
devel
master-ci
nightly
release2
release3
release3-staging
)
VALIDATE_IGNORE_FILES=(
".github/ISSUE_TEMPLATE/bug_report.md"
".github/pull_request_template.md"
)
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
cd $DIR
LOGS_DIR=$DIR/git-rewrite-$(date +"%Y-%m-%dT%H:%M:%S%z")
mkdir -p $LOGS_DIR
GIT_REWRITE_LOG=$LOGS_DIR/git-rewrite-log.txt
BRANCH_DIFF_LOG=$LOGS_DIR/branch-diff-log.txt
COMMIT_DIFF_LOG=$LOGS_DIR/commit-diff-log.txt
START_TIME=$(date +%s)
exec > >(while IFS= read -r line; do
CURRENT_TIME=$(date +%s)
ELAPSED_TIME=$((CURRENT_TIME - START_TIME))
echo "[${ELAPSED_TIME}s] $line"
done | tee -a "$GIT_REWRITE_LOG") 2>&1
# INSTALL git-filter-repo
if [ ! -f /tmp/git-filter-repo ]; then
echo "Installing git-filter-repo..."
curl -sSo /tmp/git-filter-repo https://raw.githubusercontent.com/newren/git-filter-repo/main/git-filter-repo
chmod +x /tmp/git-filter-repo
fi
# MIRROR openpilot
if [ ! -d $SRC ]; then
echo "Mirroring openpilot..."
git clone --mirror https://github.com/commaai/openpilot.git $SRC # 4.18 GiB (488034 objects)
cd $SRC
echo "Starting size $(du -sh .)"
git remote update
# the git-filter-repo analysis is bliss - can be found in the repo root/filter-repo/analysis
echo "Analyzing with git-filter-repo..."
/tmp/git-filter-repo --force --analyze
echo "Pushing to openpilot-archive..."
# push to archive repo - in smaller parts because the 2 GB push limit - https://docs.github.com/en/get-started/using-git/troubleshooting-the-2-gb-push-limit
ARCHIVE_REPO=git@github.com:commaai/openpilot-archive.git
git push --prune $ARCHIVE_REPO +refs/heads/master:refs/heads/master # push master first so it's the default branch (when openpilot-archive is an empty repo)
git push --prune $ARCHIVE_REPO +refs/heads/*:refs/heads/* # 956.39 MiB (110725 objects)
git push --prune $ARCHIVE_REPO +refs/tags/*:refs/tags/* # 1.75 GiB (21694 objects)
# git push --mirror $ARCHIVE_REPO || true # fails to push refs/pull/* (deny updating a hidden ref) for pull requests
# we fail and continue - more reading: https://stackoverflow.com/a/34266401/639708 and https://blog.plataformatec.com.br/2013/05/how-to-properly-mirror-a-git-repository/
fi
# REWRITE master and tags
if [ ! -d $SRC_CLONE ]; then
echo "Cloning $SRC..."
GIT_LFS_SKIP_SMUDGE=1 git clone $SRC $SRC_CLONE
cd $SRC_CLONE
echo "Checking out old history..."
git checkout tags/v0.7.1 > /dev/null 2>&1
# checkout as main, since we need master ref later
git checkout -b main
echo "Creating setup commits..."
# rm these so we don't get conflicts later
git rm -r cereal opendbc panda selfdrive/ui/ui > /dev/null
git commit -m "removed conflicting files" > /dev/null
# skip-smudge to get rid of some lfs errors that it can't find the reference of some lfs files
# we don't care about fetching/pushing lfs right now
git lfs install --skip-smudge --local
# squash initial setup commits
git cherry-pick -n -X theirs 6c33a5c..59b3d06 > /dev/null
git commit -m "switching to master" > /dev/null
# squash the two commits
git reset --soft HEAD~2
git commit -m "switching to master" -m "$(git log --reverse --format=%B 6c33a5c..59b3d06)" -m "removed conflicting files" > /dev/null
# get commits we want to cherry-pick
# will start with the next commit after #59b3d06 tools is local now
COMMITS=$(git rev-list --reverse 59b3d06..master)
# we need this for logging
TOTAL_COMMITS=$(echo $COMMITS | wc -w | xargs)
CURRENT_COMMIT_NUMBER=0
# empty this file
> commit-map.txt
echo "Rewriting master commits..."
for COMMIT in $COMMITS; do
CURRENT_COMMIT_NUMBER=$((CURRENT_COMMIT_NUMBER + 1))
# echo -ne "[$CURRENT_COMMIT_NUMBER/$TOTAL_COMMITS] Cherry-picking commit: $COMMIT"\\r
echo "[$CURRENT_COMMIT_NUMBER/$TOTAL_COMMITS] Cherry-picking commit: $COMMIT"
# set environment variables to preserve author/committer and dates
export GIT_AUTHOR_NAME=$(git show -s --format='%an' $COMMIT)
export GIT_AUTHOR_EMAIL=$(git show -s --format='%ae' $COMMIT)
export GIT_COMMITTER_NAME=$(git show -s --format='%cn' $COMMIT)
export GIT_COMMITTER_EMAIL=$(git show -s --format='%ce' $COMMIT)
export GIT_AUTHOR_DATE=$(git show -s --format='%ad' $COMMIT)
export GIT_COMMITTER_DATE=$(git show -s --format='%cd' $COMMIT)
# cherry-pick the commit
if ! GIT_OUTPUT=$(git cherry-pick -m 1 -X theirs $COMMIT 2>&1); then
# check if the failure is because of an empty commit
if [[ "$GIT_OUTPUT" == *"The previous cherry-pick is now empty"* ]]; then
echo "Empty commit detected. Skipping commit $COMMIT"
git cherry-pick --skip
# log it was empty to the mapping file
echo "$COMMIT EMPTY" >> commit-map.txt
else
# handle other errors or conflicts
echo "Cherry-pick failed. Handling error..."
echo "$GIT_OUTPUT"
exit 1
fi
else
# capture the new commit hash
NEW_COMMIT=$(git rev-parse HEAD)
# save the old and new commit hashes to the mapping file
echo "$COMMIT $NEW_COMMIT" >> commit-map.txt
# append the old commit ID to the commit message
git commit --amend -m "$(git log -1 --pretty=%B)" -m "Former-commit-id: $COMMIT" > /dev/null
fi
# prune every 3000 commits to avoid gc errors
if [ $((CURRENT_COMMIT_NUMBER % 3000)) -eq 0 ]; then
echo "Pruning repo..."
git gc
fi
done
echo "Rewriting tags..."
# remove all old tags
git tag -l | xargs git tag -d
# read each line from the tag-commit-map.txt
while IFS=' ' read -r TAG OLD_COMMIT; do
# search for the new commit in commit-map.txt corresponding to the old commit
NEW_COMMIT=$(grep "^$OLD_COMMIT " "commit-map.txt" | awk '{print $2}')
# check if this is a rebased commit
if [ -z "$NEW_COMMIT" ]; then
# if not, then just use old commit hash
NEW_COMMIT=$OLD_COMMIT
fi
echo "Rewriting tag $TAG from commit $NEW_COMMIT"
git tag -f "$TAG" "$NEW_COMMIT"
done < "$DIR/tag-commit-map.txt"
# uninstall lfs since we don't want to touch (push to) lfs right now
# git push will also push lfs, if we don't uninstall (--local so just for this repo)
git lfs uninstall --local
# force push new master
git push --force origin main:master
# force push new tags
git push --force --tags
fi
# REWRITE branches based on master
if [ ! -f "$SRC_CLONE/rewrite-branches-done" ]; then
cd $SRC_CLONE
> rewrite-branches-done
# empty file
> $BRANCH_DIFF_LOG
echo "Rewriting branches based on master..."
# will store raw diffs here, if exist
mkdir -p differences
# get a list of all branches except master and REWRITE_IGNORE_BRANCHES
BRANCHES=$(git branch -r | grep -v ' -> ' | sed 's/.*origin\///' | grep -v '^master$' | grep -v -f <(echo "${REWRITE_IGNORE_BRANCHES[*]}" | tr ' ' '\n'))
for BRANCH in $BRANCHES; do
# check if the branch is based on master history
MERGE_BASE=$(git merge-base master origin/$BRANCH) || true
if [ -n "$MERGE_BASE" ]; then
echo "Rewriting branch: $BRANCH"
# create a new branch based on the new master
NEW_MERGE_BASE=$(grep "^$MERGE_BASE " "commit-map.txt" | awk '{print $2}')
if [ -z "$NEW_MERGE_BASE" ]; then
echo "Error: could not find new merge base for branch $BRANCH" >> $BRANCH_DIFF_LOG
continue
fi
git checkout -b ${BRANCH}_new $NEW_MERGE_BASE
# get the range of commits unique to this branch
COMMITS=$(git rev-list --reverse $MERGE_BASE..origin/${BRANCH})
HAS_ERROR=0
# simple delimiter
echo "BRANCH ${BRANCH}" >> commit-map.txt
for COMMIT in $COMMITS; do
# set environment variables to preserve author/committer and dates
export GIT_AUTHOR_NAME=$(git show -s --format='%an' $COMMIT)
export GIT_AUTHOR_EMAIL=$(git show -s --format='%ae' $COMMIT)
export GIT_COMMITTER_NAME=$(git show -s --format='%cn' $COMMIT)
export GIT_COMMITTER_EMAIL=$(git show -s --format='%ce' $COMMIT)
export GIT_AUTHOR_DATE=$(git show -s --format='%ad' $COMMIT)
export GIT_COMMITTER_DATE=$(git show -s --format='%cd' $COMMIT)
# cherry-pick the commit
if ! GIT_OUTPUT=$(git cherry-pick -m 1 -X theirs $COMMIT 2>&1); then
# check if the failure is because of an empty commit
if [[ "$GIT_OUTPUT" == *"The previous cherry-pick is now empty"* ]]; then
echo "Empty commit detected. Skipping commit $COMMIT"
git cherry-pick --skip
# log it was empty to the mapping file
echo "$COMMIT EMPTY" >> commit-map.txt
else
# handle other errors or conflicts
echo "Cherry-pick of ${BRANCH} branch failed. Removing branch upstream..." >> $BRANCH_DIFF_LOG
echo "$GIT_OUTPUT" > "$LOGS_DIR/branch-${BRANCH}"
git cherry-pick --abort
git push --delete origin ${BRANCH}
HAS_ERROR=1
break
fi
else
# capture the new commit hash
NEW_COMMIT=$(git rev-parse HEAD)
# save the old and new commit hashes to the mapping file
echo "$COMMIT $NEW_COMMIT" >> commit-map.txt
# append the old commit ID to the commit message
git commit --amend -m "$(git log -1 --pretty=%B)" -m "Former-commit-id: $COMMIT" > /dev/null
fi
done
# force push the new branch
if [ $HAS_ERROR -eq 0 ]; then
# git lfs goes haywire here, so we need to install and uninstall
# git lfs install --skip-smudge --local
git lfs uninstall --local > /dev/null
git push -f origin ${BRANCH}_new:${BRANCH}
fi
# clean up local branch
git checkout master > /dev/null
git branch -D ${BRANCH}_new > /dev/null
else
echo "Deleting branch $BRANCH as it's not based on master history" >> $BRANCH_DIFF_LOG
git push --delete origin ${BRANCH}
fi
done
fi
# VALIDATE cherry-pick
if [ ! -f "$SRC_CLONE/validation-done" ]; then
cd $SRC_CLONE
> validation-done
TOTAL_COMMITS=$(grep -cve '^\s*$' commit-map.txt)
CURRENT_COMMIT_NUMBER=0
COUNT_SAME=0
COUNT_DIFF=0
# empty file
> $COMMIT_DIFF_LOG
echo "Validating commits..."
# will store raw diffs here, if exist
mkdir -p differences
# read each line from commit-map.txt
while IFS=' ' read -r OLD_COMMIT NEW_COMMIT; do
if [ "$NEW_COMMIT" == "EMPTY" ]; then
continue
fi
if [ "$OLD_COMMIT" == "BRANCH" ]; then
echo "Branch ${NEW_COMMIT} below:" >> $COMMIT_DIFF_LOG
continue
fi
CURRENT_COMMIT_NUMBER=$((CURRENT_COMMIT_NUMBER + 1))
# retrieve short hashes and dates for the old and new commits
OLD_COMMIT_SHORT=$(git rev-parse --short $OLD_COMMIT)
NEW_COMMIT_SHORT=$(git rev-parse --short $NEW_COMMIT)
OLD_DATE=$(git show -s --format='%cd' $OLD_COMMIT)
NEW_DATE=$(git show -s --format='%cd' $NEW_COMMIT)
# echo -ne "[$CURRENT_COMMIT_NUMBER/$TOTAL_COMMITS] Comparing old commit $OLD_COMMIT_SHORT ($OLD_DATE) with new commit $NEW_COMMIT_SHORT ($NEW_DATE)"\\r
echo "[$CURRENT_COMMIT_NUMBER/$TOTAL_COMMITS] Comparing old commit $OLD_COMMIT_SHORT ($OLD_DATE) with new commit $NEW_COMMIT_SHORT ($NEW_DATE)"
# generate lists of files and their hashes for the old and new commits, excluding ignored files
OLD_FILES=$(git ls-tree -r $OLD_COMMIT | grep -vE "$(IFS='|'; echo "${VALIDATE_IGNORE_FILES[*]}")")
NEW_FILES=$(git ls-tree -r $NEW_COMMIT | grep -vE "$(IFS='|'; echo "${VALIDATE_IGNORE_FILES[*]}")")
# Compare the diffs
if diff <(echo "$OLD_FILES") <(echo "$NEW_FILES") > /dev/null; then
# echo "Old commit $OLD_COMMIT_SHORT and new commit $NEW_COMMIT_SHORT are equivalent."
COUNT_SAME=$((COUNT_SAME + 1))
else
echo "[$CURRENT_COMMIT_NUMBER/$TOTAL_COMMITS] Difference found between old commit $OLD_COMMIT_SHORT and new commit $NEW_COMMIT_SHORT" >> $COMMIT_DIFF_LOG
COUNT_DIFF=$((COUNT_DIFF + 1))
set +e
diff -u <(echo "$OLD_FILES") <(echo "$NEW_FILES") > "$LOGS_DIR/commit-$CURRENT_COMMIT_NUMBER-$OLD_COMMIT_SHORT-$NEW_COMMIT_SHORT"
set -e
fi
done < "commit-map.txt"
echo "Summary:" >> $COMMIT_DIFF_LOG
echo "Equivalent commits: $COUNT_SAME" >> $COMMIT_DIFF_LOG
echo "Different commits: $COUNT_DIFF" >> $COMMIT_DIFF_LOG
fi
if [ ! -d $OUT ]; then
cp -r $SRC $OUT
cd $OUT
# remove all non-master branches
# git branch | grep -v "^ master$" | grep -v "\*" | xargs git branch -D
# echo "cleaning up refs"
# delete pull request refs since we can't alter them anyway (https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally#error-failed-to-push-some-refs)
# git for-each-ref --format='%(refname)' | grep '^refs/pull/' | xargs -I {} git update-ref -d {}
echo "importing new lfs files"
# import "almost" everything to lfs
BRANCHES=$(git for-each-ref --format='%(refname)' refs/heads/ | sed 's%refs/heads/%%g' | grep -v -f <(echo "${REWRITE_IGNORE_BRANCHES[*]}" | tr ' ' '\n') | tr '\n' ' ')
git lfs migrate import --include="*.dlc,*.onnx,*.svg,*.png,*.gif,*.ttf,*.wav,selfdrive/car/tests/test_models_segs.txt,system/hardware/tici/updater,selfdrive/ui/qt/spinner_larch64,selfdrive/ui/qt/text_larch64,third_party/**/*.a,third_party/**/*.so,third_party/**/*.so.*,third_party/**/*.dylib,third_party/acados/*/t_renderer,third_party/qt5/larch64/bin/lrelease,third_party/qt5/larch64/bin/lupdate,third_party/catch2/include/catch2/catch.hpp,*.apk,*.apkpatch,*.jar,*.pdf,*.jpg,*.mp3,*.thneed,*.tar.gz,*.npy,*.csv,*.a,*.so*,*.dylib,*.o,*.b64,selfdrive/hardware/tici/updater,selfdrive/boardd/tests/test_boardd,selfdrive/ui/qt/spinner_aarch64,installer/updater/updater,selfdrive/debug/profiling/simpleperf/**/*,selfdrive/hardware/eon/updater,selfdrive/ui/qt/text_aarch64,selfdrive/debug/profiling/pyflame/**/*,installer/installers/installer_openpilot,installer/installers/installer_dashcam,selfdrive/ui/text/text,selfdrive/ui/android/text/text,selfdrive/ui/spinner/spinner,selfdrive/visiond/visiond,selfdrive/loggerd/loggerd,selfdrive/sensord/sensord,selfdrive/sensord/gpsd,selfdrive/ui/android/spinner/spinner,selfdrive/ui/qt/spinner,selfdrive/ui/qt/text,_stringdefs.py,dfu-util-aarch64-linux,dfu-util-aarch64,dfu-util-x86_64-linux,dfu-util-x86_64,stb_image.h,clpeak3,clwaste,apk/**/*,external/**/*,phonelibs/**/*,third_party/boringssl/**/*,flask/**/*,panda/**/*,board/**/*,messaging/**/*,opendbc/**/*,tools/cabana/chartswidget.cc,third_party/nanovg/**/*,selfdrive/controls/lib/lateral_mpc/lib_mpc_export/**/*,selfdrive/ui/paint.cc,werkzeug/**/*,pyextra/**/*,third_party/android_hardware_libhardware/**/*,selfdrive/controls/lib/lead_mpc_lib/lib_mpc_export/**/*,selfdrive/locationd/laikad.py,selfdrive/locationd/test/test_laikad.py,tools/gpstest/test_laikad.py,selfdrive/locationd/laikad_helpers.py,tools/nui/**/*,jsonrpc/**/*,selfdrive/controls/lib/longitudinal_mpc/lib_mpc_export/**/*,selfdrive/controls/lib/lateral_mpc/mpc_export/**/*,selfdrive/camerad/cameras/camera_qcom.cc,selfdrive/manager.py,selfdrive/modeld/models/driving.cc,third_party/curl/**/*,selfdrive/modeld/thneed/debug/**/*,selfdrive/modeld/thneed/include/**/*,third_party/openmax/**/*,selfdrive/controls/lib/longitudinal_mpc/mpc_export/**/*,selfdrive/controls/lib/longitudinal_mpc_model/lib_mpc_export/**/*,Pipfile,Pipfile.lock,gunicorn/**/*,*.qm,jinja2/**/*,click/**/*,dbcs/**/*,websocket/**/*" $BRANCHES
echo "reflog and gc"
# this is needed after lfs import
git reflog expire --expire=now --all
git gc --prune=now --aggressive
# check the git-filter-repo analysis again - can be found in the repo root/filter-repo/analysis
echo "Analyzing with git-filter-repo..."
/tmp/git-filter-repo --force --analyze
echo "New size is $(du -sh .)"
fi
cd $OUT
# fetch all lfs files from https://github.com/commaai/openpilot.git
# some lfs files are missing on gitlab, but they can be found on github
git config lfs.url https://github.com/commaai/openpilot.git/info/lfs
git config lfs.pushurl ssh://git@github.com/commaai/openpilot.git
git lfs fetch --all || true
# also fetch all lfs files from https://gitlab.com/commaai/openpilot-lfs.git
git config lfs.url https://gitlab.com/commaai/openpilot-lfs.git/info/lfs
git config lfs.pushurl ssh://git@gitlab.com/commaai/openpilot-lfs.git
git lfs fetch --all || true
# final push - will also push lfs
# TODO: switch to git@github.com:commaai/openpilot.git when ready
# git push --mirror git@github.com:commaai/openpilot-tiny.git
# using this instead to ignore refs/pull/* - since this is also what --mirror does - https://blog.plataformatec.com.br/2013/05/how-to-properly-mirror-a-git-repository/
git push --prune git@github.com:commaai/openpilot-tiny.git +refs/heads/*:refs/heads/* +refs/tags/*:refs/tags/*

View File

@@ -1,59 +0,0 @@
#!/usr/bin/env bash
set -e
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
cd $DIR
git clone --bare https://github.com/commaai/openpilot
cp -r openpilot.git openpilot_backup
cd openpilot.git
# backup old repo
git push git@github.com:commaai/openpilot-archive.git +refs/heads/master:refs/heads/master
git push git@github.com:commaai/openpilot-archive.git +refs/heads/*:refs/heads/*
git push git@github.com:commaai/openpilot-archive.git +refs/tags/*:refs/tags/*
git push --mirror git@github.com:commaai/openpilot-archive.git
# ignore all release branches
git for-each-ref --format='delete %(refname)' | grep 'dashcam3\|devel\|master-ci\|nightly\|release2\|release3\|release3-staging' | git update-ref --stdin
# re-tag old releases on master
declare -A TAGS=( ["f8cb04e4a8b032b72a909f68b808a50936184bee"]="v0.9.7" ["0b4d08fab8e35a264bc7383e878538f8083c33e5"]="v0.9.6" ["3b1e9017c560499786d8a0e46aaaeea65037acac"]="v0.9.5" ["fa310d9e2542cf497d92f007baec8fd751ffa99c"]="v0.9.4" ["8704c1ff952b5c85a44f50143bbd1a4f7b4887e2"]="v0.9.3" ["c7d3b28b93faa6c955fb24bc64031512ee985ee9"]="v0.9.2" ["89f68bf0cbf53a81b0553d3816fdbe522f941fa1"]="v0.9.1" ["58b84fb401a804967aa0dd5ee66fafa90194fd30"]="v0.9.0" ["f41dc62a12cc0f3cb8c5453c0caa0ba21e1bd01e"]="v0.8.16" ["5a7c2f90361e72e9c35e88abd2e11acdc4aba354"]="v0.8.15" ["71901c94dbbaa2f9f156a80c14cc7ea65219fc7c"]="v0.8.14" ["95da47079510afc91665263619e5939126da637c"]="v0.8.13" ["472177e2a8a1d002e56f9096326fd2dff62e54f9"]="v0.8.12" ["08078acbd0b4f7da469c7dff6159000e358974a9"]="v0.8.11" ["687925c775c375495f9827946138a724bde00b9d"]="v0.8.10" ["204e5a090735a059d69c29145a4cee49450da07e"]="v0.8.9" ["4be956f8861ecbb521ef9503a3c87b07c9d36721"]="v0.8.8" ["589f82c76627d634761a31a34b2488403556eb0b"]="v0.8.7" ["507cfc8910f74ddb8810039d68b880b426ff9ff9"]="v0.8.6" ["d47b00b45a866bef088f51d1ff31de5885ab04e9"]="v0.8.5" ["553e7d1cce314e7eb0587186b1764c3ff43bed62"]="v0.8.4" ["9896438d1511602a1ff87f7c4eb3c7172b30104a"]="v0.8.3" ["280192ed1443f112463417c2d815ea8ee2762fbd"]="v0.8.2" ["8039361567e4659eae2a084e6f39f34acadf4cac"]="v0.8.1" ["d56e04c0d960c8d3d4ab88b578dc508a2b4e07dc"]="v0.8" ["3d456e5d0fbf0c9887d0499dee812f2b029edf6d"]="v0.7.10" ["81763a18b5d0e379b749e090ecce36a91fca7c43"]="v0.7.9" ["9bc0b350fd273bbb2deb3dcaef0312944e4f6cfd"]="v0.7.8" ["ede5b632b58c55e4ff003f948efae07fe03c2280"]="v0.7.7" ["775acd11ba2e0a8c2f5a5655338718d796491b36"]="v0.7.6.1" ["302417b4cf0dcf00d45e4995b5410e543ad121d1"]="v0.7.5" ["12ff088b42221dd17d9d97decb1fc61a7cb0a861"]="v0.7.4" ["9563f7730252451fdcba9bc3d9fe36dab9c86a26"]="v0.7.3" ["8321cf283abbc2ca3fda7e0c7a069a77a492fe0c"]="v0.7.2" ["1e1de64a1e59476b7b3d3558b92149246d5c3292"]="v0.7.1" ["a2ae18d1dbd1e59c38ce22fa25ddffbd1d3084e3"]="v0.7" ["d4eb5a6eafdd4803d09e6f3963918216cca5a81f"]="v0.6.6" ["70d17cd69b80e7627dcad8fd5b6438f2309ac307"]="v0.6.5" ["58f376002e0c654fbc2de127765fa297cf694a33"]="v0.6.4" ["d5f9caa82d80cdcc7f1b7748f2cf3ccbf94f82a3"]="v0.6.3" ["095ef5f9f60fca1b269aabcc3cfd322b17b9e674"]="v0.6.2" ["cf5c4aeacb1703d0ffd35bdb5297d3494fee9a22"]="v0.6.1" ["60a20537c5f3fcc7f11946d81aebc8f90c08c117"]="v0.6" ["dd34ccfe288ebda8e2568cf550994ae890379f45"]="v0.5.13" ["3f9059fea886f1fa3b0c19a62a981d891dcc84eb"]="v0.5.12" ["2f92d577f995ff6ae1945ef6b89df3cb69b92999"]="v0.5.11" ["5a9d89ed42ddcd209d001a10d7eb828ef0e6d9de"]="v0.5.10" ["0207a970400ee28d3e366f2e8f5c551281accf02"]="v0.5.9" ["b967da5fc1f7a07e3561db072dd714d325e857b0"]="v0.5.8" ["210db686bb89f8696aa040e6e16de65424b808c9"]="v0.5.7" ["860a48765d1016ba226fb2c64aea35a45fe40e4a"]="v0.5.6" ["8f3539a27b28851153454eb737da9624cccaed2d"]="v0.5.5" ["a422246dc30bce11e970514f13f7c110f4470cc3"]="v0.5.4" ["285c52eb693265a0a530543e9ca0aeb593a2a55e"]="v0.5.3" ["0129a8a4ff8da5314e8e4d4d3336e89667ff6d54"]="v0.5.2" ["6f3d10a4c475c4c4509f0b370805419acd13912d"]="v0.5.1" ["de33bc46452b1046387ee2b3a03191b2c71135fb"]="v0.5" ["ae5cb7a0dab8b1bed9d52292f9b4e8e66a0f8ec9"]="v0.4.7" ["c6df34f55ba8c5a911b60d3f9eb20e3fa45f68c1"]="v0.4.6" ["37285038d3f91fa1b49159c4a35a8383168e644f"]="v0.4.5" ["9a9ff839a9b70cb2601d7696af743f5652395389"]="v0.4.4" ["28c0797d30175043bbfa31307b63aab4197cf996"]="v0.4.2" ["4474b9b3718653aeb0aee26422caefb90460cc0e"]="v0.4.1" ["da52d065a4c4f52d6017a537f3a80326f5af8bdc"]="v0.4.0.2" ["9d3963559ae7b15193057937ff3e72481899f40d"]="v0.3.5" ["1b8c44b5067525a5d266b6e99799d8097da76a29"]="v0.3.4" ["5cf91d0496688fed4f2a6c7021349b1fc0e057a2"]="v0.3.3" ["7fe46f1e1df5dec08a940451ba0feefd5c039165"]="v0.3.2" ["41e3a0f699f5c39cb61a15c0eb7a4aa816d47c24"]="v0.3.1" ["c5d8aec28b5230d34ae4b677c2091cc3dec7e3e8"]="v0.3.0" ["693bcb0f83478f2651db6bac9be5ca5ad60d03f3"]="v0.2.9" ["95a349abcc050712c50d4d85a1c8a804eee7f6c2"]="v0.2.8" ["c6ba5dc5391d3ca6cda479bf1923b88ce45509a0"]="v0.2.7" ["6c3afeec0fb439070b2912978b8dbb659033b1d9"]="v0.2.6" ["29c58b45882ac79595356caf98580c1d2a626011"]="v0.2.5" ["ecc565aa3fdc4c7e719aadc000e1fdc4d80d4fe0"]="v0.2.4" ["adaa4ed350acda4067fc0b455ad15b54cdf4c768"]="v0.2.3" ["a64b9aa9b8cb5863c917b6926516291a63c02fe5"]="v0.2.2" ["17d9becd3c673091b22f09aa02559a9ed9230f50"]="v0.2.1" ["449b482cc3236ccf31829830b4f6a44b2dcc06c2"]="v0.2" ["e94a30bec07e719c5a7b037ca1f4db8312702cce"]="v0.1" )
for tag in "${!TAGS[@]}"; do git tag -f "${TAGS[$tag]}" "$tag" ; done
# get master root commit
ROOT_COMMIT=$(git rev-list --max-parents=0 HEAD | tail -n 1)
# link master and devel
git replace --graft $ROOT_COMMIT v0.7.1
git-filter-repo --prune-empty never --force --commit-callback 'h=commit.original_id.decode("utf-8");m=commit.message.decode("utf-8");commit.message=str.encode(m + "\n" + "old-commit-hash: " + h)'
# delete replace refs
git for-each-ref --format='delete %(refname)' refs/replace | git update-ref --stdin
# machine validation
tail -n +2 "filter-repo/commit-map" | tr ' ' '\n' | xargs -P $(nproc) -n 2 bash -c 'H1=$(cd ../openpilot_backup && git ls-tree -r $0 | sha1sum) && H2=$(git ls-tree -r $1 | sha1sum) && echo "$H1 $H2" >> /tmp/GIT_HASHES && diff <(echo $H1) <(echo $H2) || exit 255'
# human validation
less /tmp/GIT_HASH
# cleanup
git reflog expire --expire=now --all
git gc --prune=now --aggressive
# get all lfs files
set +e
git config lfs.url https://github.com/commaai/openpilot.git/info/lfs
git lfs fetch --all
git config lfs.url https://gitlab.com/commaai/openpilot-lfs.git/info/lfs
git lfs fetch --all
set -e
# add new files to lfs
git lfs migrate import --everything --include="*.ico,*.dlc,*.onnx,*.svg,*.png,*.gif,*.ttf,*.wav,system/hardware/tici/updater,selfdrive/ui/qt/spinner_larch64,selfdrive/ui/qt/text_larch64,third_party/**/*.a,third_party/**/*.so,third_party/**/*.so.*,third_party/**/*.dylib,third_party/acados/*/t_renderer,third_party/qt5/larch64/bin/lrelease,third_party/qt5/larch64/bin/lupdate,third_party/catch2/include/catch2/catch.hpp,*.apk,*.apkpatch,*.jar,*.pdf,*.jpg,*.mp3,*.thneed,*.tar.gz,*.npy,*.csv,*.a,*.so*,*.dylib,*.o,*.b64,selfdrive/hardware/tici/updater,selfdrive/boardd/tests/test_boardd,selfdrive/ui/qt/spinner_aarch64,installer/updater/updater,selfdrive/debug/profiling/simpleperf/**/*,selfdrive/hardware/eon/updater,selfdrive/ui/qt/text_aarch64,selfdrive/debug/profiling/pyflame/**/*,installer/installers/installer_openpilot,installer/installers/installer_dashcam,selfdrive/ui/text/text,selfdrive/ui/android/text/text,selfdrive/ui/spinner/spinner,selfdrive/visiond/visiond,selfdrive/loggerd/loggerd,selfdrive/sensord/sensord,selfdrive/sensord/gpsd,selfdrive/ui/android/spinner/spinner,selfdrive/ui/qt/spinner,selfdrive/ui/qt/text,_stringdefs.py,dfu-util-aarch64-linux,dfu-util-aarch64,dfu-util-x86_64-linux,dfu-util-x86_64,stb_image.h,clpeak3,clwaste,apk/**/*,external/**/*,phonelibs/**/*,third_party/boringssl/**/*,pyextra/**/*,panda/board/**/inc/*.h,panda/board/obj/*.elf,board/inc/*.h,third_party/nanovg/**/*,selfdrive/controls/lib/lateral_mpc/lib_mpc_export/**/*,pyextra/**/*,third_party/android_hardware_libhardware/**/*,selfdrive/controls/lib/lead_mpc_lib/lib_mpc_export/**/*,*.pro,selfdrive/controls/lib/longitudinal_mpc/lib_mpc_export/**/*,selfdrive/controls/lib/lateral_mpc/mpc_export/**/*,third_party/curl/**/*,selfdrive/modeld/thneed/debug/**/*,selfdrive/modeld/thneed/include/**/*,third_party/openmax/**/*,selfdrive/controls/lib/longitudinal_mpc/mpc_export/**/*,selfdrive/controls/lib/longitudinal_mpc_model/lib_mpc_export/**/*,Pipfile,Pipfile.lock,poetry.lock,*.qm"
# set new lfs endpoint
git config lfs.url https://gitlab.com/commaai/openpilot-lfs.git/info/lfs
git config lfs.pushurl ssh://git@gitlab.com/commaai/openpilot-lfs.git
# push all branch+tag (scary stuff...)
git push -f --set-upstream git@github.com:commaai/openpilot.git +refs/heads/*:refs/heads/* +refs/tags/*:refs/tags/*

View File

@@ -1,82 +0,0 @@
v0.1 e94a30bec07e719c5a7b037ca1f4db8312702cce
v0.2 449b482cc3236ccf31829830b4f6a44b2dcc06c2
v0.2.1 17d9becd3c673091b22f09aa02559a9ed9230f50
v0.2.2 a64b9aa9b8cb5863c917b6926516291a63c02fe5
v0.2.3 adaa4ed350acda4067fc0b455ad15b54cdf4c768
v0.2.4 ecc565aa3fdc4c7e719aadc000e1fdc4d80d4fe0
v0.2.5 29c58b45882ac79595356caf98580c1d2a626011
v0.2.6 6c3afeec0fb439070b2912978b8dbb659033b1d9
v0.2.7 c6ba5dc5391d3ca6cda479bf1923b88ce45509a0
v0.2.8 95a349abcc050712c50d4d85a1c8a804eee7f6c2
v0.2.9 693bcb0f83478f2651db6bac9be5ca5ad60d03f3
v0.3.0 c5d8aec28b5230d34ae4b677c2091cc3dec7e3e8
v0.3.1 41e3a0f699f5c39cb61a15c0eb7a4aa816d47c24
v0.3.2 7fe46f1e1df5dec08a940451ba0feefd5c039165
v0.3.3 5cf91d0496688fed4f2a6c7021349b1fc0e057a2
v0.3.4 1b8c44b5067525a5d266b6e99799d8097da76a29
v0.3.5 b111277f464cf66fa34b67819a83ea683e0f64df
v0.4.0.2 da52d065a4c4f52d6017a537f3a80326f5af8bdc
v0.4.1 4474b9b3718653aeb0aee26422caefb90460cc0e
v0.4.2 28c0797d30175043bbfa31307b63aab4197cf996
v0.4.4 9a9ff839a9b70cb2601d7696af743f5652395389
v0.4.5 37285038d3f91fa1b49159c4a35a8383168e644f
v0.4.6 c6df34f55ba8c5a911b60d3f9eb20e3fa45f68c1
v0.4.7 ae5cb7a0dab8b1bed9d52292f9b4e8e66a0f8ec9
v0.5 de33bc46452b1046387ee2b3a03191b2c71135fb
v0.5.1 8f22f52235c48eada586795ac57edb22688e4d08
v0.5.2 0129a8a4ff8da5314e8e4d4d3336e89667ff6d54
v0.5.3 285c52eb693265a0a530543e9ca0aeb593a2a55e
v0.5.4 a422246dc30bce11e970514f13f7c110f4470cc3
v0.5.5 8f3539a27b28851153454eb737da9624cccaed2d
v0.5.6 860a48765d1016ba226fb2c64aea35a45fe40e4a
v0.5.7 9ce3045f139ee29bf0eea5ec59dfe7df9c3d2c51
v0.5.8 2cee2e05ba0f3824fdbb8b957958800fa99071a1
v0.5.9 ad145da3bcded0fe75306df02061d07a633963c3
v0.5.10 ff4c1557d8358f158f4358788ff18ef93d2470ef
v0.5.11 d1866845df423c6855e2b365ff230cf7d89a420b
v0.5.12 f6e8ef27546e9a406724841e75f8df71cc4c2c97
v0.5.13 dd34ccfe288ebda8e2568cf550994ae890379f45
v0.6 60a20537c5f3fcc7f11946d81aebc8f90c08c117
v0.6.1 cf5c4aeacb1703d0ffd35bdb5297d3494fee9a22
v0.6.2 095ef5f9f60fca1b269aabcc3cfd322b17b9e674
v0.6.3 d5f9caa82d80cdcc7f1b7748f2cf3ccbf94f82a3
v0.6.4 58f376002e0c654fbc2de127765fa297cf694a33
v0.6.5 70d17cd69b80e7627dcad8fd5b6438f2309ac307
v0.6.6 d4eb5a6eafdd4803d09e6f3963918216cca5a81f
v0.7 a2ae18d1dbd1e59c38ce22fa25ddffbd1d3084e3
v0.7.1 1e1de64a1e59476b7b3d3558b92149246d5c3292
v0.7.2 59bd58c940673b4c4a6a86f299022614bcf42b22
v0.7.3 d7acd8b68f8131e0e714400cf124a3e228638643
v0.7.4 e93649882c5e914eec4a8b8b593dc0587e497033
v0.7.5 8abc0afe464626a461d2c7e192c912eeebeccc65
v0.7.6 69aacd9d179fe6dd3110253a099c38b34cff7899
v0.7.7 f1caed7299cdba5e45635d8377da6cc1e5fd7072
v0.7.8 2189fe8741b635d8394d55dee28959425cfd5ad0
v0.7.9 86dc54b836a973f132ed26db9f5a60b29f9b25b2
v0.7.10 47a42ff432db8a2494e922ca5e767e58020f0446
v0.7.11 f46ed718ba8d6bb4d42cd7b0f0150c406017c373
v0.8 d56e04c0d960c8d3d4ab88b578dc508a2b4e07dc
v0.8.1 cd6f26664cb8d32a13847d6648567c47c580e248
v0.8.2 7cc0999aebfe63b6bb6dd83c1dff62c3915c4820
v0.8.3 986500fe2f10870018f1fba1e5465476b8915977
v0.8.4 f0d0b82b8d6f5f450952113e234d0a5a49e80c48
v0.8.5 f5d9ddc6c2a2802a61e5ce590c6b6688bf736a69
v0.8.6 75904ed7452c6cbfb2a70cd379a899d8a75b97c2
v0.8.7 4f9e568019492126e236da85b5ca0a059f292900
v0.8.8 a949a49d5efaaf2d881143d23e9fb5ff9e28e88c
v0.8.9 a034926264cd1025c69d6ceb3fe444965f960b75
v0.8.10 59accdd814398b884167c0f41dbf46dcccf0c29c
v0.8.11 d630ec9092f039cb5e51c5dd6d92fc47b91407e4
v0.8.12 57871c99031cf597ffa0d819057ac1401e129f32
v0.8.13 e43e6e876513450d235124fcb711f1724ed9814c
v0.8.14 71901c94dbbaa2f9f156a80c14cc7ea65219fc7c
v0.8.15 5a7c2f90361e72e9c35e88abd2e11acdc4aba354
v0.8.16 f41dc62a12cc0f3cb8c5453c0caa0ba21e1bd01e
v0.9.0 58b84fb401a804967aa0dd5ee66fafa90194fd30
v0.9.1 89f68bf0cbf53a81b0553d3816fdbe522f941fa1
v0.9.2 c7d3b28b93faa6c955fb24bc64031512ee985ee9
v0.9.3 8704c1ff952b5c85a44f50143bbd1a4f7b4887e2
v0.9.4 fa310d9e2542cf497d92f007baec8fd751ffa99c
v0.9.5 3b1e9017c560499786d8a0e46aaaeea65037acac
v0.9.6 0b4d08fab8e35a264bc7383e878538f8083c33e5
v0.9.7 f8cb04e4a8b032b72a909f68b808a50936184bee

View File

@@ -1,14 +0,0 @@
#!/usr/bin/env python3
from PyQt5.QtWidgets import QApplication, QLabel
from openpilot.selfdrive.ui.qt.python_helpers import set_main_window
if __name__ == "__main__":
app = QApplication([])
label = QLabel('Hello World!')
# Set full screen and rotate
set_main_window(label)
app.exec_()

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:fa3f1c39a4e82adfb52d43fc0ad6773a70dbaa4fc79109a7d6b6c1f73b298eac
size 2833

View File

@@ -30,7 +30,7 @@ if __name__ == '__main__':
elif event.type == 3 and event.code == 57 and event.value == -1:
fingers[current_slot] = [-1, -1]
elif event.type == 3 and event.code == 53:
fingers[current_slot][1] = h - (h - event.value)
fingers[current_slot][1] = event.value
if fingers[current_slot][0] != -1:
touch_points.append(fingers[current_slot].copy())
elif event.type == 3 and event.code == 54:

View File

@@ -26,10 +26,6 @@ for pathdef, fn in {'TRANSFORM': 'transforms/transform.cl', 'LOADYUV': 'transfor
xenv['CXXFLAGS'].append(f'-D{pathdef}_PATH=\\"{File(fn).abspath}\\"')
# Compile cython
snpe_rpath_qcom = "/data/pythonpath/third_party/snpe/larch64"
snpe_rpath_pc = f"{Dir('#').abspath}/third_party/snpe/x86_64-linux-clang"
snpe_rpath = lenvCython['RPATH'] + [snpe_rpath_qcom if arch == "larch64" else snpe_rpath_pc]
cython_libs = envCython["LIBS"] + libs
commonmodel_lib = lenv.Library('commonmodel', common_src)
lenvCython.Program('models/commonmodel_pyx.so', 'models/commonmodel_pyx.pyx', LIBS=[commonmodel_lib, *cython_libs], FRAMEWORKS=frameworks)

View File

@@ -16,7 +16,6 @@ class ModelConstants:
MODEL_FREQ = 20
FEATURE_LEN = 512
FULL_HISTORY_BUFFER_LEN = 99
HISTORY_BUFFER_LEN = 24
DESIRE_LEN = 8
TRAFFIC_CONVENTION_LEN = 2
LAT_PLANNER_STATE_LEN = 4
@@ -73,14 +72,13 @@ class Plan:
class Meta:
ENGAGED = slice(0, 1)
# next 2, 4, 6, 8, 10 seconds
GAS_DISENGAGE = slice(1, 31, 6)
BRAKE_DISENGAGE = slice(2, 31, 6)
STEER_OVERRIDE = slice(3, 31, 6)
HARD_BRAKE_3 = slice(4, 31, 6)
HARD_BRAKE_4 = slice(5, 31, 6)
HARD_BRAKE_5 = slice(6, 31, 6)
GAS_DISENGAGE = slice(1, 36, 7)
BRAKE_DISENGAGE = slice(2, 36, 7)
STEER_OVERRIDE = slice(3, 36, 7)
HARD_BRAKE_3 = slice(4, 36, 7)
HARD_BRAKE_4 = slice(5, 36, 7)
HARD_BRAKE_5 = slice(6, 36, 7)
GAS_PRESS = slice(7, 36, 7)
# next 0, 2, 4, 6, 8, 10 seconds
GAS_PRESS = slice(31, 55, 4)
BRAKE_PRESS = slice(32, 55, 4)
LEFT_BLINKER = slice(33, 55, 4)
RIGHT_BLINKER = slice(34, 55, 4)
LEFT_BLINKER = slice(36, 48, 2)
RIGHT_BLINKER = slice(37, 48, 2)

View File

@@ -3,21 +3,11 @@ import capnp
import numpy as np
from cereal import log
from openpilot.selfdrive.modeld.constants import ModelConstants, Plan, Meta
from openpilot.selfdrive.controls.lib.drive_helpers import MIN_SPEED
SEND_RAW_PRED = os.getenv('SEND_RAW_PRED')
ConfidenceClass = log.ModelDataV2.ConfidenceClass
def curv_from_psis(psi_target, psi_rate, vego, delay):
vego = np.clip(vego, MIN_SPEED, np.inf)
curv_from_psi = psi_target / (vego * delay) # epsilon to prevent divide-by-zero
return 2*curv_from_psi - psi_rate / vego
def get_curvature_from_plan(plan, vego, delay):
psi_target = np.interp(delay, ModelConstants.T_IDXS, plan[:, Plan.T_FROM_CURRENT_EULER][:, 2])
psi_rate = plan[:, Plan.ORIENTATION_RATE][0, 2]
return curv_from_psis(psi_target, psi_rate, vego, delay)
class PublishState:
def __init__(self):
@@ -75,8 +65,6 @@ def fill_model_msg(base_msg: capnp._DynamicStructBuilder, extended_msg: capnp._D
extended_msg.valid = valid
base_msg.valid = valid
desired_curv = float(get_curvature_from_plan(net_output_data['plan'][0], v_ego, delay))
driving_model_data = base_msg.drivingModelData
driving_model_data.frameId = vipc_frame_id
@@ -85,7 +73,7 @@ def fill_model_msg(base_msg: capnp._DynamicStructBuilder, extended_msg: capnp._D
driving_model_data.modelExecutionTime = model_execution_time
action = driving_model_data.action
action.desiredCurvature = desired_curv
action.desiredCurvature = float(net_output_data['desired_curvature'][0,0])
modelV2 = extended_msg.modelV2
modelV2.frameId = vipc_frame_id
@@ -120,7 +108,7 @@ def fill_model_msg(base_msg: capnp._DynamicStructBuilder, extended_msg: capnp._D
# lateral planning
action = modelV2.action
action.desiredCurvature = desired_curv
action.desiredCurvature = float(net_output_data['desired_curvature'][0,0])
# times at X_IDXS according to model plan
PLAN_T_IDXS = [np.nan] * ModelConstants.IDX_N
@@ -181,8 +169,8 @@ def fill_model_msg(base_msg: capnp._DynamicStructBuilder, extended_msg: capnp._D
disengage_predictions.brake3MetersPerSecondSquaredProbs = net_output_data['meta'][0,Meta.HARD_BRAKE_3].tolist()
disengage_predictions.brake4MetersPerSecondSquaredProbs = net_output_data['meta'][0,Meta.HARD_BRAKE_4].tolist()
disengage_predictions.brake5MetersPerSecondSquaredProbs = net_output_data['meta'][0,Meta.HARD_BRAKE_5].tolist()
disengage_predictions.gasPressProbs = net_output_data['meta'][0,Meta.GAS_PRESS].tolist()
disengage_predictions.brakePressProbs = net_output_data['meta'][0,Meta.BRAKE_PRESS].tolist()
#disengage_predictions.gasPressProbs = net_output_data['meta'][0,Meta.GAS_PRESS].tolist()
#disengage_predictions.brakePressProbs = net_output_data['meta'][0,Meta.BRAKE_PRESS].tolist()
publish_state.prev_brake_5ms2_probs[:-1] = publish_state.prev_brake_5ms2_probs[1:]
publish_state.prev_brake_5ms2_probs[-1] = net_output_data['meta'][0,Meta.HARD_BRAKE_5][0]

View File

@@ -59,14 +59,14 @@ class ModelState:
def __init__(self, context: CLContext):
self.frames = {'input_imgs': DrivingModelFrame(context), 'big_input_imgs': DrivingModelFrame(context)}
self.prev_desire = np.zeros(ModelConstants.DESIRE_LEN, dtype=np.float32)
self.full_features_20Hz = np.zeros((ModelConstants.FULL_HISTORY_BUFFER_LEN, ModelConstants.FEATURE_LEN), dtype=np.float32)
self.desire_20Hz = np.zeros((ModelConstants.FULL_HISTORY_BUFFER_LEN + 1, ModelConstants.DESIRE_LEN), dtype=np.float32)
# img buffers are managed in openCL transform code
self.numpy_inputs = {
'desire': np.zeros((1, (ModelConstants.HISTORY_BUFFER_LEN+1), ModelConstants.DESIRE_LEN), dtype=np.float32),
'desire': np.zeros((1, (ModelConstants.FULL_HISTORY_BUFFER_LEN+1), ModelConstants.DESIRE_LEN), dtype=np.float32),
'traffic_convention': np.zeros((1, ModelConstants.TRAFFIC_CONVENTION_LEN), dtype=np.float32),
'features_buffer': np.zeros((1, ModelConstants.HISTORY_BUFFER_LEN, ModelConstants.FEATURE_LEN), dtype=np.float32),
'lateral_control_params': np.zeros((1, ModelConstants.LATERAL_CONTROL_PARAMS_LEN), dtype=np.float32),
'prev_desired_curv': np.zeros((1, (ModelConstants.FULL_HISTORY_BUFFER_LEN+1), ModelConstants.PREV_DESIRED_CURV_LEN), dtype=np.float32),
'features_buffer': np.zeros((1, ModelConstants.FULL_HISTORY_BUFFER_LEN, ModelConstants.FEATURE_LEN), dtype=np.float32),
}
with open(METADATA_PATH, 'rb') as f:
@@ -98,11 +98,11 @@ class ModelState:
new_desire = np.where(inputs['desire'] - self.prev_desire > .99, inputs['desire'], 0)
self.prev_desire[:] = inputs['desire']
self.desire_20Hz[:-1] = self.desire_20Hz[1:]
self.desire_20Hz[-1] = new_desire
self.numpy_inputs['desire'][:] = self.desire_20Hz.reshape((1,25,4,-1)).max(axis=2)
self.numpy_inputs['desire'][0,:-1] = self.numpy_inputs['desire'][0,1:]
self.numpy_inputs['desire'][0,-1] = new_desire
self.numpy_inputs['traffic_convention'][:] = inputs['traffic_convention']
self.numpy_inputs['lateral_control_params'][:] = inputs['lateral_control_params']
imgs_cl = {'input_imgs': self.frames['input_imgs'].prepare(buf, transform.flatten()),
'big_input_imgs': self.frames['big_input_imgs'].prepare(wbuf, transform_wide.flatten())}
@@ -113,7 +113,7 @@ class ModelState:
self.tensor_inputs[key] = qcom_tensor_from_opencl_address(imgs_cl[key].mem_address, self.input_shapes[key], dtype=dtypes.uint8)
else:
for key in imgs_cl:
self.numpy_inputs[key] = self.frames[key].buffer_from_cl(imgs_cl[key]).reshape(self.input_shapes[key])
self.numpy_inputs[key] = self.frames[key].buffer_from_cl(imgs_cl[key]).reshape(self.input_shapes[key]).astype(dtype=np.float32)
if prepare_only:
return None
@@ -125,11 +125,13 @@ class ModelState:
outputs = self.parser.parse_outputs(self.slice_outputs(self.output))
self.full_features_20Hz[:-1] = self.full_features_20Hz[1:]
self.full_features_20Hz[-1] = outputs['hidden_state'][0, :]
self.numpy_inputs['features_buffer'][0,:-1] = self.numpy_inputs['features_buffer'][0,1:]
self.numpy_inputs['features_buffer'][0,-1] = outputs['hidden_state'][0, :]
idxs = np.arange(-4,-100,-4)[::-1]
self.numpy_inputs['features_buffer'][:] = self.full_features_20Hz[idxs]
# TODO model only uses last value now
self.numpy_inputs['prev_desired_curv'][0,:-1] = self.numpy_inputs['prev_desired_curv'][0,1:]
self.numpy_inputs['prev_desired_curv'][0,-1,:] = outputs['desired_curvature'][0, :]
return outputs
@@ -240,6 +242,7 @@ def main(demo=False):
is_rhd = sm["driverMonitoringState"].isRHD
frame_id = sm["roadCameraState"].frameId
v_ego = max(sm["carState"].vEgo, 0.)
lateral_control_params = np.array([v_ego, steer_delay], dtype=np.float32)
if sm.updated["liveCalibration"] and sm.seen['roadCameraState'] and sm.seen['deviceState']:
device_from_calib_euler = np.array(sm["liveCalibration"].rpyCalib, dtype=np.float32)
dc = DEVICE_CAMERAS[(str(sm['deviceState'].deviceType), str(sm['roadCameraState'].sensor))]
@@ -270,6 +273,7 @@ def main(demo=False):
inputs:dict[str, np.ndarray] = {
'desire': vec_desire,
'traffic_convention': traffic_convention,
'lateral_control_params': lateral_control_params,
}
mt1 = time.perf_counter()

View File

@@ -8,8 +8,8 @@
DrivingModelFrame::DrivingModelFrame(cl_device_id device_id, cl_context context) : ModelFrame(device_id, context) {
input_frames = std::make_unique<uint8_t[]>(buf_size);
input_frames_cl = CL_CHECK_ERR(clCreateBuffer(context, CL_MEM_READ_WRITE, buf_size, NULL, &err));
img_buffer_20hz_cl = CL_CHECK_ERR(clCreateBuffer(context, CL_MEM_READ_WRITE, 5*frame_size_bytes, NULL, &err));
region.origin = 4 * frame_size_bytes;
img_buffer_20hz_cl = CL_CHECK_ERR(clCreateBuffer(context, CL_MEM_READ_WRITE, 2*frame_size_bytes, NULL, &err));
region.origin = 1 * frame_size_bytes;
region.size = frame_size_bytes;
last_img_cl = CL_CHECK_ERR(clCreateSubBuffer(img_buffer_20hz_cl, CL_MEM_READ_WRITE, CL_BUFFER_CREATE_TYPE_REGION, &region, &err));
@@ -20,7 +20,7 @@ DrivingModelFrame::DrivingModelFrame(cl_device_id device_id, cl_context context)
cl_mem* DrivingModelFrame::prepare(cl_mem yuv_cl, int frame_width, int frame_height, int frame_stride, int frame_uv_offset, const mat3& projection) {
run_transform(yuv_cl, MODEL_WIDTH, MODEL_HEIGHT, frame_width, frame_height, frame_stride, frame_uv_offset, projection);
for (int i = 0; i < 4; i++) {
for (int i = 0; i < 1; i++) {
CL_CHECK(clEnqueueCopyBuffer(q, img_buffer_20hz_cl, img_buffer_20hz_cl, (i+1)*frame_size_bytes, i*frame_size_bytes, frame_size_bytes, 0, nullptr, nullptr));
}
loadyuv_queue(&loadyuv, q, y_cl, u_cl, v_cl, last_img_cl);

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:72d3d6f8d3c98f5431ec86be77b6350d7d4f43c25075c0106f1d1e7ec7c77668
size 49096168
oid sha256:39786068cae1ed8c0dc34ef80c281dfcc67ed18a50e06b90765c49bcfdbf7db4
size 51453312

View File

@@ -96,6 +96,8 @@ class Parser:
out_shape=(ModelConstants.LEAD_TRAJ_LEN,ModelConstants.LEAD_WIDTH))
if 'lat_planner_solution' in outs:
self.parse_mdn('lat_planner_solution', outs, in_N=0, out_N=0, out_shape=(ModelConstants.IDX_N,ModelConstants.LAT_PLANNER_SOLUTION_WIDTH))
if 'desired_curvature' in outs:
self.parse_mdn('desired_curvature', outs, in_N=0, out_N=0, out_shape=(ModelConstants.DESIRED_CURV_WIDTH,))
for k in ['lead_prob', 'lane_lines_prob', 'meta']:
self.parse_binary_crossentropy(k, outs)
self.parse_categorical_crossentropy('desire_state', outs, out_shape=(ModelConstants.DESIRE_PRED_WIDTH,))

View File

@@ -1 +0,0 @@
benchmark

View File

@@ -1,192 +0,0 @@
#include <SNPE/SNPE.hpp>
#include <SNPE/SNPEBuilder.hpp>
#include <SNPE/SNPEFactory.hpp>
#include <DlContainer/IDlContainer.hpp>
#include <DlSystem/DlError.hpp>
#include <DlSystem/ITensor.hpp>
#include <DlSystem/ITensorFactory.hpp>
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
int64_t timespecDiff(struct timespec *timeA_p, struct timespec *timeB_p) {
return ((timeA_p->tv_sec * 1000000000) + timeA_p->tv_nsec) - ((timeB_p->tv_sec * 1000000000) + timeB_p->tv_nsec);
}
void PrintErrorStringAndExit() {
cout << "ERROR!" << endl;
const char* const errStr = zdl::DlSystem::getLastErrorString();
std::cerr << errStr << std::endl;
std::exit(EXIT_FAILURE);
}
zdl::DlSystem::Runtime_t checkRuntime() {
static zdl::DlSystem::Version_t Version = zdl::SNPE::SNPEFactory::getLibraryVersion();
static zdl::DlSystem::Runtime_t Runtime;
std::cout << "SNPE Version: " << Version.asString().c_str() << std::endl; //Print Version number
if (zdl::SNPE::SNPEFactory::isRuntimeAvailable(zdl::DlSystem::Runtime_t::DSP)) {
std::cout << "Using DSP runtime" << std::endl;
Runtime = zdl::DlSystem::Runtime_t::DSP;
} else if (zdl::SNPE::SNPEFactory::isRuntimeAvailable(zdl::DlSystem::Runtime_t::GPU)) {
std::cout << "Using GPU runtime" << std::endl;
Runtime = zdl::DlSystem::Runtime_t::GPU;
} else {
std::cout << "Using cpu runtime" << std::endl;
Runtime = zdl::DlSystem::Runtime_t::CPU;
}
return Runtime;
}
void test(char *filename) {
static zdl::DlSystem::Runtime_t runtime = checkRuntime();
std::unique_ptr<zdl::DlContainer::IDlContainer> container;
container = zdl::DlContainer::IDlContainer::open(filename);
if (!container) { PrintErrorStringAndExit(); }
cout << "start build" << endl;
std::unique_ptr<zdl::SNPE::SNPE> snpe;
{
snpe = NULL;
zdl::SNPE::SNPEBuilder snpeBuilder(container.get());
snpe = snpeBuilder.setOutputLayers({})
.setRuntimeProcessor(runtime)
.setUseUserSuppliedBuffers(false)
//.setDebugMode(true)
.build();
if (!snpe) {
cout << "ERROR!" << endl;
const char* const errStr = zdl::DlSystem::getLastErrorString();
std::cerr << errStr << std::endl;
}
cout << "ran snpeBuilder" << endl;
}
const auto &strList_opt = snpe->getInputTensorNames();
if (!strList_opt) throw std::runtime_error("Error obtaining input tensor names");
cout << "get input tensor names done" << endl;
const auto &strList = *strList_opt;
static zdl::DlSystem::TensorMap inputTensorMap;
static zdl::DlSystem::TensorMap outputTensorMap;
vector<std::unique_ptr<zdl::DlSystem::ITensor> > inputs;
for (int i = 0; i < strList.size(); i++) {
cout << "input name: " << strList.at(i) << endl;
const auto &inputDims_opt = snpe->getInputDimensions(strList.at(i));
const auto &inputShape = *inputDims_opt;
inputs.push_back(zdl::SNPE::SNPEFactory::getTensorFactory().createTensor(inputShape));
inputTensorMap.add(strList.at(i), inputs[i].get());
}
struct timespec start, end;
cout << "**** starting benchmark ****" << endl;
for (int i = 0; i < 50; i++) {
clock_gettime(CLOCK_MONOTONIC, &start);
int err = snpe->execute(inputTensorMap, outputTensorMap);
assert(err == true);
clock_gettime(CLOCK_MONOTONIC, &end);
uint64_t timeElapsed = timespecDiff(&end, &start);
printf("time: %f ms\n", timeElapsed*1.0/1e6);
}
}
void get_testframe(int index, std::unique_ptr<zdl::DlSystem::ITensor> &input) {
FILE * pFile;
string filepath="/data/ipt/quantize_samples/sample_input_"+std::to_string(index);
pFile = fopen(filepath.c_str(), "rb");
int length = 1*6*160*320*4;
float * frame_buffer = new float[length/4]; // 32/8
fread(frame_buffer, length, 1, pFile);
// std::cout << *(frame_buffer+length/4-1) << std::endl;
std::copy(frame_buffer, frame_buffer+(length/4), input->begin());
fclose(pFile);
}
void SaveITensor(const std::string& path, const zdl::DlSystem::ITensor* tensor)
{
std::ofstream os(path, std::ofstream::binary);
if (!os)
{
std::cerr << "Failed to open output file for writing: " << path << "\n";
std::exit(EXIT_FAILURE);
}
for ( auto it = tensor->cbegin(); it != tensor->cend(); ++it )
{
float f = *it;
if (!os.write(reinterpret_cast<char*>(&f), sizeof(float)))
{
std::cerr << "Failed to write data to: " << path << "\n";
std::exit(EXIT_FAILURE);
}
}
}
void testrun(char* modelfile) {
static zdl::DlSystem::Runtime_t runtime = checkRuntime();
std::unique_ptr<zdl::DlContainer::IDlContainer> container;
container = zdl::DlContainer::IDlContainer::open(modelfile);
if (!container) { PrintErrorStringAndExit(); }
cout << "start build" << endl;
std::unique_ptr<zdl::SNPE::SNPE> snpe;
{
snpe = NULL;
zdl::SNPE::SNPEBuilder snpeBuilder(container.get());
snpe = snpeBuilder.setOutputLayers({})
.setRuntimeProcessor(runtime)
.setUseUserSuppliedBuffers(false)
//.setDebugMode(true)
.build();
if (!snpe) {
cout << "ERROR!" << endl;
const char* const errStr = zdl::DlSystem::getLastErrorString();
std::cerr << errStr << std::endl;
}
cout << "ran snpeBuilder" << endl;
}
const auto &strList_opt = snpe->getInputTensorNames();
if (!strList_opt) throw std::runtime_error("Error obtaining input tensor names");
cout << "get input tensor names done" << endl;
const auto &strList = *strList_opt;
static zdl::DlSystem::TensorMap inputTensorMap;
static zdl::DlSystem::TensorMap outputTensorMap;
assert(strList.size() == 1);
const auto &inputDims_opt = snpe->getInputDimensions(strList.at(0));
const auto &inputShape = *inputDims_opt;
std::cout << "winkwink" << std::endl;
for (int i=0; i<10000; i++) {
std::unique_ptr<zdl::DlSystem::ITensor> input;
input = zdl::SNPE::SNPEFactory::getTensorFactory().createTensor(inputShape);
get_testframe(i, input);
snpe->execute(input.get(), outputTensorMap);
zdl::DlSystem::StringList tensorNames = outputTensorMap.getTensorNames();
std::for_each(tensorNames.begin(), tensorNames.end(), [&](const char* name) {
std::ostringstream path;
path << "/data/opt/Result_" << std::to_string(i) << ".raw";
auto tensorPtr = outputTensorMap.getTensor(name);
SaveITensor(path.str(), tensorPtr);
});
}
}
int main(int argc, char* argv[]) {
if (argc < 2) {
printf("usage: %s <filename>\n", argv[0]);
return -1;
}
if (argc == 2) {
while (true) test(argv[1]);
} else if (argc == 3) {
testrun(argv[1]);
}
return 0;
}

View File

@@ -1,4 +0,0 @@
#!/bin/sh -e
clang++ -I /data/openpilot/third_party/snpe/include/ -L/data/pythonpath/third_party/snpe/aarch64 -lSNPE benchmark.cc -o benchmark
export LD_LIBRARY_PATH="/data/pythonpath/third_party/snpe/aarch64/:$HOME/openpilot/third_party/snpe/x86_64/:$LD_LIBRARY_PATH"
exec ./benchmark $1

View File

@@ -1,58 +0,0 @@
#!/usr/bin/env python3
import signal
import subprocess
signal.signal(signal.SIGINT, signal.SIG_DFL)
signal.signal(signal.SIGTERM, signal.SIG_DFL)
from PyQt5.QtCore import QTimer
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QLabel
from openpilot.selfdrive.ui.qt.python_helpers import set_main_window
class Window(QWidget):
def __init__(self, parent=None):
super().__init__(parent)
layout = QVBoxLayout()
self.setLayout(layout)
self.l = QLabel("jenkins runner")
layout.addWidget(self.l)
layout.addStretch(1)
layout.setContentsMargins(20, 20, 20, 20)
cmds = [
"cat /etc/hostname",
"echo AGNOS v$(cat /VERSION)",
"uptime -p",
]
self.labels = {}
for c in cmds:
self.labels[c] = QLabel(c)
layout.addWidget(self.labels[c])
self.setStyleSheet("""
* {
color: white;
font-size: 55px;
background-color: black;
font-family: "JetBrains Mono";
}
""")
self.timer = QTimer()
self.timer.timeout.connect(self.update)
self.timer.start(10 * 1000)
self.update()
def update(self):
for cmd, label in self.labels.items():
out = subprocess.run(cmd, capture_output=True,
shell=True, check=False, encoding='utf8').stdout
label.setText(out.strip())
if __name__ == "__main__":
app = QApplication([])
w = Window()
set_main_window(w)
app.exec_()

View File

@@ -1,25 +0,0 @@
#!/usr/bin/env bash
set -e
if [ $# -lt 2 ]; then
echo "Usage: $0 <base|docs|sim|prebuilt|cl> <arch1> <arch2> ..."
exit 1
fi
SCRIPT_DIR=$(dirname "$0")
ARCHS=("${@:2}")
source $SCRIPT_DIR/docker_common.sh $1
MANIFEST_AMENDS=""
for ARCH in ${ARCHS[@]}; do
MANIFEST_AMENDS="$MANIFEST_AMENDS --amend $REMOTE_TAG-$ARCH:$COMMIT_SHA"
done
docker manifest create $REMOTE_TAG $MANIFEST_AMENDS
docker manifest create $REMOTE_SHA_TAG $MANIFEST_AMENDS
if [[ -n "$PUSH_IMAGE" ]]; then
docker manifest push $REMOTE_TAG
docker manifest push $REMOTE_SHA_TAG
fi

View File

@@ -1,8 +0,0 @@
#!/usr/bin/env bash
set -e
# Loop something forever until it fails, for verifying new tests
while true; do
$@
done

View File

@@ -1 +0,0 @@
707434c540e685bbe2886b3ff7c82fd61939d362

View File

@@ -57,7 +57,7 @@ def generate_report(proposed, master, tmp, commit):
(lambda x: x.action.desiredCurvature, "desiredCurvature"),
(lambda x: x.leadsV3[0].x[0], "leadsV3.x"),
(lambda x: x.laneLines[1].y[0], "laneLines.y"),
(lambda x: x.meta.disengagePredictions.gasPressProbs[1], "gasPressProbs")
#(lambda x: x.meta.disengagePredictions.gasPressProbs[1], "gasPressProbs")
], "modelV2")
DriverStateV2_Plots = zl([
(lambda x: x.wheelOnRightProb, "wheelOnRightProb"),

View File

@@ -1,98 +0,0 @@
import os
import numpy as np
import hashlib
import pyopencl as cl # install with `PYOPENCL_CL_PRETEND_VERSION=2.0 pip install pyopencl`
from openpilot.system.hardware import PC, TICI
from openpilot.common.basedir import BASEDIR
from openpilot.common.transformations.camera import DEVICE_CAMERAS
from openpilot.system.camerad.snapshot.snapshot import yuv_to_rgb
from openpilot.tools.lib.logreader import LogReader
# TODO: check all sensors
TEST_ROUTE = "8345e3b82948d454|2022-05-04--13-45-33/0"
cam = DEVICE_CAMERAS[("tici", "ar0231")]
FRAME_WIDTH, FRAME_HEIGHT = (cam.dcam.width, cam.dcam.height)
FRAME_STRIDE = FRAME_WIDTH * 12 // 8 + 4
UV_WIDTH = FRAME_WIDTH // 2
UV_HEIGHT = FRAME_HEIGHT // 2
UV_SIZE = UV_WIDTH * UV_HEIGHT
def init_kernels(frame_offset=0):
ctx = cl.create_some_context(interactive=False)
with open(os.path.join(BASEDIR, 'system/camerad/cameras/process_raw.cl')) as f:
build_args = f' -cl-fast-relaxed-math -cl-denorms-are-zero -cl-single-precision-constant -I{BASEDIR}/system/camerad/sensors ' + \
f' -DFRAME_WIDTH={FRAME_WIDTH} -DFRAME_HEIGHT={FRAME_WIDTH} -DFRAME_STRIDE={FRAME_STRIDE} -DFRAME_OFFSET={frame_offset} ' + \
f' -DRGB_WIDTH={FRAME_WIDTH} -DRGB_HEIGHT={FRAME_HEIGHT} -DYUV_STRIDE={FRAME_WIDTH} -DUV_OFFSET={FRAME_WIDTH*FRAME_HEIGHT}' + \
' -DSENSOR_ID=1 -DVIGNETTING=0 '
if PC:
build_args += ' -DHALF_AS_FLOAT=1 -cl-std=CL2.0'
imgproc_prg = cl.Program(ctx, f.read()).build(options=build_args)
return ctx, imgproc_prg
def proc_frame(ctx, imgproc_prg, data, rgb=False):
q = cl.CommandQueue(ctx)
yuv_buff = np.empty(FRAME_WIDTH * FRAME_HEIGHT + UV_SIZE * 2, dtype=np.uint8)
cam_g = cl.Buffer(ctx, cl.mem_flags.READ_ONLY | cl.mem_flags.COPY_HOST_PTR, hostbuf=data)
yuv_g = cl.Buffer(ctx, cl.mem_flags.WRITE_ONLY, FRAME_WIDTH * FRAME_HEIGHT + UV_SIZE * 2)
krn = imgproc_prg.process_raw
krn.set_scalar_arg_dtypes([None, None, np.int32])
local_worksize = (20, 20) if TICI else (4, 4)
ev1 = krn(q, (FRAME_WIDTH//2, FRAME_HEIGHT//2), local_worksize, cam_g, yuv_g, 1)
cl.enqueue_copy(q, yuv_buff, yuv_g, wait_for=[ev1]).wait()
cl.enqueue_barrier(q)
y = yuv_buff[:FRAME_WIDTH*FRAME_HEIGHT].reshape((FRAME_HEIGHT, FRAME_WIDTH))
u = yuv_buff[FRAME_WIDTH*FRAME_HEIGHT::2].reshape((UV_HEIGHT, UV_WIDTH))
v = yuv_buff[FRAME_WIDTH*FRAME_HEIGHT+1::2].reshape((UV_HEIGHT, UV_WIDTH))
if rgb:
return yuv_to_rgb(y, u, v)
else:
return y, u, v
def imgproc_replay(lr):
ctx, imgproc_prg = init_kernels()
frames = []
for m in lr:
if m.which() == 'roadCameraState':
cs = m.roadCameraState
if cs.image:
data = np.frombuffer(cs.image, dtype=np.uint8)
img = proc_frame(ctx, imgproc_prg, data)
frames.append(img)
return frames
if __name__ == "__main__":
# load logs
lr = list(LogReader(TEST_ROUTE))
# run replay
out_frames = imgproc_replay(lr)
all_pix = np.concatenate([np.concatenate([d.flatten() for d in f]) for f in out_frames])
pix_hash = hashlib.sha1(all_pix).hexdigest()
with open('imgproc_replay_ref_hash') as f:
ref_hash = f.read()
if pix_hash != ref_hash:
print("result changed! please check kernel")
print(f"ref: {ref_hash}")
print(f"new: {pix_hash}")
else:
print("test passed")

View File

@@ -1,2 +0,0 @@
cachegrind.out.*
*.prof

View File

@@ -1,91 +0,0 @@
from collections import defaultdict
from cereal.services import SERVICE_LIST
import cereal.messaging as messaging
import capnp
class ReplayDone(Exception):
pass
class SubSocket:
def __init__(self, msgs, trigger):
self.i = 0
self.trigger = trigger
self.msgs = [m.as_builder().to_bytes() for m in msgs if m.which() == trigger]
self.max_i = len(self.msgs) - 1
def receive(self, non_blocking=False):
if non_blocking:
return None
if self.i == self.max_i:
raise ReplayDone
while True:
msg = self.msgs[self.i]
self.i += 1
return msg
class PubSocket:
def send(self, data):
pass
class SubMaster(messaging.SubMaster):
def __init__(self, msgs, trigger, services, check_averag_freq=False):
self.frame = 0
self.data = {}
self.ignore_alive = []
self.alive = {s: True for s in services}
self.updated = {s: False for s in services}
self.rcv_time = {s: 0. for s in services}
self.rcv_frame = {s: 0 for s in services}
self.valid = {s: True for s in services}
self.freq_ok = {s: True for s in services}
self.freq_tracker = {s: messaging.FrequencyTracker(SERVICE_LIST[s].frequency, SERVICE_LIST[s].frequency, False) for s in services}
self.logMonoTime = {}
self.sock = {}
self.freq = {}
self.check_average_freq = check_averag_freq
self.non_polled_services = []
self.ignore_average_freq = []
# TODO: specify multiple triggers for service like plannerd that poll on more than one service
cur_msgs = []
self.msgs = []
msgs = [m for m in msgs if m.which() in services]
for msg in msgs:
cur_msgs.append(msg)
if msg.which() == trigger:
self.msgs.append(cur_msgs)
cur_msgs = []
self.msgs = list(reversed(self.msgs))
for s in services:
self.freq[s] = SERVICE_LIST[s].frequency
try:
data = messaging.new_message(s)
except capnp.lib.capnp.KjException:
# lists
data = messaging.new_message(s, 0)
self.data[s] = getattr(data, s)
self.logMonoTime[s] = 0
self.sock[s] = SubSocket(msgs, s)
def update(self, timeout=None):
if not len(self.msgs):
raise ReplayDone
cur_msgs = self.msgs.pop()
self.update_msgs(cur_msgs[0].logMonoTime, self.msgs.pop())
class PubMaster(messaging.PubMaster):
def __init__(self):
self.sock = defaultdict(PubSocket)

View File

@@ -1,97 +0,0 @@
#!/usr/bin/env python3
import os
import sys
import cProfile
import pprofile
import pyprof2calltree
from opendbc.car.toyota.values import CAR as TOYOTA
from opendbc.car.honda.values import CAR as HONDA
from opendbc.car.volkswagen.values import CAR as VW
from openpilot.common.params import Params
from openpilot.tools.lib.logreader import LogReader
from openpilot.selfdrive.test.profiling.lib import SubMaster, PubMaster, SubSocket, ReplayDone
from openpilot.selfdrive.test.process_replay.process_replay import CONFIGS
BASE_URL = "https://commadataci.blob.core.windows.net/openpilotci/"
CARS = {
'toyota': ("0982d79ebb0de295|2021-01-03--20-03-36/6", TOYOTA.TOYOTA_RAV4),
'honda': ("0982d79ebb0de295|2021-01-08--10-13-10/6", HONDA.HONDA_CIVIC),
"vw": ("ef895f46af5fd73f|2021-05-22--14-06-35/6", VW.AUDI_A3_MK3),
}
def get_inputs(msgs, process, fingerprint):
for config in CONFIGS:
if config.proc_name == process:
sub_socks = list(config.pubs)
trigger = sub_socks[0]
break
# some procs block on CarParams
for msg in msgs:
if msg.which() == 'carParams':
m = msg.as_builder()
m.carParams.carFingerprint = fingerprint
Params().put("CarParams", m.carParams.copy().to_bytes())
break
sm = SubMaster(msgs, trigger, sub_socks)
pm = PubMaster()
if 'can' in sub_socks:
can_sock = SubSocket(msgs, 'can')
else:
can_sock = None
return sm, pm, can_sock
def profile(proc, func, car='toyota'):
segment, fingerprint = CARS[car]
segment = segment.replace('|', '/')
rlog_url = f"{BASE_URL}{segment}/rlog.bz2"
msgs = list(LogReader(rlog_url)) * int(os.getenv("LOOP", "1"))
os.environ['FINGERPRINT'] = fingerprint
os.environ['SKIP_FW_QUERY'] = "1"
os.environ['REPLAY'] = "1"
def run(sm, pm, can_sock):
try:
if can_sock is not None:
func(sm, pm, can_sock)
else:
func(sm, pm)
except ReplayDone:
pass
# Statistical
sm, pm, can_sock = get_inputs(msgs, proc, fingerprint)
with pprofile.StatisticalProfile()(period=0.00001) as pr:
run(sm, pm, can_sock)
pr.dump_stats(f'cachegrind.out.{proc}_statistical')
# Deterministic
sm, pm, can_sock = get_inputs(msgs, proc, fingerprint)
with cProfile.Profile() as pr:
run(sm, pm, can_sock)
pyprof2calltree.convert(pr.getstats(), f'cachegrind.out.{proc}_deterministic')
if __name__ == '__main__':
from openpilot.selfdrive.controls.controlsd import main as controlsd_thread
from openpilot.selfdrive.locationd.paramsd import main as paramsd_thread
from openpilot.selfdrive.controls.plannerd import main as plannerd_thread
procs = {
'controlsd': controlsd_thread,
'paramsd': paramsd_thread,
'plannerd': plannerd_thread,
}
proc = sys.argv[1]
if proc not in procs:
print(f"{proc} not available")
sys.exit(0)
else:
profile(proc, procs[proc])

View File

@@ -103,7 +103,7 @@ TIMINGS = {
LOGS_SIZE_RATE = {
"qlog": 0.0083,
"rlog": 0.1528,
"rlog": 0.135,
"qcamera.ts": 0.03828,
}
LOGS_SIZE_RATE.update(dict.fromkeys(['ecamera.hevc', 'fcamera.hevc'], 1.2740))

View File

@@ -33,20 +33,17 @@ def register(show_spinner=False) -> str | None:
"""
params = Params()
IMEI = params.get("IMEI", encoding='utf8')
HardwareSerial = params.get("HardwareSerial", encoding='utf8')
dongle_id: str | None = params.get("DongleId", encoding='utf8')
if dongle_id is None and Path(Paths.persist_root()+"/comma/dongle_id").is_file():
# not all devices will have this; added early in comma 3X production (2/28/24)
with open(Paths.persist_root()+"/comma/dongle_id") as f:
dongle_id = f.read().strip()
needs_registration = None in (IMEI, HardwareSerial, dongle_id)
pubkey = Path(Paths.persist_root()+"/comma/id_rsa.pub")
if not pubkey.is_file():
dongle_id = UNREGISTERED_DONGLE_ID
cloudlog.warning(f"missing public key: {pubkey}")
elif needs_registration:
elif dongle_id is None:
if show_spinner:
spinner = Spinner()
spinner.update("registering device")
@@ -71,9 +68,6 @@ def register(show_spinner=False) -> str | None:
if time.monotonic() - start_time > 60 and show_spinner:
spinner.update(f"registering device - serial: {serial}, IMEI: ({imei1}, {imei2})")
params.put("IMEI", imei1)
params.put("HardwareSerial", serial)
backoff = 0
start_time = time.monotonic()
while True:

View File

@@ -32,8 +32,6 @@ class TestRegistration:
def test_valid_cache(self, mocker):
# if all params are written, return the cached dongle id.
# should work with a dongle ID on either /persist/ or normal params
self.params.put("IMEI", "imei")
self.params.put("HardwareSerial", "serial")
self._generate_keys()
dongle = "DONGLE_ID_123"

View File

@@ -4,7 +4,7 @@
#include "system/camerad/sensors/sensor.h"
int build_update(uint8_t *dst, const SensorInfo *s, std::vector<uint32_t> &patches) {
int build_update(uint8_t *dst, const SensorInfo *s, std::vector<uint32_t> &patches, int camera_num) {
uint8_t *start = dst;
dst += write_random(dst, {
@@ -34,7 +34,7 @@ int build_update(uint8_t *dst, const SensorInfo *s, std::vector<uint32_t> &patch
});
dst += write_cont(dst, 0x40, {
0x00000c06, // (1<<8) to enable vignetting correction
0x00000c06 | ((uint32_t)(camera_num == 1) << 8),
});
dst += write_cont(dst, 0x48, {
@@ -76,11 +76,11 @@ int build_update(uint8_t *dst, const SensorInfo *s, std::vector<uint32_t> &patch
}
int build_initial_config(uint8_t *dst, const SensorInfo *s, std::vector<uint32_t> &patches) {
int build_initial_config(uint8_t *dst, const SensorInfo *s, std::vector<uint32_t> &patches, int camera_num) {
uint8_t *start = dst;
// start with the every frame config
dst += build_update(dst, s, patches);
dst += build_update(dst, s, patches, camera_num);
uint64_t addr;
@@ -111,7 +111,7 @@ int build_initial_config(uint8_t *dst, const SensorInfo *s, std::vector<uint32_t
dst += write_cont(dst, 0x500, s->linearization_pts);
dst += write_cont(dst, 0x510, s->linearization_pts);
// TODO: this is DMI64 in the dump, does that matter?
dst += write_dmi(dst, &addr, 288, 0xc24, 9);
dst += write_dmi(dst, &addr, s->linearization_lut.size()*sizeof(uint32_t), 0xc24, 9);
patches.push_back(addr - (uint64_t)start);
/* TODO
cdm_dmi_cmd_t 248
@@ -129,17 +129,14 @@ int build_initial_config(uint8_t *dst, const SensorInfo *s, std::vector<uint32_t
0x00670067,
0xd3b1300c,
0x13b1300c,
0x00670067,
0xd3b1300c,
0x13b1300c,
0xec4e4000,
0x0100c003,
});
dst += write_cont(dst, 0x6d8, {
0xec4e4000,
0x0100c003,
});
dst += write_dmi(dst, &addr, 884, 0xc24, 14);
dst += write_dmi(dst, &addr, s->vignetting_lut.size()*sizeof(uint32_t), 0xc24, 14); // GRR
patches.push_back(addr - (uint64_t)start);
dst += write_dmi(dst, &addr, 884, 0xc24, 15);
dst += write_dmi(dst, &addr, s->vignetting_lut.size()*sizeof(uint32_t), 0xc24, 15); // GBB
patches.push_back(addr - (uint64_t)start);
// debayer
@@ -158,11 +155,11 @@ int build_initial_config(uint8_t *dst, const SensorInfo *s, std::vector<uint32_t
dst += write_cont(dst, 0x798, {
0x00000000,
});
dst += write_dmi(dst, &addr, 256, 0xc24, 26); // G
dst += write_dmi(dst, &addr, s->gamma_lut_rgb.size()*sizeof(uint32_t), 0xc24, 26); // G
patches.push_back(addr - (uint64_t)start);
dst += write_dmi(dst, &addr, 256, 0xc24, 28); // B
dst += write_dmi(dst, &addr, s->gamma_lut_rgb.size()*sizeof(uint32_t), 0xc24, 28); // B
patches.push_back(addr - (uint64_t)start);
dst += write_dmi(dst, &addr, 256, 0xc24, 30); // R
dst += write_dmi(dst, &addr, s->gamma_lut_rgb.size()*sizeof(uint32_t), 0xc24, 30); // R
patches.push_back(addr - (uint64_t)start);
// YUV

View File

@@ -507,9 +507,9 @@ void SpectraCamera::config_ife(int idx, int request_id, bool init) {
// stream of IFE register writes
if (!is_raw) {
if (init) {
buf_desc[0].length = build_initial_config((unsigned char*)ife_cmd.ptr + buf_desc[0].offset, sensor.get(), patches);
buf_desc[0].length = build_initial_config((unsigned char*)ife_cmd.ptr + buf_desc[0].offset, sensor.get(), patches, cc.camera_num);
} else {
buf_desc[0].length = build_update((unsigned char*)ife_cmd.ptr + buf_desc[0].offset, sensor.get(), patches);
buf_desc[0].length = build_update((unsigned char*)ife_cmd.ptr + buf_desc[0].offset, sensor.get(), patches, cc.camera_num);
}
}
@@ -879,20 +879,25 @@ void SpectraCamera::configISP() {
CAM_MEM_FLAG_HW_READ_WRITE | CAM_MEM_FLAG_KMD_ACCESS | CAM_MEM_FLAG_UMD_ACCESS | CAM_MEM_FLAG_CMD_BUF_TYPE,
m->device_iommu, m->cdm_iommu, ife_buf_depth);
if (!is_raw) {
ife_gamma_lut.init(m, 64*sizeof(uint32_t), 0x20,
assert(sensor->gamma_lut_rgb.size() == 64);
ife_gamma_lut.init(m, sensor->gamma_lut_rgb.size()*sizeof(uint32_t), 0x20,
CAM_MEM_FLAG_HW_READ_WRITE | CAM_MEM_FLAG_KMD_ACCESS | CAM_MEM_FLAG_UMD_ACCESS | CAM_MEM_FLAG_CMD_BUF_TYPE,
m->device_iommu, m->cdm_iommu, 3); // 3 for RGB
for (int i = 0; i < 3; i++) {
memcpy(ife_gamma_lut.ptr + ife_gamma_lut.size*i, sensor->gamma_lut_rgb.data(), ife_gamma_lut.size);
}
ife_linearization_lut.init(m, sensor->linearization_lut.size(), 0x20,
assert(sensor->linearization_lut.size() == 36);
ife_linearization_lut.init(m, sensor->linearization_lut.size()*sizeof(uint32_t), 0x20,
CAM_MEM_FLAG_HW_READ_WRITE | CAM_MEM_FLAG_KMD_ACCESS | CAM_MEM_FLAG_UMD_ACCESS | CAM_MEM_FLAG_CMD_BUF_TYPE,
m->device_iommu, m->cdm_iommu);
memcpy(ife_linearization_lut.ptr, sensor->linearization_lut.data(), ife_linearization_lut.size);
ife_vignetting_lut.init(m, sensor->vignetting_lut.size(), 0x20,
assert(sensor->vignetting_lut.size() == 221);
ife_vignetting_lut.init(m, sensor->vignetting_lut.size()*sizeof(uint32_t), 0x20,
CAM_MEM_FLAG_HW_READ_WRITE | CAM_MEM_FLAG_KMD_ACCESS | CAM_MEM_FLAG_UMD_ACCESS | CAM_MEM_FLAG_CMD_BUF_TYPE,
m->device_iommu, m->cdm_iommu, 2);
memcpy(ife_vignetting_lut.ptr, sensor->vignetting_lut.data(), ife_vignetting_lut.size*2);
for (int i = 0; i < 2; i++) {
memcpy(ife_vignetting_lut.ptr + ife_vignetting_lut.size*i, sensor->vignetting_lut.data(), ife_vignetting_lut.size);
}
}
config_ife(0, 1, true);

View File

@@ -151,13 +151,22 @@ AR0231::AR0231() {
0x00003fff, 0x00003fff, 0x00003fff, 0x00003fff,
0x00003fff, 0x00003fff, 0x00003fff, 0x00003fff,
};
for (int i = 0; i < 252; i++) {
linearization_lut.push_back(0x0);
}
linearization_pts = {0x07ff0bff, 0x17ff1bff, 0x23ff3fff, 0x3fff3fff};
for (int i = 0; i < 884*2; i++) {
vignetting_lut.push_back(0xff);
}
vignetting_lut = {
0x00eaa755, 0x00cf2679, 0x00bc05e0, 0x00acc566, 0x00a1450a, 0x009984cc, 0x0095a4ad, 0x009584ac, 0x009944ca, 0x00a0c506, 0x00ac0560, 0x00bb25d9, 0x00ce2671, 0x00e90748, 0x01112889, 0x014a2a51, 0x01984cc2,
0x00db06d8, 0x00c30618, 0x00afe57f, 0x00a0a505, 0x009524a9, 0x008d646b, 0x0089844c, 0x0089644b, 0x008d2469, 0x0094a4a5, 0x009fe4ff, 0x00af0578, 0x00c20610, 0x00d986cc, 0x00fda7ed, 0x01320990, 0x017aebd7,
0x00d1868c, 0x00baa5d5, 0x00a7853c, 0x009844c2, 0x008cc466, 0x0085a42d, 0x0083641b, 0x0083641b, 0x0085842c, 0x008c4462, 0x0097a4bd, 0x00a6c536, 0x00b9a5cd, 0x00d06683, 0x00f1678b, 0x01226913, 0x0167ab3d,
0x00cd0668, 0x00b625b1, 0x00a30518, 0x0093c49e, 0x00884442, 0x00830418, 0x0080e407, 0x0080c406, 0x0082e417, 0x0087c43e, 0x00932499, 0x00a22511, 0x00b525a9, 0x00cbe65f, 0x00eb0758, 0x011a68d3, 0x015daaed,
0x00cc4662, 0x00b565ab, 0x00a24512, 0x00930498, 0x0087843c, 0x0082a415, 0x00806403, 0x00806403, 0x00828414, 0x00870438, 0x00926493, 0x00a1850c, 0x00b465a3, 0x00cb2659, 0x00ea2751, 0x011928c9, 0x015c2ae1,
0x00cf667b, 0x00b885c4, 0x00a5652b, 0x009624b1, 0x008aa455, 0x00846423, 0x00822411, 0x00822411, 0x00844422, 0x008a2451, 0x009564ab, 0x00a48524, 0x00b785bc, 0x00ce4672, 0x00ee6773, 0x011e88f4, 0x0162eb17,
0x00d6c6b6, 0x00bf65fb, 0x00ac4562, 0x009d04e8, 0x0091848c, 0x0089c44e, 0x00862431, 0x00860430, 0x0089844c, 0x00910488, 0x009c64e3, 0x00ab655b, 0x00be65f3, 0x00d566ab, 0x00f847c2, 0x012b2959, 0x01726b93,
0x00e3e71f, 0x00ca0650, 0x00b705b8, 0x00a7a53d, 0x009c24e1, 0x009484a4, 0x00908484, 0x00908484, 0x009424a1, 0x009bc4de, 0x00a70538, 0x00b625b1, 0x00c90648, 0x00e26713, 0x0108e847, 0x013fe9ff, 0x018bcc5e,
0x00f807c0, 0x00d966cb, 0x00c5862c, 0x00b625b1, 0x00aaa555, 0x00a30518, 0x009f04f8, 0x009f04f8, 0x00a2a515, 0x00aa2551, 0x00b585ac, 0x00c4a625, 0x00d846c2, 0x00f647b2, 0x0121a90d, 0x015e4af2, 0x01b8cdc6,
0x011548aa, 0x00f1678b, 0x00d886c4, 0x00c86643, 0x00bce5e7, 0x00b545aa, 0x00b1658b, 0x00b1458a, 0x00b505a8, 0x00bc85e4, 0x00c7c63e, 0x00d786bc, 0x00efe77f, 0x0113489a, 0x0144ea27, 0x01888c44, 0x01fdcfee,
0x013e49f2, 0x0113e89f, 0x00f5a7ad, 0x00e0c706, 0x00d30698, 0x00cb665b, 0x00c7663b, 0x00c7663b, 0x00cb0658, 0x00d2a695, 0x00dfe6ff, 0x00f467a3, 0x01122891, 0x013be9df, 0x01750ba8, 0x01cfae7d, 0x025912c8,
0x01766bb3, 0x01446a23, 0x011fc8fe, 0x0105e82f, 0x00f467a3, 0x00e9874c, 0x00e46723, 0x00e44722, 0x00e92749, 0x00f3a79d, 0x0104c826, 0x011e48f2, 0x01424a12, 0x01738b9c, 0x01bf6dfb, 0x023611b0, 0x02ced676,
0x01cf8e7c, 0x01866c33, 0x015aaad5, 0x013ae9d7, 0x01250928, 0x011768bb, 0x0110a885, 0x01108884, 0x0116e8b7, 0x01242921, 0x0139a9cd, 0x0158eac7, 0x01840c20, 0x01cb0e58, 0x0233719b, 0x02b9d5ce, 0x03645b22,
};
}
void AR0231::processRegisters(uint8_t *cur_buf, cereal::FrameData::Builder &framed) const {

View File

@@ -86,13 +86,22 @@ OS04C10::OS04C10() {
0x00003fff, 0x00003fff, 0x00003fff, 0x00003fff,
0x00003fff, 0x00003fff, 0x00003fff, 0x00003fff,
};
for (int i = 0; i < 252; i++) {
linearization_lut.push_back(0x0);
}
linearization_pts = {0x07ff0bff, 0x17ff1bff, 0x23ff3fff, 0x3fff3fff};
for (int i = 0; i < 884*2; i++) {
vignetting_lut.push_back(0xff);
}
vignetting_lut = {
0x01064832, 0x00da26d1, 0x00bb25d9, 0x00aac556, 0x00a06503, 0x009a64d3, 0x009744ba, 0x009744ba, 0x009a24d1, 0x00a00500, 0x00aa2551, 0x00ba45d2, 0x00d826c1, 0x01040820, 0x013729b9, 0x0171ab8d, 0x01b36d9b,
0x00eee777, 0x00c2c616, 0x00ae2571, 0x009fe4ff, 0x0096e4b7, 0x0090e487, 0x008d446a, 0x008d2469, 0x0090a485, 0x009684b4, 0x009f64fb, 0x00ad456a, 0x00c1a60d, 0x00eca765, 0x011fc8fe, 0x015a4ad2, 0x019c0ce0,
0x00dee6f7, 0x00b9c5ce, 0x00a5652b, 0x009964cb, 0x00904482, 0x00892449, 0x0085842c, 0x0085642b, 0x0088e447, 0x008fe47f, 0x0098e4c7, 0x00a4c526, 0x00b8a5c5, 0x00dc86e4, 0x010fc87e, 0x014a2a51, 0x018c0c60,
0x00d626b1, 0x00b4e5a7, 0x00a1e50f, 0x0095e4af, 0x008c2461, 0x00850428, 0x0081640b, 0x0081440a, 0x0084a425, 0x008ba45d, 0x009564ab, 0x00a1450a, 0x00b3c59e, 0x00d3e69f, 0x01070838, 0x01418a0c, 0x01834c1a,
0x00d4c6a6, 0x00b425a1, 0x00a1450a, 0x009544aa, 0x008b645b, 0x00844422, 0x0080a405, 0x0080a405, 0x00840420, 0x008b0458, 0x0094c4a6, 0x00a0a505, 0x00b30598, 0x00d26693, 0x0105a82d, 0x01402a01, 0x0181ec0f,
0x00daa6d5, 0x00b765bb, 0x00a3c51e, 0x0097a4bd, 0x008e4472, 0x00872439, 0x0083841c, 0x0083641b, 0x0086e437, 0x008de46f, 0x009724b9, 0x00a30518, 0x00b665b3, 0x00d866c3, 0x010b885c, 0x01460a30, 0x0187ec3f,
0x00e80740, 0x00bec5f6, 0x00aa6553, 0x009d24e9, 0x009404a0, 0x008d846c, 0x0089e44f, 0x0089e44f, 0x008d446a, 0x0093c49e, 0x009ca4e5, 0x00a9854c, 0x00bdc5ee, 0x00e5a72d, 0x0118c8c6, 0x01534a9a, 0x01952ca9,
0x00fca7e5, 0x00d06683, 0x00b5c5ae, 0x00a5852c, 0x009c84e4, 0x009664b3, 0x0093649b, 0x0093449a, 0x009624b1, 0x009c24e1, 0x00a50528, 0x00b4e5a7, 0x00ce8674, 0x00fa47d2, 0x012d696b, 0x0167eb3f, 0x01a9cd4e,
0x011888c4, 0x00ec6763, 0x00c7863c, 0x00b4e5a7, 0x00a8a545, 0x00a1c50e, 0x009ec4f6, 0x009ea4f5, 0x00a1a50d, 0x00a82541, 0x00b445a2, 0x00c5e62f, 0x00ea6753, 0x011648b2, 0x01496a4b, 0x0183ec1f, 0x01c5ae2d,
0x013bc9de, 0x010fa87d, 0x00eac756, 0x00cd466a, 0x00bc25e1, 0x00b405a0, 0x00afc57e, 0x00afa57d, 0x00b3a59d, 0x00bbc5de, 0x00cc0660, 0x00e92749, 0x010da86d, 0x013989cc, 0x016cab65, 0x01a72d39, 0x01e8ef47,
0x01666b33, 0x013a49d2, 0x011568ab, 0x00f7e7bf, 0x00e1c70e, 0x00d2e697, 0x00cb665b, 0x00cb2659, 0x00d26693, 0x00e0c706, 0x00f6a7b5, 0x0113c89e, 0x013849c2, 0x01642b21, 0x01974cba, 0x01d1ce8e, 0x0213909c,
0x01986cc3, 0x016c2b61, 0x01476a3b, 0x0129e94f, 0x0113a89d, 0x0104c826, 0x00fd47ea, 0x00fd27e9, 0x01044822, 0x0112c896, 0x0128a945, 0x0145ca2e, 0x016a4b52, 0x01960cb0, 0x01c92e49, 0x0203b01d, 0x0245922c,
0x01d1ae8d, 0x01a58d2c, 0x0180ac05, 0x01632b19, 0x014cea67, 0x013e29f1, 0x013689b4, 0x013669b3, 0x013d89ec, 0x014c0a60, 0x0161eb0f, 0x017f0bf8, 0x01a38d1c, 0x01cf4e7a, 0x02029014, 0x023d11e8, 0x027ed3f6,
};
}
std::vector<i2c_random_wr_payload> OS04C10::getExposureRegisters(int exposure_time, int new_exp_g, bool dc_gain_enabled) const {

View File

@@ -88,13 +88,22 @@ OX03C10::OX03C10() {
0x00003fff, 0x00003fff, 0x00003fff, 0x00003fff,
0x00003fff, 0x00003fff, 0x00003fff, 0x00003fff,
};
for (int i = 0; i < 252; i++) {
linearization_lut.push_back(0x0);
}
linearization_pts = {0x07ff0bff, 0x17ff1bff, 0x1fff23ff, 0x27ff3fff};
for (int i = 0; i < 884*2; i++) {
vignetting_lut.push_back(0xff);
}
vignetting_lut = {
0x00eaa755, 0x00cf2679, 0x00bc05e0, 0x00acc566, 0x00a1450a, 0x009984cc, 0x0095a4ad, 0x009584ac, 0x009944ca, 0x00a0c506, 0x00ac0560, 0x00bb25d9, 0x00ce2671, 0x00e90748, 0x01112889, 0x014a2a51, 0x01984cc2,
0x00db06d8, 0x00c30618, 0x00afe57f, 0x00a0a505, 0x009524a9, 0x008d646b, 0x0089844c, 0x0089644b, 0x008d2469, 0x0094a4a5, 0x009fe4ff, 0x00af0578, 0x00c20610, 0x00d986cc, 0x00fda7ed, 0x01320990, 0x017aebd7,
0x00d1868c, 0x00baa5d5, 0x00a7853c, 0x009844c2, 0x008cc466, 0x0085a42d, 0x0083641b, 0x0083641b, 0x0085842c, 0x008c4462, 0x0097a4bd, 0x00a6c536, 0x00b9a5cd, 0x00d06683, 0x00f1678b, 0x01226913, 0x0167ab3d,
0x00cd0668, 0x00b625b1, 0x00a30518, 0x0093c49e, 0x00884442, 0x00830418, 0x0080e407, 0x0080c406, 0x0082e417, 0x0087c43e, 0x00932499, 0x00a22511, 0x00b525a9, 0x00cbe65f, 0x00eb0758, 0x011a68d3, 0x015daaed,
0x00cc4662, 0x00b565ab, 0x00a24512, 0x00930498, 0x0087843c, 0x0082a415, 0x00806403, 0x00806403, 0x00828414, 0x00870438, 0x00926493, 0x00a1850c, 0x00b465a3, 0x00cb2659, 0x00ea2751, 0x011928c9, 0x015c2ae1,
0x00cf667b, 0x00b885c4, 0x00a5652b, 0x009624b1, 0x008aa455, 0x00846423, 0x00822411, 0x00822411, 0x00844422, 0x008a2451, 0x009564ab, 0x00a48524, 0x00b785bc, 0x00ce4672, 0x00ee6773, 0x011e88f4, 0x0162eb17,
0x00d6c6b6, 0x00bf65fb, 0x00ac4562, 0x009d04e8, 0x0091848c, 0x0089c44e, 0x00862431, 0x00860430, 0x0089844c, 0x00910488, 0x009c64e3, 0x00ab655b, 0x00be65f3, 0x00d566ab, 0x00f847c2, 0x012b2959, 0x01726b93,
0x00e3e71f, 0x00ca0650, 0x00b705b8, 0x00a7a53d, 0x009c24e1, 0x009484a4, 0x00908484, 0x00908484, 0x009424a1, 0x009bc4de, 0x00a70538, 0x00b625b1, 0x00c90648, 0x00e26713, 0x0108e847, 0x013fe9ff, 0x018bcc5e,
0x00f807c0, 0x00d966cb, 0x00c5862c, 0x00b625b1, 0x00aaa555, 0x00a30518, 0x009f04f8, 0x009f04f8, 0x00a2a515, 0x00aa2551, 0x00b585ac, 0x00c4a625, 0x00d846c2, 0x00f647b2, 0x0121a90d, 0x015e4af2, 0x01b8cdc6,
0x011548aa, 0x00f1678b, 0x00d886c4, 0x00c86643, 0x00bce5e7, 0x00b545aa, 0x00b1658b, 0x00b1458a, 0x00b505a8, 0x00bc85e4, 0x00c7c63e, 0x00d786bc, 0x00efe77f, 0x0113489a, 0x0144ea27, 0x01888c44, 0x01fdcfee,
0x013e49f2, 0x0113e89f, 0x00f5a7ad, 0x00e0c706, 0x00d30698, 0x00cb665b, 0x00c7663b, 0x00c7663b, 0x00cb0658, 0x00d2a695, 0x00dfe6ff, 0x00f467a3, 0x01122891, 0x013be9df, 0x01750ba8, 0x01cfae7d, 0x025912c8,
0x01766bb3, 0x01446a23, 0x011fc8fe, 0x0105e82f, 0x00f467a3, 0x00e9874c, 0x00e46723, 0x00e44722, 0x00e92749, 0x00f3a79d, 0x0104c826, 0x011e48f2, 0x01424a12, 0x01738b9c, 0x01bf6dfb, 0x023611b0, 0x02ced676,
0x01cf8e7c, 0x01866c33, 0x015aaad5, 0x013ae9d7, 0x01250928, 0x011768bb, 0x0110a885, 0x01108884, 0x0116e8b7, 0x01242921, 0x0139a9cd, 0x0158eac7, 0x01840c20, 0x01cb0e58, 0x0233719b, 0x02b9d5ce, 0x03645b22,
};
}
std::vector<i2c_random_wr_payload> OX03C10::getExposureRegisters(int exposure_time, int new_exp_g, bool dc_gain_enabled) const {

View File

@@ -79,9 +79,9 @@ public:
}
gamma_lut_rgb.pop_back();
}
std::vector<uint32_t> linearization_lut; // length 288
std::vector<uint32_t> linearization_lut; // length 36
std::vector<uint32_t> linearization_pts; // length 4
std::vector<uint32_t> vignetting_lut; // 2x length 884
std::vector<uint32_t> vignetting_lut; // length 221
};
class AR0231 : public SensorInfo {

View File

@@ -1,6 +1,7 @@
#pragma once
#include <cstdlib>
#include <cassert>
#include <fstream>
#include <map>
#include <string>
@@ -22,7 +23,7 @@ public:
static std::string get_name() {
std::string model = util::read_file("/sys/firmware/devicetree/base/model");
return model.substr(std::string("comma ").size());
return util::strip(model.substr(std::string("comma ").size()));
}
static cereal::InitData::DeviceType get_device_type() {
@@ -32,7 +33,8 @@ public:
{"mici", cereal::InitData::DeviceType::MICI}
};
auto it = device_map.find(get_name());
return it != device_map.end() ? it->second : cereal::InitData::DeviceType::UNKNOWN;
assert(it != device_map.end());
return it->second;
}
static int get_voltage() { return std::atoi(util::read_file("/sys/class/hwmon/hwmon1/in1_input").c_str()); }
@@ -82,17 +84,17 @@ public:
return;
}
percent = std::clamp(percent, 0, 100);
int value = util::map_val(std::clamp(percent, 0, 100), 0, 100, 0, 255);
std::ofstream torch_brightness("/sys/class/leds/led:torch_2/brightness");
if (torch_brightness.is_open()) {
torch_brightness << percent << "\n";
torch_brightness << value << "\n";
torch_brightness.close();
}
std::ofstream switch_brightness("/sys/class/leds/led:switch_2/brightness");
if (switch_brightness.is_open()) {
switch_brightness << percent << "\n";
switch_brightness << value << "\n";
switch_brightness.close();
}
}

View File

@@ -67,7 +67,8 @@ def manager_init() -> None:
except PermissionError:
print(f"WARNING: failed to make {Paths.shm_path()}")
# set version params
# set params
serial = HARDWARE.get_serial()
params.put("Version", build_metadata.openpilot.version)
params.put("TermsVersion", terms_version)
params.put("TrainingVersion", training_version)
@@ -77,13 +78,13 @@ def manager_init() -> None:
params.put("GitRemote", build_metadata.openpilot.git_origin)
params.put_bool("IsTestedBranch", build_metadata.tested_channel)
params.put_bool("IsReleaseBranch", build_metadata.release_channel)
params.put("HardwareSerial", serial)
# set dongle id
reg_res = register(show_spinner=True)
if reg_res:
dongle_id = reg_res
else:
serial = params.get("HardwareSerial")
raise Exception(f"Registration failed for device {serial}")
os.environ['DONGLE_ID'] = dongle_id # Needed for swaglog
os.environ['GIT_ORIGIN'] = build_metadata.openpilot.git_normalized_origin # Needed for swaglog

View File

@@ -79,7 +79,8 @@ def and_(*fns):
procs = [
DaemonProcess("manage_athenad", "system.athena.manage_athenad", "AthenadPid"),
NativeProcess("camerad", "system/camerad", ["./camerad"], driverview),
NativeProcess("camerad", "system/camerad", ["./camerad"], driverview, enabled=not WEBCAM),
PythonProcess("webcamerad", "tools.webcam.camerad", driverview, enabled=WEBCAM),
NativeProcess("logcatd", "system/logcatd", ["./logcatd"], only_onroad),
NativeProcess("proclogd", "system/proclogd", ["./proclogd"], only_onroad),
PythonProcess("logmessaged", "system.logmessaged", always_run),
@@ -87,7 +88,7 @@ procs = [
PythonProcess("timed", "system.timed", always_run, enabled=not PC),
# TODO Make python process once TG allows opening QCOM from child proc
NativeProcess("dmonitoringmodeld", "selfdrive/modeld", ["./dmonitoringmodeld"], driverview, enabled=(not PC or WEBCAM)),
NativeProcess("dmonitoringmodeld", "selfdrive/modeld", ["./dmonitoringmodeld"], driverview, enabled=(WEBCAM or not PC)),
NativeProcess("encoderd", "system/loggerd", ["./encoderd"], only_onroad),
NativeProcess("stream_encoderd", "system/loggerd", ["./encoderd", "--stream"], notcar),
NativeProcess("loggerd", "system/loggerd", ["./loggerd"], logging),
@@ -105,7 +106,7 @@ procs = [
PythonProcess("selfdrived", "selfdrive.selfdrived.selfdrived", only_onroad),
PythonProcess("card", "selfdrive.car.card", only_onroad),
PythonProcess("deleter", "system.loggerd.deleter", always_run),
PythonProcess("dmonitoringd", "selfdrive.monitoring.dmonitoringd", driverview, enabled=(not PC or WEBCAM)),
PythonProcess("dmonitoringd", "selfdrive.monitoring.dmonitoringd", driverview, enabled=(WEBCAM or not PC)),
PythonProcess("qcomgpsd", "system.qcomgpsd.qcomgpsd", qcomgps, enabled=TICI),
PythonProcess("pandad", "selfdrive.pandad.pandad", always_run),
PythonProcess("paramsd", "selfdrive.locationd.paramsd", only_onroad),

View File

@@ -13,7 +13,7 @@ from openpilot.common.gps import get_gps_location_service
def set_time(new_time):
diff = datetime.datetime.now() - new_time
if diff < datetime.timedelta(seconds=10):
if abs(diff) < datetime.timedelta(seconds=10):
cloudlog.debug(f"Time diff too small: {diff}")
return

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:fb3b1fd29d958e9a3a6625eac9fac9e7cd6eb40309b285ad973324761db0b4c9
size 1202792

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:161a5d0bf7347465b53ae49690a38fbacf03d606ef204147b3b148a5f59188da
size 9008016

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:7e0e66c12a1eb3b5b4b2b2694831ca51e5132818f400dad789adbcc30e0e0793
size 14032

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:784f2e80fa3534cf7934c5ecbbda37db633104380f2b41d896b4721ad6006eb2
size 2420312

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:33afe465e74bbe2c409350d2ca8e86cfadf050ceb8feac75a86adc19ff1f9c48
size 26016

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:7bee94d38195478ffdd0ce15292a2dfa7813377f4c3b7d99c270e05079d1746b
size 20828

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4e040c87072aa915c47859c8c7f74076b98c6919b83ddd5dc4bb555870d586a7
size 1813866

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:838bc58ac0094ba9593cf7c44ab6e8a94ae3dbbe176e320d9fbe86ceead53c5e
size 1817962

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:77d025d59521e13e4ed012f0d9d2b684cdb858208d70426078df51219eaeb9bd
size 10098673

View File

@@ -1,84 +0,0 @@
//=============================================================================
//
// Copyright (c) 2015, 2020 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//=============================================================================
#ifndef __IDIAGLOG_HPP_
#define __IDIAGLOG_HPP_
#include <string>
#include "DiagLog/Options.hpp"
#include "DlSystem/String.hpp"
#include "DlSystem/ZdlExportDefine.hpp"
namespace zdl
{
namespace DiagLog
{
/** @addtogroup c_plus_plus_apis C++
@{ */
/// @brief .
///
/// Interface for controlling logging for zdl components.
class ZDL_EXPORT IDiagLog
{
public:
/// @brief .
///
/// Sets the options after initialization occurs.
///
/// @param[in] loggingOptions The options to set up diagnostic logging.
///
/// @return False if the options could not be set. Ensure logging is not started.
virtual bool setOptions(const Options& loggingOptions) = 0;
/// @brief .
///
/// Gets the curent options for the diag logger.
///
/// @return Diag log options object.
virtual Options getOptions() = 0;
/// @brief .
///
/// Allows for setting the log mask once diag logging has started
///
/// @return True if the level was set successfully, false if a failure occurred.
virtual bool setDiagLogMask(const std::string& mask) = 0;
/// @brief .
///
/// Allows for setting the log mask once diag logging has started
///
/// @return True if the level was set successfully, false if a failure occurred.
virtual bool setDiagLogMask(const zdl::DlSystem::String& mask) = 0;
/// @brief .
///
/// Enables logging for zdl components.
///
/// Logging should be started prior to the instantiation of zdl components
/// to ensure all events are captured.
///
/// @return False if diagnostic logging could not be started.
virtual bool start(void) = 0;
/// @brief Disables logging for zdl components.
virtual bool stop(void) = 0;
virtual ~IDiagLog() {};
};
} // DiagLog namespace
} // zdl namespace
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */
#endif

View File

@@ -1,79 +0,0 @@
//=============================================================================
//
// Copyright (c) 2015, 2020 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//=============================================================================
#ifndef __DIAGLOG_OPTIONS_HPP_
#define __DIAGLOG_OPTIONS_HPP_
#include <string>
#include "DlSystem/ZdlExportDefine.hpp"
namespace zdl
{
namespace DiagLog
{
/** @addtogroup c_plus_plus_apis C++
@{ */
/// @brief .
///
/// Options for setting up diagnostic logging for zdl components.
class ZDL_EXPORT Options
{
public:
Options() :
DiagLogMask(""),
LogFileDirectory("diaglogs"),
LogFileName("DiagLog"),
LogFileRotateCount(20),
LogFileReplace(true)
{
// Solves the empty string problem with multiple std libs
DiagLogMask.reserve(1);
}
/// @brief .
///
/// Enables diag logging only on the specified area mask (DNN_RUNTIME=ON | OFF)
std::string DiagLogMask;
/// @brief .
///
/// The path to the directory where log files will be written.
/// The path may be relative or absolute. Relative paths are interpreted
/// from the current working directory.
/// Default value is "diaglogs"
std::string LogFileDirectory;
/// @brief .
///
//// The name used for log files. If this value is empty then BaseName will be
/// used as the default file name.
/// Default value is "DiagLog"
std::string LogFileName;
/// @brief .
///
/// The maximum number of log files to create. If set to 0 no log rotation
/// will be used and the log file name specified will be used each time, overwriting
/// any existing log file that may exist.
/// Default value is 20
uint32_t LogFileRotateCount;
/// @brief
///
/// If the log file already exists, control whether it will be replaced
/// (existing contents truncated), or appended.
/// Default value is true
bool LogFileReplace;
};
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */
} // DiagLog namespace
} // zdl namespace
#endif

View File

@@ -1,191 +0,0 @@
//=============================================================================
//
// Copyright (c) 2015-2020 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//=============================================================================
#ifndef ZEROTH_IDNC_CONTAINER_HPP
#define ZEROTH_IDNC_CONTAINER_HPP
#include <memory>
#include <stdint.h>
#include <string>
#include <vector>
#include <set>
#include "DlSystem/ZdlExportDefine.hpp"
#include "DlSystem/String.hpp"
namespace zdl {
namespace DlContainer {
/** @addtogroup c_plus_plus_apis C++
@{ */
class IDlContainer;
class dlc_error;
/**
* The structure of a record in a DL container.
*/
struct ZDL_EXPORT DlcRecord
{
/// Name of the record.
std::string name;
/// Byte blob holding the data for the record.
std::vector<uint8_t> data;
DlcRecord();
DlcRecord( DlcRecord&& other )
: name(std::move(other.name))
, data(std::move(other.data))
{}
DlcRecord(const std::string& new_name)
: name(new_name)
, data()
{
if(name.empty())
{
name.reserve(1);
}
}
DlcRecord(const DlcRecord&) = delete;
};
// The maximum length of any record name.
extern const uint32_t RECORD_NAME_MAX_SIZE;
// The maximum size of the record payload (bytes).
extern const uint32_t RECORD_DATA_MAX_SIZE;
// The maximum number of records in an archive at one time.
extern const uint32_t ARCHIVE_MAX_RECORDS;
/**
* Represents a container for a neural network model which can
* be used to load the model into the SNPE runtime.
*/
class ZDL_EXPORT IDlContainer
{
public:
/**
* Initializes a container from a container archive file.
*
* @param[in] filename Container archive file path.
*
* @return A pointer to the initialized container
*/
static std::unique_ptr<IDlContainer>
open(const std::string &filename) noexcept;
/**
* Initializes a container from a container archive file.
*
* @param[in] filename Container archive file path.
*
* @return A pointer to the initialized container
*/
static std::unique_ptr<IDlContainer>
open(const zdl::DlSystem::String &filename) noexcept;
/**
* Initializes a container from a byte buffer.
*
* @param[in] buffer Byte buffer holding the contents of an archive
* file.
*
* @return A pointer to the initialized container
*/
static std::unique_ptr<IDlContainer>
open(const std::vector<uint8_t> &buffer) noexcept;
/**
* Initializes a container from a byte buffer.
*
* @param[in] buffer Byte buffer holding the contents of an archive
* file.
*
* @param[in] size Size of the byte buffer.
*
* @return A pointer to the initialized container
*/
static std::unique_ptr<IDlContainer>
open(const uint8_t* buffer, const size_t size) noexcept;
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */
/**
* Get the record catalog for a container.
*
* @param[out] catalog Buffer that will hold the record names on
* return.
*/
virtual void getCatalog(std::set<std::string> &catalog) const = 0;
/**
* Get the record catalog for a container.
*
* @param[out] catalog Buffer that will hold the record names on
* return.
*/
virtual void getCatalog(std::set<zdl::DlSystem::String> &catalog) const = 0;
/**
* Get a record from a container by name.
*
* @param[in] name Name of the record to fetch.
* @param[out] record The passed in record will be populated with the
* record data on return. Note that the caller
* will own the data in the record and is
* responsible for freeing it if needed.
*/
virtual void getRecord(const std::string &name, DlcRecord &record) const = 0;
/**
* Get a record from a container by name.
*
* @param[in] name Name of the record to fetch.
* @param[out] record The passed in record will be populated with the
* record data on return. Note that the caller
* will own the data in the record and is
* responsible for freeing it if needed.
*/
virtual void getRecord(const zdl::DlSystem::String &name, DlcRecord &record) const = 0;
/**
* Save the container to an archive on disk. This function will save the
* container if the filename is different from the file that it was opened
* from, or if at least one record was modified since the container was
* opened.
*
* It will truncate any existing file at the target path.
*
* @param filename Container archive file path.
*
* @return indication of success/failure
*/
virtual bool save(const std::string &filename) = 0;
/**
* Save the container to an archive on disk. This function will save the
* container if the filename is different from the file that it was opened
* from, or if at least one record was modified since the container was
* opened.
*
* It will truncate any existing file at the target path.
*
* @param filename Container archive file path.
*
* @return indication of success/failure
*/
virtual bool save (const zdl::DlSystem::String &filename) = 0;
virtual ~IDlContainer() {}
};
} // ns DlContainer
} // ns zdl
#endif

View File

@@ -1,234 +0,0 @@
//==============================================================================
//
// Copyright (c) 2014-2021 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//==============================================================================
#ifndef _DL_ENUMS_HPP_
#define _DL_ENUMS_HPP_
#include "DlSystem/ZdlExportDefine.hpp"
namespace zdl {
namespace DlSystem
{
/** @addtogroup c_plus_plus_apis C++
@{ */
/**
* Enumeration of supported target runtimes.
*/
enum class Runtime_t
{
/// Run the processing on Snapdragon CPU.
/// Data: float 32bit
/// Math: float 32bit
CPU_FLOAT32 = 0,
/// Run the processing on the Adreno GPU.
/// Data: float 16bit
/// Math: float 32bit
GPU_FLOAT32_16_HYBRID = 1,
/// Run the processing on the Hexagon DSP.
/// Data: 8bit fixed point Tensorflow style format
/// Math: 8bit fixed point Tensorflow style format
DSP_FIXED8_TF = 2,
/// Run the processing on the Adreno GPU.
/// Data: float 16bit
/// Math: float 16bit
GPU_FLOAT16 = 3,
/// Run the processing on Snapdragon AIX+HVX.
/// Data: 8bit fixed point Tensorflow style format
/// Math: 8bit fixed point Tensorflow style format
AIP_FIXED8_TF = 5,
AIP_FIXED_TF = AIP_FIXED8_TF,
/// Default legacy enum to retain backward compatibility.
/// CPU = CPU_FLOAT32
CPU = CPU_FLOAT32,
/// Default legacy enum to retain backward compatibility.
/// GPU = GPU_FLOAT32_16_HYBRID
GPU = GPU_FLOAT32_16_HYBRID,
/// Default legacy enum to retain backward compatibility.
/// DSP = DSP_FIXED8_TF
DSP = DSP_FIXED8_TF,
/// Special value indicating the property is unset.
UNSET = -1
};
/**
* Enumeration of runtime available check options.
*/
enum class RuntimeCheckOption_t
{
/// Perform standard runtime available check
DEFAULT = 0,
/// Perform standard runtime available check
NORMAL_CHECK = 0,
/// Perform basic runtime available check, may be runtime specific
BASIC_CHECK = 1,
/// Perform unsignedPD runtime available check
UNSIGNEDPD_CHECK = 2,
};
/**
* Enumeration of various performance profiles that can be requested.
*/
enum class PerformanceProfile_t
{
/// Run in a standard mode.
/// This mode will be deprecated in the future and replaced with BALANCED.
DEFAULT = 0,
/// Run in a balanced mode.
BALANCED = 0,
/// Run in high performance mode
HIGH_PERFORMANCE = 1,
/// Run in a power sensitive mode, at the expense of performance.
POWER_SAVER = 2,
/// Use system settings. SNPE makes no calls to any performance related APIs.
SYSTEM_SETTINGS = 3,
/// Run in sustained high performance mode
SUSTAINED_HIGH_PERFORMANCE = 4,
/// Run in burst mode
BURST = 5,
/// Run in lower clock than POWER_SAVER, at the expense of performance.
LOW_POWER_SAVER = 6,
/// Run in higher clock and provides better performance than POWER_SAVER.
HIGH_POWER_SAVER = 7,
/// Run in lower balanced mode
LOW_BALANCED = 8,
};
/**
* Enumeration of various profilngLevels that can be requested.
*/
enum class ProfilingLevel_t
{
/// No profiling.
/// Collects no runtime stats in the DiagLog
OFF = 0,
/// Basic profiling
/// Collects some runtime stats in the DiagLog
BASIC = 1,
/// Detailed profiling
/// Collects more runtime stats in the DiagLog, including per-layer statistics
/// Performance may be impacted
DETAILED = 2,
/// Moderate profiling
/// Collects more runtime stats in the DiagLog, no per-layer statistics
MODERATE = 3
};
/**
* Enumeration of various execution priority hints.
*/
enum class ExecutionPriorityHint_t
{
/// Normal priority
NORMAL = 0,
/// Higher than normal priority
HIGH = 1,
/// Lower priority
LOW = 2
};
/** @} */ /* end_addtogroup c_plus_plus_apis C++*/
/**
* Enumeration that lists the supported image encoding formats.
*/
enum class ImageEncoding_t
{
/// For unknown image type. Also used as a default value for ImageEncoding_t.
UNKNOWN = 0,
/// The RGB format consists of 3 bytes per pixel: one byte for
/// Red, one for Green, and one for Blue. The byte ordering is
/// endian independent and is always in RGB byte order.
RGB = 1,
/// The ARGB32 format consists of 4 bytes per pixel: one byte for
/// Red, one for Green, one for Blue, and one for the alpha channel.
/// The alpha channel is ignored. The byte ordering depends on the
/// underlying CPU. For little endian CPUs, the byte order is BGRA.
/// For big endian CPUs, the byte order is ARGB.
ARGB32 = 2,
/// The RGBA format consists of 4 bytes per pixel: one byte for
/// Red, one for Green, one for Blue, and one for the alpha channel.
/// The alpha channel is ignored. The byte ordering is endian independent
/// and is always in RGBA byte order.
RGBA = 3,
/// The GRAYSCALE format is for 8-bit grayscale.
GRAYSCALE = 4,
/// NV21 is the Android version of YUV. The Chrominance is down
/// sampled and has a subsampling ratio of 4:2:0. Note that this
/// image format has 3 channels, but the U and V channels
/// are subsampled. For every four Y pixels there is one U and one V pixel. @newpage
NV21 = 5,
/// The BGR format consists of 3 bytes per pixel: one byte for
/// Red, one for Green and one for Blue. The byte ordering is
/// endian independent and is always BGR byte order.
BGR = 6
};
/**
* Enumeration that lists the supported LogLevels that can be set by users.
*/
enum class LogLevel_t
{
/// Enumeration variable to be used by user to set logging level to FATAL.
LOG_FATAL = 0,
/// Enumeration variable to be used by user to set logging level to ERROR.
LOG_ERROR = 1,
/// Enumeration variable to be used by user to set logging level to WARN.
LOG_WARN = 2,
/// Enumeration variable to be used by user to set logging level to INFO.
LOG_INFO = 3,
/// Enumeration variable to be used by user to set logging level to VERBOSE.
LOG_VERBOSE = 4
};
typedef enum : int
{
UNSPECIFIED = 0,
FLOATING_POINT_32 = 1,
FLOATING_POINT_16 = 2,
FIXED_POINT_8 = 3,
FIXED_POINT_16 = 4
} IOBufferDataType_t;
}} // namespaces end
#endif

View File

@@ -1,259 +0,0 @@
//==============================================================================
//
// Copyright (c) 2016-2021 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//==============================================================================
#ifndef _DL_ERROR_HPP_
#define _DL_ERROR_HPP_
#include <stdint.h>
#include <limits> // numeric_limits
#include "DlSystem/ZdlExportDefine.hpp"
namespace zdl {
namespace DlSystem {
// clang and arm gcc different in how ZDL_EXPORT is used with enum class
#if !defined (__clang__)
enum class ErrorCode : uint32_t ZDL_EXPORT {
#else
enum class ZDL_EXPORT ErrorCode : uint32_t {
#endif // ARM64V8A
NONE = 0,
// System config errors
SNPE_CONFIG_MISSING_PARAM = 100,
SNPE_CONFIG_INVALID_PARAM = 101,
SNPE_CONFIG_MISSING_FILE = 102,
SNPE_CONFIG_NNCONFIG_NOT_SET = 103,
SNPE_CONFIG_NNCONFIG_INVALID = 104,
SNPE_CONFIG_WRONG_INPUT_NAME = 105,
SNPE_CONFIG_INCORRECT_INPUT_DIMENSIONS = 106,
SNPE_CONFIG_DIMENSIONS_MODIFICATION_NOT_SUPPORTED = 107,
SNPE_CONFIG_BOTH_OUTPUT_LAYER_TENSOR_NAMES_SET = 108,
SNPE_CONFIG_NNCONFIG_ONLY_TENSOR_SUPPORTED = 120,
SNPE_CONFIG_NNCONFIG_ONLY_USER_BUFFER_SUPPORTED = 121,
// DlSystem errors
SNPE_DLSYSTEM_MISSING_BUFFER = 200,
SNPE_DLSYSTEM_TENSOR_CAST_FAILED = 201,
SNPE_DLSYSTEM_FIXED_POINT_PARAM_INVALID = 202,
SNPE_DLSYSTEM_SIZE_MISMATCH = 203,
SNPE_DLSYSTEM_NAME_NOT_FOUND = 204,
SNPE_DLSYSTEM_VALUE_MISMATCH = 205,
SNPE_DLSYSTEM_INSERT_FAILED = 206,
SNPE_DLSYSTEM_TENSOR_FILE_READ_FAILED = 207,
SNPE_DLSYSTEM_DIAGLOG_FAILURE = 208,
SNPE_DLSYSTEM_LAYER_NOT_SET = 209,
SNPE_DLSYSTEM_WRONG_NUMBER_INPUT_BUFFERS = 210,
SNPE_DLSYSTEM_RUNTIME_TENSOR_SHAPE_MISMATCH = 211,
SNPE_DLSYSTEM_TENSOR_MISSING = 212,
SNPE_DLSYSTEM_TENSOR_ITERATION_UNSUPPORTED = 213,
SNPE_DLSYSTEM_BUFFER_MANAGER_MISSING = 214,
SNPE_DLSYSTEM_RUNTIME_BUFFER_SOURCE_UNSUPPORTED = 215,
SNPE_DLSYSTEM_BUFFER_CAST_FAILED = 216,
SNPE_DLSYSTEM_WRONG_TRANSITION_TYPE = 217,
SNPE_DLSYSTEM_LAYER_ALREADY_REGISTERED = 218,
SNPE_DLSYSTEM_TENSOR_DIM_INVALID = 219,
SNPE_DLSYSTEM_BUFFERENCODING_UNKNOWN = 240,
SNPE_DLSYSTEM_BUFFER_INVALID_PARAM = 241,
// DlContainer errors
SNPE_DLCONTAINER_MODEL_PARSING_FAILED = 300,
SNPE_DLCONTAINER_UNKNOWN_LAYER_CODE = 301,
SNPE_DLCONTAINER_MISSING_LAYER_PARAM = 302,
SNPE_DLCONTAINER_LAYER_PARAM_NOT_SUPPORTED = 303,
SNPE_DLCONTAINER_LAYER_PARAM_INVALID = 304,
SNPE_DLCONTAINER_TENSOR_DATA_MISSING = 305,
SNPE_DLCONTAINER_MODEL_LOAD_FAILED = 306,
SNPE_DLCONTAINER_MISSING_RECORDS = 307,
SNPE_DLCONTAINER_INVALID_RECORD = 308,
SNPE_DLCONTAINER_WRITE_FAILURE = 309,
SNPE_DLCONTAINER_READ_FAILURE = 310,
SNPE_DLCONTAINER_BAD_CONTAINER = 311,
SNPE_DLCONTAINER_BAD_DNN_FORMAT_VERSION = 312,
SNPE_DLCONTAINER_UNKNOWN_AXIS_ANNOTATION = 313,
SNPE_DLCONTAINER_UNKNOWN_SHUFFLE_TYPE = 314,
SNPE_DLCONTAINER_TEMP_FILE_FAILURE = 315,
// Network errors
SNPE_NETWORK_EMPTY_NETWORK = 400,
SNPE_NETWORK_CREATION_FAILED = 401,
SNPE_NETWORK_PARTITION_FAILED = 402,
SNPE_NETWORK_NO_OUTPUT_DEFINED = 403,
SNPE_NETWORK_MISMATCH_BETWEEN_NAMES_AND_DIMS = 404,
SNPE_NETWORK_MISSING_INPUT_NAMES = 405,
SNPE_NETWORK_MISSING_OUTPUT_NAMES = 406,
SNPE_NETWORK_EXECUTION_FAILED = 407,
// Host runtime errors
SNPE_HOST_RUNTIME_TARGET_UNAVAILABLE = 500,
// CPU runtime errors
SNPE_CPU_LAYER_NOT_SUPPORTED = 600,
SNPE_CPU_LAYER_PARAM_NOT_SUPPORTED = 601,
SNPE_CPU_LAYER_PARAM_INVALID = 602,
SNPE_CPU_LAYER_PARAM_COMBINATION_INVALID = 603,
SNPE_CPU_BUFFER_NOT_FOUND = 604,
SNPE_CPU_NETWORK_NOT_SUPPORTED = 605,
SNPE_CPU_UDO_OPERATION_FAILED = 606,
// CPU fixed-point runtime errors
SNPE_CPU_FXP_LAYER_NOT_SUPPORTED = 700,
SNPE_CPU_FXP_LAYER_PARAM_NOT_SUPPORTED = 701,
SNPE_CPU_FXP_LAYER_PARAM_INVALID = 702,
// GPU runtime errors
SNPE_GPU_LAYER_NOT_SUPPORTED = 800,
SNPE_GPU_LAYER_PARAM_NOT_SUPPORTED = 801,
SNPE_GPU_LAYER_PARAM_INVALID = 802,
SNPE_GPU_LAYER_PARAM_COMBINATION_INVALID = 803,
SNPE_GPU_KERNEL_COMPILATION_FAILED = 804,
SNPE_GPU_CONTEXT_NOT_SET = 805,
SNPE_GPU_KERNEL_NOT_SET = 806,
SNPE_GPU_KERNEL_PARAM_INVALID = 807,
SNPE_GPU_OPENCL_CHECK_FAILED = 808,
SNPE_GPU_OPENCL_FUNCTION_ERROR = 809,
SNPE_GPU_BUFFER_NOT_FOUND = 810,
SNPE_GPU_TENSOR_DIM_INVALID = 811,
SNPE_GPU_MEMORY_FLAGS_INVALID = 812,
SNPE_GPU_UNEXPECTED_NUMBER_OF_IO = 813,
SNPE_GPU_LAYER_PROXY_ERROR = 814,
SNPE_GPU_BUFFER_IN_USE = 815,
SNPE_GPU_BUFFER_MODIFICATION_ERROR = 816,
SNPE_GPU_DATA_ARRANGEMENT_INVALID = 817,
SNPE_GPU_UDO_OPERATION_FAILED = 818,
// DSP runtime errors
SNPE_DSP_LAYER_NOT_SUPPORTED = 900,
SNPE_DSP_LAYER_PARAM_NOT_SUPPORTED = 901,
SNPE_DSP_LAYER_PARAM_INVALID = 902,
SNPE_DSP_LAYER_PARAM_COMBINATION_INVALID = 903,
SNPE_DSP_STUB_NOT_PRESENT = 904,
SNPE_DSP_LAYER_NAME_TRUNCATED = 905,
SNPE_DSP_LAYER_INPUT_BUFFER_NAME_TRUNCATED = 906,
SNPE_DSP_LAYER_OUTPUT_BUFFER_NAME_TRUNCATED = 907,
SNPE_DSP_RUNTIME_COMMUNICATION_ERROR = 908,
SNPE_DSP_RUNTIME_INVALID_PARAM_ERROR = 909,
SNPE_DSP_RUNTIME_SYSTEM_ERROR = 910,
SNPE_DSP_RUNTIME_CRASHED_ERROR = 911,
SNPE_DSP_BUFFER_SIZE_ERROR = 912,
SNPE_DSP_UDO_EXECUTE_ERROR = 913,
SNPE_DSP_UDO_LIB_NOT_REGISTERED_ERROR = 914,
SNPE_DSP_UDO_INVALID_QUANTIZATION_TYPE_ERROR = 915,
SNPE_DSP_RUNTIME_INVALID_RPC_DRIVER = 916,
SNPE_DSP_RUNTIME_RPC_PERMISSION_ERROR = 917,
SNPE_DSP_RUNTIME_DSP_FILE_OPEN_ERROR = 918,
// Model validataion errors
SNPE_MODEL_VALIDATION_LAYER_NOT_SUPPORTED = 1000,
SNPE_MODEL_VALIDATION_LAYER_PARAM_NOT_SUPPORTED = 1001,
SNPE_MODEL_VALIDATION_LAYER_PARAM_INVALID = 1002,
SNPE_MODEL_VALIDATION_LAYER_PARAM_MISSING = 1003,
SNPE_MODEL_VALIDATION_LAYER_PARAM_COMBINATION_INVALID = 1004,
SNPE_MODEL_VALIDATION_LAYER_ORDERING_INVALID = 1005,
SNPE_MODEL_VALIDATION_INVALID_CONSTRAINT = 1006,
SNPE_MODEL_VALIDATION_MISSING_BUFFER = 1007,
SNPE_MODEL_VALIDATION_BUFFER_REUSE_NOT_SUPPORTED = 1008,
SNPE_MODEL_VALIDATION_LAYER_COULD_NOT_BE_ASSIGNED = 1009,
SNPE_MODEL_VALIDATION_UDO_LAYER_FAILED = 1010,
// UDL errors
SNPE_UDL_LAYER_EMPTY_UDL_NETWORK = 1100,
SNPE_UDL_LAYER_PARAM_INVALID = 1101,
SNPE_UDL_LAYER_INSTANCE_MISSING = 1102,
SNPE_UDL_LAYER_SETUP_FAILED = 1103,
SNPE_UDL_EXECUTE_FAILED = 1104,
SNPE_UDL_BUNDLE_INVALID = 1105,
SNPE_UDO_REGISTRATION_FAILED = 1106,
SNPE_UDO_GET_PACKAGE_FAILED = 1107,
SNPE_UDO_GET_IMPLEMENTATION_FAILED = 1108,
// Dependent library errors
SNPE_STD_LIBRARY_ERROR = 1200,
// Unknown exception (catch (...)), Has no component attached to this
SNPE_UNKNOWN_EXCEPTION = 1210,
// Storage Errors
SNPE_STORAGE_INVALID_KERNEL_REPO = 1300,
// AIP runtime errors
SNPE_AIP_LAYER_NOT_SUPPORTED = 1400,
SNPE_AIP_LAYER_PARAM_NOT_SUPPORTED = 1401,
SNPE_AIP_LAYER_PARAM_INVALID = 1402,
SNPE_AIP_LAYER_PARAM_COMBINATION_INVALID = 1403,
SNPE_AIP_STUB_NOT_PRESENT = 1404,
SNPE_AIP_LAYER_NAME_TRUNCATED = 1405,
SNPE_AIP_LAYER_INPUT_BUFFER_NAME_TRUNCATED = 1406,
SNPE_AIP_LAYER_OUTPUT_BUFFER_NAME_TRUNCATED = 1407,
SNPE_AIP_RUNTIME_COMMUNICATION_ERROR = 1408,
SNPE_AIP_RUNTIME_INVALID_PARAM_ERROR = 1409,
SNPE_AIP_RUNTIME_SYSTEM_ERROR = 1410,
SNPE_AIP_RUNTIME_TENSOR_MISSING = 1411,
SNPE_AIP_RUNTIME_TENSOR_SHAPE_MISMATCH = 1412,
SNPE_AIP_RUNTIME_BAD_AIX_RECORD = 1413,
// DlCaching errors
SNPE_DLCACHING_INVALID_METADATA = 1500,
SNPE_DLCACHING_INVALID_INITBLOB = 1501,
// Infrastructure Errors
SNPE_INFRA_CLUSTERMGR_INSTANCE_INVALID = 1600,
SNPE_INFRA_CLUSTERMGR_EXECUTE_SYNC_FAILED = 1601,
// Memory Errors
SNPE_MEMORY_CORRUPTION_ERROR = 1700
};
/** @addtogroup c_plus_plus_apis C++
@{ */
/**
* Returns the error code of the last error encountered.
*
* @return The error code.
*
* @note The returned error code is significant only when the return
* value of the call indicated an error.
*/
ZDL_EXPORT ErrorCode getLastErrorCode();
/**
* Returns the error string of the last error encountered.
*
* @return The error string.
*
* @note The returned error string is significant only when the return
* value of the call indicated an error.
*/
ZDL_EXPORT const char* getLastErrorString();
/**
* Returns the info string of the last error encountered.
*/
ZDL_EXPORT const char* getLastInfoString();
/**
* Returns the uint32_t representation of the error code enum.
*
* @param[in] code The error code to be converted.
*
* @return uint32_t representation of the error code.
*/
ZDL_EXPORT uint32_t enumToUInt32(zdl::DlSystem::ErrorCode code);
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */
} // DlSystem
} // zdl
#endif // _DL_ERROR_HPP_

View File

@@ -1,225 +0,0 @@
//==============================================================================
//
// Copyright (c) 2016, 2020 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//==============================================================================
#ifndef _DL_SYSTEM_OPTIONAL_HPP_
#define _DL_SYSTEM_OPTIONAL_HPP_
#include <cstdio>
#include <utility>
#include <stdexcept>
#include "DlSystem/ZdlExportDefine.hpp"
namespace zdl {
namespace DlSystem {
template <typename T>
/** @addtogroup c_plus_plus_apis C++
@{ */
/**
* @brief .
*
* Class to manage a value that may or may not exist. The boolean value
* of the Optional class is true if the object contains a value and false
* if it does not contain a value.
*
* The class must be evaluated and confirmed as true (containing a value)
* before being dereferenced.
*/
class ZDL_EXPORT Optional final {
public:
enum class LIFECYCLE {
NONE = 0,
REFERENCE_OWNED = 1,
POINTER_OWNED = 2,
POINTER_NOT_OWNED = 3
};
struct ReferenceCount {
size_t count = 0;
void increment() { count++; }
size_t decrement() {
if (count > 0) {
count--;
}
return count;
}
};
using U = typename std::remove_pointer<T>::type;
/**
* The default constructor is set to not have any value, and is
* therefore evaluated as false.
*/
// Do not explicit it so we can return {}
Optional() {
m_Type = LIFECYCLE::NONE;
}
/**
* Construct an Optional class using an object.
* @param[in] Reference to an object v
* @param[out] Optional instance of object v
*/
template <typename Q = T>
Optional (const T& v, typename std::enable_if<!std::is_pointer<Q>::value>::type* = 0)
: m_Type(LIFECYCLE::REFERENCE_OWNED) {
try {
m_StoragePtr = new T(v);
} catch (...) {
m_StoragePtr = nullptr;
m_Type = LIFECYCLE::NONE;
}
}
template <typename Q = T>
Optional(U* v, LIFECYCLE type, typename std::enable_if<std::is_pointer<Q>::value>::type* = 0)
: m_Type(type) {
switch (m_Type) {
case LIFECYCLE::POINTER_OWNED:
m_StoragePtr = v;
m_Count = new ReferenceCount();
m_Count->increment();
break;
case LIFECYCLE::POINTER_NOT_OWNED:
m_StoragePtr = v;
break;
case LIFECYCLE::REFERENCE_OWNED:
throw std::bad_exception();
case LIFECYCLE::NONE:
break;
}
}
Optional(const Optional &other) : m_Type(other.m_Type), m_Count(other.m_Count) {
if (isReference()) {
m_StoragePtr = new U(*other.m_StoragePtr);
} else if (isPointer()) {
m_StoragePtr = other.m_StoragePtr;
if (isOwned()) {
m_Count->increment();
}
}
}
Optional& operator=(const Optional& other) noexcept {
Optional tmp(other);
swap(std::move(tmp));
return *this;
}
Optional(Optional&& other) noexcept {
swap(std::move(other));
}
Optional& operator=(Optional&& other) noexcept {
swap(std::move(other));
return *this;
}
~Optional() {
if (isOwned()) {
if (isReference() || (isPointer() && m_Count->decrement() == 0)) {
delete m_StoragePtr;
delete m_Count;
}
}
}
/**
* Boolean value of Optional class is only true when there exists a value.
*/
operator bool() const noexcept { return isValid(); }
bool operator!() const noexcept { return !isValid(); }
/**
* Get reference of Optional object
* @warning User must validate Optional has value before.
*/
const T& operator*() { return this->GetReference(); }
/**
* Get reference of Optional object
* @warning User must validate Optional has value before.
*/
const T& operator*() const { return this->GetReference(); }
operator T&() { return this->GetReference(); }
T operator->() {
T self = this->GetReference();
return self;
}
private:
void swap(Optional&& other) {
m_Type = other.m_Type;
m_StoragePtr = other.m_StoragePtr;
m_Count = other.m_Count;
other.m_Type = LIFECYCLE::NONE;
other.m_StoragePtr = nullptr;
other.m_Count = nullptr;
}
template <typename Q = T>
typename std::enable_if<std::is_same<U, Q>::value, const Q&>::type GetReference() const noexcept {
if (!isReference()) std::terminate();
return *static_cast<const Q*>(m_StoragePtr);
}
template <typename Q = T>
typename std::enable_if<std::is_same<U*, Q>::value, const Q&>::type GetReference() const noexcept {
if (!isPointer()) std::terminate();
return static_cast<const Q&>(m_StoragePtr);
}
template <typename Q = T>
typename std::enable_if<std::is_same<U, Q>::value, Q&>::type GetReference() noexcept {
if (!isReference()) std::terminate();
return *m_StoragePtr;
}
template <typename Q = T>
typename std::enable_if<std::is_same<U*, Q>::value, Q&>::type GetReference() noexcept {
if (!isPointer()) std::terminate();
return m_StoragePtr;
}
bool isPointer() const {
return m_Type == LIFECYCLE::POINTER_OWNED || m_Type == LIFECYCLE::POINTER_NOT_OWNED;
}
bool isOwned() const {
return m_Type == LIFECYCLE::REFERENCE_OWNED || m_Type == LIFECYCLE::POINTER_OWNED;
}
bool isReference() const {
return m_Type == LIFECYCLE::REFERENCE_OWNED;
}
bool isValid() const {
return m_Type != LIFECYCLE::NONE;
}
U* m_StoragePtr = nullptr;
LIFECYCLE m_Type;
ReferenceCount *m_Count = nullptr;
};
} // ns DlSystem
} // ns zdl
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */
#endif // _DL_SYSTEM_OPTIONAL_HPP_

View File

@@ -1,78 +0,0 @@
//==============================================================================
//
// Copyright (c) 2014-2015 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//==============================================================================
#ifndef _DL_VERSION_HPP_
#define _DL_VERSION_HPP_
#include "ZdlExportDefine.hpp"
#include <stdint.h>
#include <string>
#include "DlSystem/String.hpp"
namespace zdl {
namespace DlSystem
{
class Version_t;
}}
namespace zdl { namespace DlSystem
{
/** @addtogroup c_plus_plus_apis C++
@{ */
/**
* A class that contains the different portions of a version number.
*/
class ZDL_EXPORT Version_t
{
public:
/// Holds the major version number. Changes in this value indicate
/// major changes that break backward compatibility.
int32_t Major;
/// Holds the minor version number. Changes in this value indicate
/// minor changes made to library that are backwards compatible
/// (such as additions to the interface).
int32_t Minor;
/// Holds the teeny version number. Changes in this value indicate
/// changes such as bug fixes and patches made to the library that
/// do not affect the interface.
int32_t Teeny;
/// This string holds information about the build version.
///
std::string Build;
static zdl::DlSystem::Version_t fromString(const std::string &stringValue);
static zdl::DlSystem::Version_t fromString(const zdl::DlSystem::String &stringValue);
/**
* @brief Returns a string in the form Major.Minor.Teeny.Build
*
* @return A formatted string holding the version information.
*/
const std::string toString() const;
/**
* @brief Returns a string in the form Major.Minor.Teeny.Build
*
* @return A formatted string holding the version information.
*/
const zdl::DlSystem::String asString() const;
};
}}
/** @} */ /* end_addtogroup c_plus_plus_apis */
#endif

View File

@@ -1,86 +0,0 @@
//==============================================================================
//
// Copyright (c) 2017-2019 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//==============================================================================
#ifndef _IBUFFER_ATTRIBUTES_HPP
#define _IBUFFER_ATTRIBUTES_HPP
#include "IUserBuffer.hpp"
#include "TensorShape.hpp"
#include "ZdlExportDefine.hpp"
namespace zdl {
namespace DlSystem {
class UserBufferEncoding;
}
}
namespace zdl {
namespace DlSystem {
/**
* @brief IBufferAttributes returns a buffer's dimension and alignment
* requirements, along with info on its encoding type
*/
class ZDL_EXPORT IBufferAttributes {
public:
/**
* @brief Gets the buffer's element size, in bytes
*
* This can be used to compute the memory size required
* to back this buffer.
*
* @return Element size, in bytes
*/
virtual size_t getElementSize() const noexcept = 0;
/**
* @brief Gets the element's encoding type
*
* @return encoding type
*/
virtual zdl::DlSystem::UserBufferEncoding::ElementType_t getEncodingType() const noexcept = 0;
/**
* @brief Gets the number of elements in each dimension
*
* @return Dimension size, in terms of number of elements
*/
virtual const TensorShape getDims() const noexcept = 0;
/**
* @brief Gets the alignment requirement of each dimension
*
* Alignment per each dimension is expressed as an multiple, for
* example, if one particular dimension can accept multiples of 8,
* the alignment will be 8.
*
* @return Alignment in each dimension, in terms of multiple of
* number of elements
*/
virtual const TensorShape getAlignments() const noexcept = 0;
/**
* @brief Gets the buffer encoding returned from the network responsible
* for generating this buffer. Depending on the encoding type, this will
* be an instance of an encoding type specific derived class.
*
* @return Derived user buffer encoding object.
*/
virtual zdl::DlSystem::UserBufferEncoding* getEncoding() const noexcept = 0;
virtual ~IBufferAttributes() {}
};
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */
}
}
#endif

View File

@@ -1,127 +0,0 @@
//=============================================================================
//
// Copyright (c) 2021-2022 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//=============================================================================
#ifndef DL_SYSTEM_IOBUFFER_DATATYPE_MAP_HPP
#define DL_SYSTEM_IOBUFFER_DATATYPE_MAP_HPP
#include <cstddef>
#include <memory>
#include "DlSystem/DlEnums.hpp"
namespace DlSystem
{
// Forward declaration of IOBufferDataTypeMapImpl implementation.
class IOBufferDataTypeMapImpl;
}
namespace zdl
{
namespace DlSystem
{
/** @addtogroup c_plus_plus_apis C++
@{ */
/**
* @brief .
*
* The IoBufferDataTypeMap class definition
*/
class ZDL_EXPORT IOBufferDataTypeMap final
{
public:
/**
* @brief .
*
* Creates a new Buffer Data type map
*
*/
IOBufferDataTypeMap();
/**
* @brief Adds a name and the corresponding buffer data type
* to the map
*
* @param[name] name The name of the buffer
* @param[bufferDataType] buffer Data Type of the buffer
*
* @note If a buffer with the same name already exists, no new
* buffer is added.
*/
void add(const char* name, zdl::DlSystem::IOBufferDataType_t bufferDataType);
/**
* @brief Removes a buffer name from the map
*
* @param[name] name The name of the buffer
*
*/
void remove(const char* name);
/**
* @brief Returns the type of the named buffer
*
* @param[name] name The name of the buffer
*
* @return The type of the buffer, or UNSPECIFIED if the buffer does not exist
*
*/
zdl::DlSystem::IOBufferDataType_t getBufferDataType(const char* name);
/**
* @brief Returns the type of the first buffer
*
* @return The type of the first buffer, or UNSPECIFIED if the map is empty.
*
*/
zdl::DlSystem::IOBufferDataType_t getBufferDataType();
/**
* @brief Returns the size of the buffer type map.
*
* @return The size of the map
*
*/
size_t size();
/**
* @brief Checks the existence of the named buffer in the map
*
* @return True if the named buffer exists, false otherwise.
*
*/
bool find(const char* name);
/**
* @brief Resets the map
*
*/
void clear();
/**
* @brief Checks whether the map is empty
*
* @return True if the map is empty, false otherwise.
*
*/
bool empty();
/**
* @brief Destroys the map
*
*/
~IOBufferDataTypeMap();
private:
std::shared_ptr<::DlSystem::IOBufferDataTypeMapImpl> m_IOBufferDataTypeMapImpl;
};
}
}
#endif

View File

@@ -1,146 +0,0 @@
//=============================================================================
//
// Copyright (c) 2015-2020 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//=============================================================================
#ifndef _ITENSOR_HPP_
#define _ITENSOR_HPP_
#include "ITensorItr.hpp"
#include "ITensorItrImpl.hpp"
#include "TensorShape.hpp"
#include "ZdlExportDefine.hpp"
#include <memory>
#include <ostream>
#include <cmath>
namespace zdl {
namespace DlSystem
{
class ITensor;
}}
namespace zdl { namespace DlSystem
{
/** @addtogroup c_plus_plus_apis C++
@{ */
/**
* Represents a tensor which holds n-dimensional data. It is important to
* understand how the tensor data is represented in memory
* relative to the tensor dimensions. Tensors store data in
* memory in row-major order (i.e. the last tensor dimension is
* the fastest varying one). For example, if you have a two
* dimensional tensor with 3 rows and 2 columns (i.e. the tensor
* dimensions are 3,2 as returned in tensor dimension vectors)
* with the following data in terms rows and columns:
*
* | 1 2 | <br/>
* | 3 4 | <br/>
* | 5 6 | <br/>
*
* This data would be stored in memory as 1,2,3,4,5,6.
*/
class ZDL_EXPORT ITensor
{
public:
typedef zdl::DlSystem::ITensorItr<false> iterator;
typedef zdl::DlSystem::ITensorItr<true> const_iterator;
virtual ~ITensor() {}
/**
* Returns a tensor iterator pointing to the beginning
* of the data in the tensor.
*
* @return A tensor iterator that points to the first data
* element in the tensor.
*/
virtual iterator begin() = 0;
/**
* Returns the const version of a tensor iterator
* pointing to the beginning of the data in the tensor.
*
* @return A tensor const iterator that points to the first data
* element in the tensor.
*/
virtual const_iterator cbegin() const = 0;
/**
* Returns a tensor iterator pointing to the end of the
* data in the tensor. This tensor should not be
* dereferenced.
*
* @return A tensor iterator that points to the end of the data
* (one past the last element) in the tensor.
*/
virtual iterator end() = 0;
/**
* Returns the const version of a tensor iterator
* pointing to the end of the data in the tensor. This
* tensor should not be dereferenced.
*
* @return A tensor const iterator that points to the end of the
* data (one past the last element) in the tensor.
*/
virtual const_iterator cend() const = 0;
/**
* @brief Gets the shape of this tensor.
*
* The last element of the vector represents the fastest varying
* dimension and the zeroth element represents the slowest
* varying dimension, etc.
*
* @return A shape class holding the tensor dimensions.
*/
virtual TensorShape getShape() const = 0;
/**
* Returns the element size of the data in the tensor
* (discounting strides). This is how big a buffer would
* need to be to hold the tensor data contiguously in
* memory.
*
* @return The size of the tensor (in elements).
*/
virtual size_t getSize() const = 0;
/**
* @brief Serializes the tensor to an output stream.
*
* @param[in] output The output stream to which to write the tensor
*
* @throw std::runtime_error If the stream is ever in a bad
* state before the tensor is fully serialized.
*/
virtual void serialize(std::ostream &output) const = 0;
friend iterator;
friend const_iterator;
virtual bool isQuantized() {return false;}
virtual float GetDelta() {return NAN;};
virtual float GetOffset() {return NAN;};
protected:
/**
* Returns the tensor iterator implementation.
*
* @return A pointer to the tensor iterator implementation.
*/
virtual std::unique_ptr<::DlSystem::ITensorItrImpl> getItrImpl() const = 0;
};
}}
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */
#endif

View File

@@ -1,92 +0,0 @@
//=============================================================================
//
// Copyright (c) 2015-2016 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//=============================================================================
#ifndef _ITENSOR_FACTORY_HPP
#define _ITENSOR_FACTORY_HPP
#include "ITensor.hpp"
#include "TensorShape.hpp"
#include "ZdlExportDefine.hpp"
#include <istream>
namespace zdl {
namespace DlSystem
{
class ITensor;
class TensorShape;
}
}
namespace zdl { namespace DlSystem
{
/** @addtogroup c_plus_plus_apis C++
@{ */
/**
* Factory interface class to create ITensor objects.
*/
class ZDL_EXPORT ITensorFactory
{
public:
virtual ~ITensorFactory() = default;
/**
* Creates a new ITensor with uninitialized data.
*
* The strides for the tensor will match the tensor dimensions
* (i.e., the tensor data is contiguous in memory).
*
* @param[in] shape The dimensions for the tensor in which the last
* element of the vector represents the fastest varying
* dimension and the zeroth element represents the slowest
* varying, etc.
*
* @return A pointer to the created tensor or nullptr if creating failed.
*/
virtual std::unique_ptr<ITensor>
createTensor(const TensorShape &shape) noexcept = 0;
/**
* Creates a new ITensor by loading it from a file.
*
* @param[in] input The input stream from which to read the tensor
* data.
*
* @return A pointer to the created tensor or nullptr if creating failed.
*
*/
virtual std::unique_ptr<ITensor> createTensor(std::istream &input) noexcept = 0;
/**
* Create a new ITensor with specific data.
* (i.e. the tensor data is contiguous in memory). This tensor is
* primarily used to create a tensor where tensor size can't be
* computed directly from dimension. One such example is
* NV21-formatted image, or any YUV formatted image
*
* @param[in] shape The dimensions for the tensor in which the last
* element of the vector represents the fastest varying
* dimension and the zeroth element represents the slowest
* varying, etc.
*
* @param[in] data The actual data with which the Tensor object is filled.
*
* @param[in] dataSize The size of data
*
* @return A pointer to the created tensor
*/
virtual std::unique_ptr<ITensor>
createTensor(const TensorShape &shape, const unsigned char *data, size_t dataSize) noexcept = 0;
};
}}
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */
#endif

View File

@@ -1,182 +0,0 @@
//=============================================================================
//
// Copyright (c) 2015 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//=============================================================================
#ifndef _ITENSOR_ITR_HPP_
#define _ITENSOR_ITR_HPP_
#include "ZdlExportDefine.hpp"
#include "ITensorItrImpl.hpp"
#include <memory>
#include <iterator>
#include <iostream>
namespace zdl {
namespace DlSystem
{
template<bool IS_CONST> class ITensorItr;
class ITensor;
void ZDL_EXPORT fill(ITensorItr<false> first, ITensorItr<false> end, float val);
template<class InItr, class OutItr> OutItr ZDL_EXPORT copy(InItr first, InItr last, OutItr result)
{
return std::copy(first, last, result);
}
}}
namespace DlSystem
{
class ITensorItrImpl;
}
namespace zdl { namespace DlSystem
{
/** @addtogroup c_plus_plus_apis C++
@{ */
/**
* A bidirectional iterator (with limited random access
* capabilities) for the zdl::DlSystem::ITensor class.
*
* This is a standard bidrectional iterator and is compatible
* with standard algorithm functions that operate on bidirectional
* access iterators (e.g., std::copy, std::fill, etc.). It uses a
* template parameter to create const and non-const iterators
* from the same code. Iterators are easiest to declare via the
* typedefs iterator and const_iterator in the ITensor class
* (e.g., zdl::DlSystem::ITensor::iterator).
*
* Note that if the tensor the iterator is traversing was
* created with nondefault (i.e., nontrivial) strides, the
* iterator will obey the strides when traversing the tensor
* data.
*
* Also note that nontrivial strides dramatically affect the
* performance of the iterator (on the order of 20x slower).
*/
template<bool IS_CONST=true>
class ZDL_EXPORT ITensorItr : public std::iterator<std::bidirectional_iterator_tag, float>
{
public:
typedef typename std::conditional<IS_CONST, const float&, float&>::type VALUE_REF;
ITensorItr() = delete;
virtual ~ITensorItr() {}
ITensorItr(std::unique_ptr<::DlSystem::ITensorItrImpl> impl,
bool isTrivial = false,
float* data = nullptr)
: m_Impl(impl->clone())
, m_IsTrivial(isTrivial)
, m_Data(data)
, m_DataStart(data) {}
ITensorItr(const ITensorItr<IS_CONST>& itr)
: m_Impl(itr.m_Impl->clone()),
m_IsTrivial(itr.m_IsTrivial),
m_Data(itr.m_Data),
m_DataStart(itr.m_DataStart) {}
zdl::DlSystem::ITensorItr<IS_CONST>& operator=(const ITensorItr<IS_CONST>& other)
{
if (this == &other) return *this;
m_Impl = std::move(other.m_Impl->clone());
m_IsTrivial = other.m_IsTrivial;
m_Data = other.m_Data;
m_DataStart = other.m_DataStart;
return *this;
}
inline zdl::DlSystem::ITensorItr<IS_CONST>& operator++()
{
if (m_IsTrivial) m_Data++; else m_Impl->increment();
return *this;
}
inline zdl::DlSystem::ITensorItr<IS_CONST> operator++(int)
{
ITensorItr tmp(*this);
operator++();
return tmp;
}
inline zdl::DlSystem::ITensorItr<IS_CONST>& operator--()
{
if (m_IsTrivial) m_Data--; else m_Impl->decrement();
return *this;
}
inline zdl::DlSystem::ITensorItr<IS_CONST> operator--(int)
{
ITensorItr tmp(*this);
operator--();
return tmp;
}
inline zdl::DlSystem::ITensorItr<IS_CONST>& operator+=(int rhs)
{
if (m_IsTrivial) m_Data += rhs; else m_Impl->increment(rhs);
return *this;
}
inline friend zdl::DlSystem::ITensorItr<IS_CONST> operator+(zdl::DlSystem::ITensorItr<IS_CONST> lhs, int rhs)
{ lhs += rhs; return lhs; }
inline zdl::DlSystem::ITensorItr<IS_CONST>& operator-=(int rhs)
{
if (m_IsTrivial) m_Data -= rhs; else m_Impl->decrement(rhs);
return *this;
}
inline friend zdl::DlSystem::ITensorItr<IS_CONST> operator-(zdl::DlSystem::ITensorItr<IS_CONST> lhs, int rhs)
{ lhs -= rhs; return lhs; }
inline size_t operator-(const zdl::DlSystem::ITensorItr<IS_CONST>& rhs)
{
if (m_IsTrivial) return (m_Data - m_DataStart) - (rhs.m_Data - rhs.m_DataStart);
return m_Impl->getPosition() - rhs.m_Impl->getPosition();
}
inline friend bool operator<(const ITensorItr<IS_CONST>& lhs, const ITensorItr<IS_CONST>& rhs)
{
if (lhs.m_IsTrivial) return lhs.m_Data < rhs.m_Data;
return lhs.m_Impl->dataPointer() < rhs.m_Impl->dataPointer();
}
inline friend bool operator>(const ITensorItr<IS_CONST>& lhs, const ITensorItr<IS_CONST>& rhs)
{ return rhs < lhs; }
inline friend bool operator<=(const ITensorItr<IS_CONST>& lhs, const ITensorItr<IS_CONST>& rhs)
{ return !(lhs > rhs); }
inline friend bool operator>=(const ITensorItr<IS_CONST>& lhs, const ITensorItr<IS_CONST>& rhs)
{ return !(lhs < rhs); }
inline bool operator==(const ITensorItr<IS_CONST>& rhs) const
{
if (m_IsTrivial) return m_Data == rhs.m_Data;
return m_Impl->dataPointer() == rhs.m_Impl->dataPointer();
}
inline bool operator!=(const ITensorItr<IS_CONST>& rhs) const
{ return !operator==(rhs); }
inline VALUE_REF operator[](size_t idx)
{
if (m_IsTrivial) return *(m_DataStart + idx);
return m_Impl->getReferenceAt(idx);
}
inline VALUE_REF operator*()
{ if (m_IsTrivial) return *m_Data; else return m_Impl->getReference(); }
inline VALUE_REF operator->()
{ return *(*this); }
inline float* dataPointer() const
{ if (m_IsTrivial) return m_Data; else return m_Impl->dataPointer(); }
protected:
std::unique_ptr<::DlSystem::ITensorItrImpl> m_Impl;
bool m_IsTrivial = false;
float* m_Data = nullptr;
float* m_DataStart = nullptr;
};
}}
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */
#endif

View File

@@ -1,42 +0,0 @@
//=============================================================================
//
// Copyright (c) 2015-2020 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//=============================================================================
#ifndef _ITENSOR_ITR_IMPL_HPP_
#define _ITENSOR_ITR_IMPL_HPP_
#include "ZdlExportDefine.hpp"
#include <memory>
#include <iterator>
namespace DlSystem
{
class ITensorItrImpl;
}
class ZDL_EXPORT DlSystem::ITensorItrImpl
{
public:
ITensorItrImpl() {}
virtual ~ITensorItrImpl() {}
virtual float getValue() const = 0;
virtual float& getReference() = 0;
virtual float& getReferenceAt(size_t idx) = 0;
virtual float* dataPointer() const = 0;
virtual void increment(int incVal = 1) = 0;
virtual void decrement(int decVal = 1) = 0;
virtual size_t getPosition() = 0;
virtual std::unique_ptr<DlSystem::ITensorItrImpl> clone() = 0;
private:
ITensorItrImpl& operator=(const ITensorItrImpl& other) = delete;
ITensorItrImpl(const ITensorItrImpl& other) = delete;
};
#endif

View File

@@ -1,105 +0,0 @@
//=============================================================================
//
// Copyright (c) 2016-2021 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//=============================================================================
#ifndef _DL_SYSTEM_IUDL_HPP_
#define _DL_SYSTEM_IUDL_HPP_
#include "ZdlExportDefine.hpp"
namespace zdl {
namespace DlSystem {
/**
* NOTE: DEPRECATED, MAY BE REMOVED IN THE FUTURE.
*
* @brief .
*
* Base class user concrete UDL implementation.
*
* All functions are marked as:
*
* - virtual
* - noexcept
*
* User should make sure no exceptions are propagated outside of
* their module. Errors can be communicated via return values.
*/
class ZDL_EXPORT IUDL {
public:
/**
* NOTE: DEPRECATED, MAY BE REMOVED IN THE FUTURE.
*
* @brief .
*
* Destructor
*/
virtual ~IUDL() = default;
/**
* NOTE: DEPRECATED, MAY BE REMOVED IN THE FUTURE.
*
* @brief Sets up the user's environment.
* This is called by the SNPE framework to allow the user the
* opportunity to setup anything which is needed for running
* user defined layers.
*
* @param cookie User provided opaque data returned by the SNPE
* runtime
*
* @param insz How many elements in input size array
* @param indim Pointer to a buffer that holds input dimension
* array
* @param indimsz Input dimension size array of the buffer
* 'indim'. Corresponds to indim
*
* @param outsz How many elements in output size array
* @param outdim Pointer to a buffer that holds output
* dimension array
* @param outdimsz Output dimension size of the buffer 'oudim'.
* Corresponds to indim
*
* @return true on success, false otherwise
*/
virtual bool setup(void *cookie,
size_t insz, const size_t **indim, const size_t *indimsz,
size_t outsz, const size_t **outdim, const size_t *outdimsz) = 0;
/**
* NOTE: DEPRECATED, MAY BE REMOVED IN THE FUTURE.
*
* @brief Close the instance. Invoked by the SNPE
* framework to allow the user the opportunity to release any resources
* allocated during setup.
*
* @param cookie - User provided opaque data returned by the SNPE runtime
*/
virtual void close(void *cookie) noexcept = 0;
/**
* NOTE: DEPRECATED, MAY BE REMOVED IN THE FUTURE.
*
* @brief Execute the user defined layer
*
* @param cookie User provided opaque data returned by the SNPE
* runtime
*
* @param input Const pointer to a float buffer that contains
* the input
*
* @param output Float pointer to a buffer that would hold
* the user defined layer's output. This buffer
* is allocated and owned by SNPE runtime.
*/
virtual bool execute(void *cookie, const float **input, float **output) = 0;
};
} // ns DlSystem
} // ns zdl
#endif // _DL_SYSTEM_IUDL_HPP_

View File

@@ -1,358 +0,0 @@
//==============================================================================
//
// Copyright (c) 2017-2020 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//==============================================================================
#ifndef _IUSER_BUFFER_HPP
#define _IUSER_BUFFER_HPP
#include "TensorShape.hpp"
#include "ZdlExportDefine.hpp"
#include <math.h>
namespace zdl {
namespace DlSystem {
/** @addtogroup c_plus_plus_apis C++
@{ */
/**
* @brief .
*
* A base class buffer encoding type
*/
class ZDL_EXPORT UserBufferEncoding {
public:
/**
* @brief .
*
* An enum class of all supported element types in a IUserBuffer
*/
enum class ElementType_t
{
/// Unknown element type.
UNKNOWN = 0,
/// Each element is presented by float.
FLOAT = 1,
/// Each element is presented by an unsigned int.
UNSIGNED8BIT = 2,
/// Each element is presented by an 8-bit quantized value.
TF8 = 10,
/// Each element is presented by an 16-bit quantized value.
TF16 = 11
};
/**
* @brief Retrieves the size of the element, in bytes.
*
* @return Size of the element, in bytes.
*/
virtual size_t getElementSize() const noexcept = 0;
/**
* @brief Retrieves the element type
*
* @return Element type
*/
ElementType_t getElementType() const noexcept {return m_ElementType;};
virtual ~UserBufferEncoding() {}
protected:
UserBufferEncoding(ElementType_t elementType) : m_ElementType(elementType) {};
private:
const ElementType_t m_ElementType;
};
/**
* @brief .
*
* A base class buffer source type
*
* @note User buffer from CPU support all kinds of runtimes;
* User buffer from GLBUFFER support only GPU runtime.
*/
class ZDL_EXPORT UserBufferSource {
public:
enum class SourceType_t
{
/// Unknown buffer source type.
UNKNOWN = 0,
/// The network inputs are from CPU buffer.
CPU = 1,
/// The network inputs are from OpenGL buffer.
GLBUFFER = 2
};
/**
* @brief Retrieves the source type
*
* @return Source type
*/
SourceType_t getSourceType() const noexcept {return m_SourceType;};
protected:
UserBufferSource(SourceType_t sourceType): m_SourceType(sourceType) {};
private:
const SourceType_t m_SourceType;
};
/**
* @brief .
*
* An source type where input data is delivered from OpenGL buffer
*/
class ZDL_EXPORT UserBufferSourceGLBuffer : public UserBufferSource{
public:
UserBufferSourceGLBuffer() : UserBufferSource(SourceType_t::GLBUFFER) {};
};
/**
* @brief .
*
* An encoding type where each element is represented by an unsigned int
*/
class ZDL_EXPORT UserBufferEncodingUnsigned8Bit : public UserBufferEncoding {
public:
UserBufferEncodingUnsigned8Bit() : UserBufferEncoding(ElementType_t::UNSIGNED8BIT) {};
size_t getElementSize() const noexcept override;
protected:
UserBufferEncodingUnsigned8Bit(ElementType_t elementType) : UserBufferEncoding(elementType) {};
};
/**
* @brief .
*
* An encoding type where each element is represented by a float
*/
class ZDL_EXPORT UserBufferEncodingFloat : public UserBufferEncoding {
public:
UserBufferEncodingFloat() : UserBufferEncoding(ElementType_t::FLOAT) {};
size_t getElementSize() const noexcept override;
};
/**
* @brief .
*
* An encoding type where each element is represented by tf8, which is an
* 8-bit quantizd value, which has an exact representation of 0.0
*/
class ZDL_EXPORT UserBufferEncodingTfN : public UserBufferEncoding {
public:
UserBufferEncodingTfN() = delete;
UserBufferEncodingTfN(uint64_t stepFor0, float stepSize, uint8_t bWidth=8):
UserBufferEncoding(getTypeFromWidth(bWidth)),
bitWidth(bWidth),
m_StepExactly0(stepFor0),
m_QuantizedStepSize(stepSize){};
UserBufferEncodingTfN(const zdl::DlSystem::UserBufferEncoding &ubEncoding) : UserBufferEncoding(ubEncoding.getElementType()){
const zdl::DlSystem::UserBufferEncodingTfN* ubEncodingTfN
= dynamic_cast <const zdl::DlSystem::UserBufferEncodingTfN*> (&ubEncoding);
if (ubEncodingTfN) {
m_StepExactly0 = ubEncodingTfN->getStepExactly0();
m_QuantizedStepSize = ubEncodingTfN->getQuantizedStepSize();
bitWidth = ubEncodingTfN->bitWidth;
}
}
size_t getElementSize() const noexcept override;
/**
* @brief Sets the step value that represents 0
*
* @param[in] stepExactly0 The step value that represents 0
*
*/
void setStepExactly0(uint64_t stepExactly0) {
m_StepExactly0 = stepExactly0;
}
/**
* @brief Sets the float value that each step represents
*
* @param[in] quantizedStepSize The float value of each step size
*
*/
void setQuantizedStepSize(const float quantizedStepSize) {
m_QuantizedStepSize = quantizedStepSize;
}
/**
* @brief Retrieves the step that represents 0.0
*
* @return Step value
*/
uint64_t getStepExactly0() const {
return m_StepExactly0;
}
/**
* Calculates the minimum floating point value that
* can be represented with this encoding.
*
* @return Minimum representable floating point value
*/
float getMin() const {
return static_cast<float>(m_QuantizedStepSize * (0 - (double)m_StepExactly0));
}
/**
* Calculates the maximum floating point value that
* can be represented with this encoding.
*
* @return Maximum representable floating point value
*/
float getMax() const{
return static_cast<float>(m_QuantizedStepSize * (pow(2,bitWidth)-1 - (double)m_StepExactly0));
};
/**
* @brief Retrieves the step size
*
* @return Step size
*/
float getQuantizedStepSize() const {
return m_QuantizedStepSize;
}
ElementType_t getTypeFromWidth(uint8_t width);
uint8_t bitWidth;
protected:
uint64_t m_StepExactly0;
float m_QuantizedStepSize;
};
class ZDL_EXPORT UserBufferEncodingTf8 : public UserBufferEncodingTfN {
public:
UserBufferEncodingTf8() = delete;
UserBufferEncodingTf8(unsigned char stepFor0, float stepSize) :
UserBufferEncodingTfN(stepFor0, stepSize) {};
UserBufferEncodingTf8(const zdl::DlSystem::UserBufferEncoding &ubEncoding) : UserBufferEncodingTfN(ubEncoding){}
/**
* @brief Sets the step value that represents 0
*
* @param[in] stepExactly0 The step value that represents 0
*
*/
void setStepExactly0(const unsigned char stepExactly0) {
UserBufferEncodingTfN::m_StepExactly0 = stepExactly0;
}
/**
* @brief Retrieves the step that represents 0.0
*
* @return Step value
*/
unsigned char getStepExactly0() const {
return UserBufferEncodingTfN::m_StepExactly0;
}
};
/**
* @brief UserBuffer contains a pointer and info on how to walk it and interpret its content.
*/
class ZDL_EXPORT IUserBuffer {
public:
virtual ~IUserBuffer() = default;
/**
* @brief Retrieves the total number of bytes between elements in each dimension if
* the buffer were to be interpreted as a multi-dimensional array.
*
* @return Number of bytes between elements in each dimension.
* e.g. A tightly packed tensor of floats with dimensions [4, 3, 2] would
* return strides of [24, 8, 4].
*/
virtual const TensorShape& getStrides() const = 0;
/**
* @brief Retrieves the size of the buffer, in bytes.
*
* @return Size of the underlying buffer, in bytes.
*/
virtual size_t getSize() const = 0;
/**
* @brief Retrieves the size of the inference data in the buffer, in bytes.
*
* The inference results from a dynamic-sized model may not be exactly the same size
* as the UserBuffer provided to SNPE. This function can be used to get the amount
* of output inference data, which may be less or greater than the size of the UserBuffer.
*
* If the inference results fit in the UserBuffer, getOutputSize() would be less than
* or equal to getSize(). But if the inference results were more than the capacity of
* the provided UserBuffer, the results would be truncated to fit the UserBuffer. But,
* getOutputSize() would be greater than getSize(), which indicates a bigger buffer
* needs to be provided to SNPE to hold all of the inference results.
*
* @return Size required for the buffer to hold all inference results, which can be less
* or more than the size of the buffer, in bytes.
*/
virtual size_t getOutputSize() const = 0;
/**
* @brief Changes the underlying memory that backs the UserBuffer.
*
* This can be used to avoid creating multiple UserBuffer objects
* when the only thing that differs is the memory location.
*
* @param[in] buffer Pointer to the memory location
*
* @return Whether the set succeeds.
*/
virtual bool setBufferAddress(void *buffer) noexcept = 0;
/**
* @brief Gets a const reference to the data encoding object of
* the underlying buffer
*
* This is necessary when the UserBuffer is filled by SNPE with
* data types such as TF8, where the caller needs to know the quantization
* parameters in order to interpret the data properly
*
* @return A read-only encoding object
*/
virtual const UserBufferEncoding& getEncoding() const noexcept = 0;
/**
* @brief Gets a reference to the data encoding object of
* the underlying buffer
*
* This is necessary when the UserBuffer is re-used, and the encoding
* parameters can change. For example, each input can be quantized with
* different step sizes.
*
* @return Data encoding meta-data
*/
virtual UserBufferEncoding& getEncoding() noexcept = 0;
};
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */
}
}
#endif

View File

@@ -1,81 +0,0 @@
//=============================================================================
//
// Copyright (c) 2017 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//=============================================================================
#ifndef _IUSERBUFFER_FACTORY_HPP
#define _IUSERBUFFER_FACTORY_HPP
#include "IUserBuffer.hpp"
#include "TensorShape.hpp"
#include "ZdlExportDefine.hpp"
#include "DlEnums.hpp"
namespace zdl {
namespace DlSystem {
class IUserBuffer;
class TensorShape;
}
}
namespace zdl {
namespace DlSystem {
/** @addtogroup c_plus_plus_apis C++
@{ */
/**
* Factory interface class to create IUserBuffer objects.
*/
class ZDL_EXPORT IUserBufferFactory {
public:
virtual ~IUserBufferFactory() = default;
/**
* @brief Creates a UserBuffer
*
* @param[in] buffer Pointer to the buffer that the caller supplies
*
* @param[in] bufSize Buffer size, in bytes
*
* @param[in] strides Total number of bytes between elements in each dimension.
* E.g. A tightly packed tensor of floats with dimensions [4, 3, 2] would have strides of [24, 8, 4].
*
* @param[in] userBufferEncoding Reference to an UserBufferEncoding object
*
* @note Caller has to ensure that memory pointed to by buffer stays accessible
* for the lifetime of the object created
*/
virtual std::unique_ptr<IUserBuffer>
createUserBuffer(void *buffer, size_t bufSize, const zdl::DlSystem::TensorShape &strides, zdl::DlSystem::UserBufferEncoding* userBufferEncoding) noexcept = 0;
/**
* @brief Creates a UserBuffer
*
* @param[in] buffer Pointer to the buffer that the caller supplies
*
* @param[in] bufSize Buffer size, in bytes
*
* @param[in] strides Total number of bytes between elements in each dimension.
* E.g. A tightly packed tensor of floats with dimensions [4, 3, 2] would have strides of [24, 8, 4].
*
* @param[in] userBufferEncoding Reference to an UserBufferEncoding object
*
* @param[in] userBufferSource Reference to an UserBufferSource object
*
* @note Caller has to ensure that memory pointed to by buffer stays accessible
* for the lifetime of the object created
*/
virtual std::unique_ptr<IUserBuffer>
createUserBuffer(void *buffer, size_t bufSize, const zdl::DlSystem::TensorShape &strides, zdl::DlSystem::UserBufferEncoding* userBufferEncoding, zdl::DlSystem::UserBufferSource* userBufferSource) noexcept = 0;
};
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */
}
}
#endif

View File

@@ -1,230 +0,0 @@
//=============================================================================
//
// Copyright (c) 2017-2018,2021 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//=============================================================================
#ifndef _DL_SYSTEM_PLATFORM_CONFIG_HPP_
#define _DL_SYSTEM_PLATFORM_CONFIG_HPP_
#include "DlSystem/ZdlExportDefine.hpp"
#include <string>
namespace zdl{
namespace DlSystem
{
/** @addtogroup c_plus_plus_apis C++
@{ */
/**
* @brief .
*
* A structure OpenGL configuration
*
* @note When certain OpenGL context and display are provided to UserGLConfig for using
* GPU buffer as input directly, the user MUST ensure the particular OpenGL
* context and display remain vaild throughout the execution of neural network models.
*/
struct ZDL_EXPORT UserGLConfig
{
/// Holds user EGL context.
///
void* userGLContext = nullptr;
/// Holds user EGL display.
void* userGLDisplay = nullptr;
};
/**
* @brief .
*
* A structure Gpu configuration
*/
struct ZDL_EXPORT UserGpuConfig{
/// Holds user OpenGL configuration.
///
UserGLConfig userGLConfig;
};
/**
* @brief .
*
* A class user platform configuration
*/
class ZDL_EXPORT PlatformConfig
{
public:
/**
* @brief .
*
* An enum class of all supported platform types
*/
enum class PlatformType_t
{
/// Unknown platform type.
UNKNOWN = 0,
/// Snapdragon CPU.
CPU = 1,
/// Adreno GPU.
GPU = 2,
/// Hexagon DSP.
DSP = 3
};
/**
* @brief .
*
* A union class user platform configuration information
*/
union PlatformConfigInfo
{
/// Holds user GPU Configuration.
///
UserGpuConfig userGpuConfig;
PlatformConfigInfo(){};
};
PlatformConfig() : m_PlatformType(PlatformType_t::UNKNOWN),
m_PlatformOptions("") {};
/**
* @brief Retrieves the platform type
*
* @return Platform type
*/
PlatformType_t getPlatformType() const {return m_PlatformType;};
/**
* @brief Indicates whther the plaform configuration is valid.
*
* @return True if the platform configuration is valid; false otherwise.
*/
bool isValid() const {return (PlatformType_t::UNKNOWN != m_PlatformType);};
/**
* @brief Retrieves the Gpu configuration
*
* @param[out] userGpuConfig The passed in userGpuConfig populated with the Gpu configuration on return.
*
* @return True if Gpu configuration was retrieved; false otherwise.
*/
bool getUserGpuConfig(UserGpuConfig& userGpuConfig) const
{
if(m_PlatformType == PlatformType_t::GPU)
{
userGpuConfig = m_PlatformConfigInfo.userGpuConfig;
return true;
}
else
{
return false;
}
}
/**
* @brief Sets the Gpu configuration
*
* @param[in] userGpuConfig Gpu Configuration
*
* @return True if Gpu configuration was successfully set; false otherwise.
*/
bool setUserGpuConfig(UserGpuConfig& userGpuConfig)
{
if((userGpuConfig.userGLConfig.userGLContext != nullptr) && (userGpuConfig.userGLConfig.userGLDisplay != nullptr))
{
switch (m_PlatformType)
{
case PlatformType_t::GPU:
m_PlatformConfigInfo.userGpuConfig = userGpuConfig;
return true;
case PlatformType_t::UNKNOWN:
m_PlatformType = PlatformType_t::GPU;
m_PlatformConfigInfo.userGpuConfig = userGpuConfig;
return true;
default:
return false;
}
}
else
return false;
}
/**
* @brief Sets the platform options
*
* @param[in] options Options as a string in the form of "keyword:options"
*
* @return True if options are pass validation; otherwise false. If false, the options are not updated.
*/
bool setPlatformOptions(std::string options) {
std::string oldOptions = m_PlatformOptions;
m_PlatformOptions = options;
if (isOptionsValid()) {
return true;
} else {
m_PlatformOptions = oldOptions;
return false;
}
}
/**
* @brief Indicates whther the plaform configuration is valid.
*
* @return True if the platform configuration is valid; false otherwise.
*/
bool isOptionsValid() const;
/**
* @brief Gets the platform options
*
* @return Options as a string
*/
std::string getPlatformOptions() const { return m_PlatformOptions; }
/**
* @brief Sets the platform options
*
* @param[in] optionName Name of platform options"
* @param[in] value Value of specified optionName
*
* @return If true, add "optionName:value" to platform options if optionName don't exist, otherwise update the
* value of specified optionName.
* If false, the platform options will not be changed.
*/
bool setPlatformOptionValue(const std::string& optionName, const std::string& value);
/**
* @brief Removes the platform options
*
* @param[in] optionName Name of platform options"
* @param[in] value Value of specified optionName
*
* @return If true, removed "optionName:value" to platform options if optionName don't exist, do nothing.
* If false, the platform options will not be changed.
*/
bool removePlatformOptionValue(const std::string& optionName, const std::string& value);
static void SetIsUserGLBuffer(bool isUserGLBuffer);
static bool GetIsUserGLBuffer();
private:
PlatformType_t m_PlatformType;
PlatformConfigInfo m_PlatformConfigInfo;
std::string m_PlatformOptions;
static bool m_IsUserGLBuffer;
};
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */
}} //namespace end
#endif

View File

@@ -1,154 +0,0 @@
//=============================================================================
//
// Copyright (c) 2019 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//=============================================================================
#include "ZdlExportDefine.hpp"
#include "DlSystem/DlEnums.hpp"
#include "DlSystem/StringList.hpp"
#include <cstddef>
#include <memory>
#ifndef DL_SYSTEM_RUNTIME_LIST_HPP
#define DL_SYSTEM_RUNTIME_LIST_HPP
namespace DlSystem
{
// Forward declaration of Runtime List implementation.
class RuntimeListImpl;
}
namespace zdl
{
namespace DlSystem
{
/** @addtogroup c_plus_plus_apis C++
@{ */
/**
* @brief .
*
* A class representing list of runtimes
*/
class ZDL_EXPORT RuntimeList final
{
public:
/**
* @brief .
*
* Creates a new runtime list
*
*/
RuntimeList();
/**
* @brief .
*
* copy constructor.
* @param[in] other object to copy.
*/
RuntimeList(const RuntimeList& other);
/**
* @brief .
*
* constructor with single Runtime_t object
* @param[in] Runtime_t object
*/
RuntimeList(const zdl::DlSystem::Runtime_t& runtime);
/**
* @brief .
*
* assignment operator.
*/
RuntimeList& operator=(const RuntimeList& other);
/**
* @brief .
*
* subscript operator.
*/
Runtime_t& operator[](size_t index);
/**
* @brief Adds runtime to the end of the runtime list
* order of precedence is former followed by latter entry
*
* @param[in] runtime to add
*
* Ruturns false If the runtime already exists
*/
bool add(const zdl::DlSystem::Runtime_t& runtime);
/**
* @brief Removes the runtime from the list
*
* @param[in] runtime to be removed
*
* @note If the runtime is not found, nothing is done.
*/
void remove(const zdl::DlSystem::Runtime_t runtime) noexcept;
/**
* @brief Returns the number of runtimes in the list
*/
size_t size() const noexcept;
/**
* @brief Returns true if the list is empty
*/
bool empty() const noexcept;
/**
* @brief .
*
* Removes all runtime from the list
*/
void clear() noexcept;
/**
* @brief .
*
* Returns a StringList of names from the runtime list in
* order of precedence
*/
zdl::DlSystem::StringList getRuntimeListNames() const;
/**
* @brief .
*
* @param[in] runtime string
* Returns a Runtime enum corresponding to the in param string
*
*/
static zdl::DlSystem::Runtime_t stringToRuntime(const char* runtimeStr);
/**
* @brief .
*
* @param[in] runtime
* Returns a string corresponding to the in param runtime enum
*
*/
static const char* runtimeToString(const zdl::DlSystem::Runtime_t runtime);
~RuntimeList();
private:
void deepCopy(const RuntimeList &other);
std::unique_ptr<::DlSystem::RuntimeListImpl> m_RuntimeListImpl;
};
} // DlSystem namespace
} // zdl namespace
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */
#endif // DL_SYSTEM_RUNTIME_LIST_HPP

View File

@@ -1,104 +0,0 @@
//=============================================================================
//
// Copyright (c) 2017, 2020 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//=============================================================================
#ifndef PLATFORM_STANDARD_STRING_HPP
#define PLATFORM_STANDARD_STRING_HPP
#include <cstdio>
#include <string>
#include <ostream>
#include "DlSystem/ZdlExportDefine.hpp"
namespace zdl
{
namespace DlSystem
{
/** @addtogroup c_plus_plus_apis C++
@{ */
/**
* @brief .
*
* Class for wrapping char * as a really stripped down std::string replacement.
*/
class ZDL_EXPORT String final
{
public:
String() = delete;
/**
* Construct a string from std::string reference.
* @param str Reference to a std::string
*/
explicit String(const std::string& str);
/**
* Construct a string from char* reference.
* @param a char*
*/
explicit String(const char* str);
/**
* move constructor.
*/
String(String&& other) noexcept;
/**
* copy constructor.
*/
String(const String& other) = delete;
/**
* assignment operator.
*/
String& operator=(const String&) = delete;
/**
* move assignment operator.
*/
String& operator=(String&&) = delete;
/**
* class comparators
*/
bool operator<(const String& rhs) const noexcept;
bool operator>(const String& rhs) const noexcept;
bool operator<=(const String& rhs) const noexcept;
bool operator>=(const String& rhs) const noexcept;
bool operator==(const String& rhs) const noexcept;
bool operator!=(const String& rhs) const noexcept;
/**
* class comparators against std::string
*/
bool operator<(const std::string& rhs) const noexcept;
bool operator>(const std::string& rhs) const noexcept;
bool operator<=(const std::string& rhs) const noexcept;
bool operator>=(const std::string& rhs) const noexcept;
bool operator==(const std::string& rhs) const noexcept;
bool operator!=(const std::string& rhs) const noexcept;
const char* c_str() const noexcept;
~String();
private:
char* m_string;
};
/**
* overloaded << operator
*/
ZDL_EXPORT std::ostream& operator<<(std::ostream& os, const String& str) noexcept;
} // DlSystem namespace
} // zdl namespace
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */
#endif // PLATFORM_STANDARD_STRING_HPP

View File

@@ -1,107 +0,0 @@
//=============================================================================
//
// Copyright (c) 2016 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//=============================================================================
#include <cstdio>
#include "ZdlExportDefine.hpp"
#ifndef DL_SYSTEM_STRINGLIST_HPP
#define DL_SYSTEM_STRINGLIST_HPP
namespace zdl
{
namespace DlSystem
{
/** @addtogroup c_plus_plus_apis C++
@{ */
/**
* @brief .
*
* Class for holding an order list of null-terminated ASCII strings.
*/
class ZDL_EXPORT StringList final
{
public:
StringList() {}
/**
* Construct a string list with some pre-allocated memory.
* @warning Contents of the list will be uninitialized
* @param[in] length Number of elements for which to pre-allocate space.
*/
explicit StringList(size_t length);
/**
* Append a string to the list.
* @param[in] str Null-terminated ASCII string to append to the list.
*/
void append(const char* str);
/**
* Returns the string at the indicated position,
* or an empty string if the positions is greater than the size
* of the list.
* @param[in] idx Position in the list of the desired string
*/
const char* at(size_t idx) const noexcept;
/**
* Pointer to the first string in the list.
* Can be used to iterate through the list.
*/
const char** begin() const noexcept;
/**
* Pointer to one after the last string in the list.
* Can be used to iterate through the list.
*/
const char** end() const noexcept;
/**
* Return the number of valid string pointers held by this list.
*/
size_t size() const noexcept;
/**
* assignment operator.
*/
StringList& operator=(const StringList&) noexcept;
/**
* copy constructor.
* @param[in] other object to copy.
*/
StringList(const StringList& other);
/**
* move constructor.
* @param[in] other object to move.
*/
StringList(StringList&& other) noexcept;
~StringList();
private:
void copy(const StringList& other);
void resize(size_t length);
void clear();
static const char* s_Empty;
const char** m_Strings = nullptr;
const char** m_End = nullptr;
size_t m_Size = 0;
};
} // DlSystem namespace
} // zdl namespace
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */
#endif // DL_SYSTEM_STRINGLIST_HPP

View File

@@ -1,120 +0,0 @@
//=============================================================================
//
// Copyright (c) 2016 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//=============================================================================
#include <memory>
#include "ZdlExportDefine.hpp"
#include "ITensor.hpp"
#include "StringList.hpp"
#ifndef DL_SYSTEM_TENSOR_MAP_HPP
#define DL_SYSTEM_TENSOR_MAP_HPP
namespace DlSystem
{
// Forward declaration of tensor map implementation.
class TensorMapImpl;
}
namespace zdl
{
namespace DlSystem
{
/** @addtogroup c_plus_plus_apis C++
@{ */
/**
* @brief .
*
* A class representing the map of tensor.
*/
class ZDL_EXPORT TensorMap final
{
public:
/**
* @brief .
*
* Creates a new empty tensor map
*/
TensorMap();
/**
* copy constructor.
* @param[in] other object to copy.
*/
TensorMap(const TensorMap& other);
/**
* assignment operator.
*/
TensorMap& operator=(const TensorMap& other);
/**
* @brief Adds a name and the corresponding tensor pointer
* to the map
*
* @param[in] name The name of the tensor
* @param[out] tensor The pointer to the tensor
*
* @note If a tensor with the same name already exists, the
* tensor is replaced with the existing tensor.
*/
void add(const char *name, zdl::DlSystem::ITensor *tensor);
/**
* @brief Removes a mapping of tensor and its name by its name
*
* @param[in] name The name of tensor to be removed
*
* @note If no tensor with the specified name is found, nothing
* is done.
*/
void remove(const char *name) noexcept;
/**
* @brief Returns the number of tensors in the map
*/
size_t size() const noexcept;
/**
* @brief .
*
* Removes all tensors from the map
*/
void clear() noexcept;
/**
* @brief Returns the tensor given its name.
*
* @param[in] name The name of the tensor to get.
*
* @return nullptr if no tensor with the specified name is
* found; otherwise, a valid pointer to the tensor.
*/
zdl::DlSystem::ITensor* getTensor(const char *name) const noexcept;
/**
* @brief .
*
* Returns the names of all tensors
*/
zdl::DlSystem::StringList getTensorNames() const;
~TensorMap();
private:
void swap(const TensorMap &other);
std::unique_ptr<::DlSystem::TensorMapImpl> m_TensorMapImpl;
};
} // DlSystem namespace
} // zdl namespace
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */
#endif // DL_SYSTEM_TENSOR_MAP_HPP

View File

@@ -1,203 +0,0 @@
//=============================================================================
//
// Copyright (c) 2016 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//=============================================================================
#include <initializer_list>
#include <cstdio>
#include <memory>
#include <vector>
#include "ZdlExportDefine.hpp"
#ifndef DL_SYSTEM_TENSOR_SHAPE_HPP
#define DL_SYSTEM_TENSOR_SHAPE_HPP
namespace DlSystem
{
// Forward declaration of tensor shape implementation.
class TensorShapeImpl;
}
namespace zdl
{
namespace DlSystem
{
/** @addtogroup c_plus_plus_apis C++
@{ */
/**
* @brief .
*
* Convenient typedef to represent dimension
*/
using Dimension = size_t;
/**
* @brief .
*
* A class representing the shape of tensor. It is used at the
* time of creation of tensor.
*/
class ZDL_EXPORT TensorShape final
{
public:
/**
* @brief .
*
* Creates a new shape with a list of dims specified in
* initializer list fashion.
*
* @param[in] dims The dimensions are specified in which the last
* element of the vector represents the fastest varying
* dimension and the zeroth element represents the slowest
* varying, etc.
*
*/
TensorShape(std::initializer_list<Dimension> dims);
/**
* @brief .
*
* Creates a new shape with a list of dims specified in array
*
* @param[in] dims The dimensions are specified in which the last
* element of the vector represents the fastest varying
* dimension and the zeroth element represents the slowest
* varying, etc.
*
* @param[in] size Size of the array.
*
*/
TensorShape(const Dimension *dims, size_t size);
/**
* @brief .
*
* Creates a new shape with a vector of dims specified in
* vector fashion.
*
* @param[in] dims The dimensions are specified in which the last
* element of the vector represents the fastest varying
* dimension and the zeroth element represents the slowest
* varying, etc.
*
*/
TensorShape(std::vector<Dimension> dims);
/**
* @brief .
*
* copy constructor.
* @param[in] other object to copy.
*/
TensorShape(const TensorShape& other);
/**
* @brief .
*
* assignment operator.
*/
TensorShape& operator=(const TensorShape& other);
/**
* @brief .
*
* Creates a new shape with no dims. It can be extended later
* by invoking concatenate.
*/
TensorShape();
/**
* @brief .
*
* Concatenates additional dimensions specified in
* initializer list fashion to the existing dimensions.
*
* @param[in] dims The dimensions are specified in which the last
* element of the vector represents the fastest varying
* dimension and the zeroth element represents the slowest
* varying, etc.
*
*/
void concatenate(std::initializer_list<Dimension> dims);
/**
* @brief .
*
* Concatenates additional dimensions specified in
* the array to the existing dimensions.
*
* @param[in] dims The dimensions are specified in which the last
* element of the vector represents the fastest varying
* dimension and the zeroth element represents the slowest
* varying, etc.
*
* @param[in] size Size of the array.
*
*/
void concatenate(const Dimension *dims, size_t size);
/**
* @brief .
*
* Concatenates an additional dimension to the existing
* dimensions.
*
* @param[in] dim The dimensions are specified in which the last element
* of the vector represents the fastest varying dimension and the
* zeroth element represents the slowest varying, etc.
*
*/
void concatenate(const Dimension &dim);
/**
* @brief .
*
* Retrieves a single dimension, based on its index.
*
* @return The value of dimension
*
* @throws std::out_of_range if the index is >= the number of
* dimensions (or rank).
*/
Dimension& operator[](size_t index);
Dimension& operator[](size_t index) const;
/**
* @brief .
*
* Retrieves the rank i.e. number of dimensions.
*
* @return The rank
*/
size_t rank() const;
/**
* @brief .
*
* Retrieves a pointer to the first dimension of shape
*
* @return nullptr if no dimension exists; otherwise, points to
* the first dimension.
*
*/
const Dimension* getDimensions() const;
~TensorShape();
private:
void swap(const TensorShape &other);
std::unique_ptr<::DlSystem::TensorShapeImpl> m_TensorShapeImpl;
};
} // DlSystem namespace
} // zdl namespace
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */
#endif // DL_SYSTEM_TENSOR_SHAPE_HPP

View File

@@ -1,127 +0,0 @@
//=============================================================================
//
// Copyright (c) 2017-2020 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//=============================================================================
#include <initializer_list>
#include <cstdio>
#include <memory>
#include "ZdlExportDefine.hpp"
#include "DlSystem/TensorShape.hpp"
#include "DlSystem/StringList.hpp"
#ifndef DL_SYSTEM_TENSOR_SHAPE_MAP_HPP
#define DL_SYSTEM_TENSOR_SHAPE_MAP_HPP
namespace DlSystem
{
// Forward declaration of tensor shape map implementation.
class TensorShapeMapImpl;
}
namespace zdl
{
namespace DlSystem
{
/** @addtogroup c_plus_plus_apis C++
@{ */
/**
* @brief .
*
* A class representing the map of names and tensorshapes.
*/
class ZDL_EXPORT TensorShapeMap final
{
public:
/**
* @brief .
*
* Creates a new tensor shape map
*
*/
TensorShapeMap();
/**
* @brief .
*
* copy constructor.
* @param[in] other object to copy.
*/
TensorShapeMap(const TensorShapeMap& other);
/**
* @brief .
*
* assignment operator.
*/
TensorShapeMap& operator=(const TensorShapeMap& other);
/**
* @brief Adds a name and the corresponding tensor pointer
* to the map
*
* @param[in] name The name of the tensor
* @param[out] tensor The pointer to the tensor
*
* @note If a tensor with the same name already exists, no new
* tensor is added.
*/
void add(const char *name, const zdl::DlSystem::TensorShape& tensorShape);
/**
* @brief Removes a mapping of tensor and its name by its name
*
* @param[in] name The name of tensor to be removed
*
* @note If no tensor with the specified name is found, nothing
* is done.
*/
void remove(const char *name) noexcept;
/**
* @brief Returns the number of tensors in the map
*/
size_t size() const noexcept;
/**
* @brief .
*
* Removes all tensors from the map
*/
void clear() noexcept;
/**
* @brief Returns the tensor given its name.
*
* @param[in] name The name of the tensor to get.
*
* @return nullptr if no tensor with the specified name is
* found; otherwise, a valid pointer to the tensor.
*/
zdl::DlSystem::TensorShape getTensorShape(const char *name) const noexcept;
/**
* @brief .
*
* Returns the names of all tensor shapes
*/
zdl::DlSystem::StringList getTensorShapeNames() const;
~TensorShapeMap();
private:
void swap(const TensorShapeMap &other);
std::unique_ptr<::DlSystem::TensorShapeMapImpl> m_TensorShapeMapImpl;
};
} // DlSystem namespace
} // zdl namespace
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */
#endif // DL_SYSTEM_TENSOR_SHAPE_MAP_HPP

View File

@@ -1,243 +0,0 @@
//==============================================================================
//
// Copyright (c) 2016-2021 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//==============================================================================
#ifndef UDL_CONTEXT_HPP
#define UDL_CONTEXT_HPP
#include <cstring> // memset
#include <tuple>
#include "ZdlExportDefine.hpp"
namespace zdl { namespace DlSystem {
/**
* NOTE: DEPRECATED, MAY BE REMOVED IN THE FUTURE.
*
* @brief .
*
* UDLContext holds the user defined layer context which
* consists of a layer name, layer ID, blob and blob size.
*
* An instance of UDLContext is passed as an argument to the
* UDLFactoryFunc provided by the user every time the SNPE
* runtime encounters an unknown layer descriptor. The instance
* of a UDLContext is created by the SNPE runtime and is
* consumed by the user's factory function. The user should
* obtain a copy of this class and should not assume any
* prolonged object lifetime beyond the UDLFactoryFunction.
*/
class ZDL_EXPORT UDLContext final {
public:
/**
* @brief Constructor
*
* @param[in] name name of the layer
*
* @param[in] type layer type
*
* @param[in] id identifier for the layer
*
* @param[in] id Blob/bytes as packed by the user code as part of
* the Python converter script
*/
UDLContext(const std::string& name,
const std::string& type,
int32_t id,
const std::string& blob) :
m_Name(name), m_Type(type), m_Size(blob.size()), m_Id(id) {
// FIXME not dealing with alloc error
m_Buffer = new uint8_t[m_Size];
std::memcpy(m_Buffer, blob.data(), m_Size);
}
/**
* @brief .
*
* Empty constructor is useful for
* creating an empty UDLContext and then run copy constructor
* from a fully initialized one.
*/
explicit UDLContext() {}
/**
* @brief .
*
* destructor Deallocates any internal allocated memory
*/
~UDLContext() { release(); }
/**
* @brief .
*
* Deallocate any internally allocated memory
*/
void release() {
if (m_Buffer && m_Size)
std::memset(m_Buffer, 0, m_Size);
delete []m_Buffer;
m_Buffer = nullptr;
m_Size = 0;
}
/**
* @brief .
*
* Copy Constructor - makes a copy from ctx
*
* @param[in] ctx Source UDLContext to copy from
*/
UDLContext(const UDLContext& ctx) : m_Name(ctx.m_Name),
m_Type(ctx.m_Type),
m_Id(ctx.m_Id) {
std::tuple<uint8_t*, size_t> cpy = ctx.getCopy();
// current compiler does not support get<type>
m_Buffer = std::get<0>(cpy);
m_Size = std::get<1>(cpy);
}
/**
* @brief
*
* Assignment operator - makes a copy from ctx
*
* @param[in] ctx Source UDLContext to copy from
*
* @return this
*/
UDLContext& operator=(const UDLContext& ctx) {
UDLContext c (ctx);
this->swap(c); // non throwing swap
return *this;
}
/**
* @brief .
*
* Move Constructor - Move internals from ctx into this
*
* @param[in] ctx Source UDLContext to move from
*/
UDLContext(UDLContext&& ctx) :
m_Name(std::move(ctx.m_Name)),
m_Type(std::move(ctx.m_Type)),
m_Buffer(ctx.m_Buffer),
m_Size(ctx.m_Size),
m_Id(ctx.m_Id) {
ctx.clear();
}
/**
* @brief .
*
* Assignment move - Move assignment operator from ctx
*
* @param[in] ctx Source UDLContext to move from
*
* @return this
*/
UDLContext& operator=(UDLContext&& ctx) {
m_Name = std::move(ctx.m_Name);
m_Type = std::move(ctx.m_Type);
m_Buffer = ctx.m_Buffer;
m_Size = ctx.m_Size;
m_Id = ctx.m_Id;
ctx.clear();
return *this;
}
/**
* @brief .
*
* Obtain the name of the layer
*
* @return const reference to the name of the layer
*/
const std::string& getName() const noexcept { return m_Name; }
/**
* @brief .
*
* Obtain the type of the layer
*
* @return const reference to the type of the layer
*/
const std::string& getType() const noexcept { return m_Type; }
/**
* @brief .
*
* Obtain the Id of the layer
*
* @return The id of the layer
*/
int32_t getId() const noexcept { return m_Id; }
/**
* @brief .
*
* Obtain the size of the blob
*
* @return Size of the internal blob
*/
size_t getSize() const noexcept { return m_Size; }
/**
* @brief .
*
* Get a const pointer to the internal blob
*
* @return Const pointer to the internal blob
*/
const uint8_t* getBlob() const noexcept { return m_Buffer; }
/**
* @brief .
*
* Get a copy of the blob/size into a tuple
*
* @return A tuple with a pointer to a copy of the blob and a
* size
*/
std::tuple<uint8_t*, size_t> getCopy() const {
uint8_t* buf = new uint8_t[m_Size];
// FIXME missing memcpy
std::memcpy(buf, m_Buffer, m_Size);
return std::make_tuple(buf, m_Size);
}
/**
* @brief .
*
* Set zeros in the internals members
*/
void clear() {
m_Name.clear();
m_Type.clear();
m_Buffer = 0;
m_Size = 0;
m_Id = -1;
}
private:
void swap(UDLContext& c) noexcept {
std::swap(m_Name, c.m_Name);
std::swap(m_Type, c.m_Type);
std::swap(m_Id, c.m_Id);
std::swap(m_Buffer, c.m_Buffer);
std::swap(m_Size, c.m_Size);
}
std::string m_Name; // name of the layer instance
std::string m_Type; // The actual layer type
uint8_t* m_Buffer = nullptr;
size_t m_Size = 0;
int32_t m_Id = -1;
};
}}
#endif /* UDL_CONTEXT_HPP */

View File

@@ -1,87 +0,0 @@
//==============================================================================
//
// Copyright (c) 2015-2021 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//==============================================================================
#ifndef _UDL_FUNC_HPP_
#define _UDL_FUNC_HPP_
#include <functional>
#include "ZdlExportDefine.hpp"
#include <DlSystem/IUDL.hpp>
namespace zdl {
namespace DlSystem {
class UDLContext;
}
}
namespace zdl { namespace DlSystem {
/**
* NOTE: DEPRECATED, MAY BE REMOVED IN THE FUTURE.
*
* @brief .
*
* Definition of UDLFactoyFunc, using/typedef and default FactoryFunction
* UDLBundle - a simple way to bundle func and cookie into one type
*/
/**
* @brief .
*
* Convenient typedef for user defined layer creation factory
*
* @param[out] void* Cookie - a user opaque data that was passed during SNPE's runtime's
* CreateInstance. SNPE's runtime is passing this back to the user.
*
* @param[out] DlSystem::UDLContext* - The specific Layer Description context what is passe
* SNPE runtime.
*
* @return IUDL* - a Concrete instance of IUDL derivative
*/
using UDLFactoryFunc = std::function<zdl::DlSystem::IUDL* (void*, const zdl::DlSystem::UDLContext*)>;
/**
* NOTE: DEPRECATED, MAY BE REMOVED IN THE FUTURE.
*
* @brief .
*
* default UDL factory implementation
*
* @param[out] DlSystem::UDLContext* - The specific Layer Description context what is passe
* SNPE runtime.
*
* @param[out] void* Cookie - a user opaque data that was passed during SNPE's runtime's
* CreateInstance. SNPE's runtime is passing this back to the user.
*
* @return IUDL* - nullptr to indicate SNPE's runtime that there is no specific
* implementation for UDL. When SNPE's runtime sees nullptr as a return
* value from the factory, it will halt execution if model has an unknown layer
*
*/
inline ZDL_EXPORT zdl::DlSystem::IUDL* DefaultUDLFunc(void*, const zdl::DlSystem::UDLContext*) { return nullptr; }
/**
* NOTE: DEPRECATED, MAY BE REMOVED IN THE FUTURE.
*
* @brief .
*
* Simple struct to bundle 2 elements.
* A user defined cookie that would be returned for each
* IUDL call. The user can place anything there and the
* SNPE runtime will provide it back
*/
struct ZDL_EXPORT UDLBundle {
void *cookie = nullptr;
UDLFactoryFunc func = DefaultUDLFunc;
};
}}
#endif // _UDL_FUNC_HPP_

View File

@@ -1,122 +0,0 @@
//=============================================================================
//
// Copyright (c) 2017 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//=============================================================================
#include <memory>
#include "ZdlExportDefine.hpp"
#include "StringList.hpp"
#ifndef DL_SYSTEM_USER_BUFFER_MAP_HPP
#define DL_SYSTEM_USER_BUFFER_MAP_HPP
namespace DlSystem
{
// Forward declaration of UserBuffer map implementation.
class UserBufferMapImpl;
}
namespace zdl
{
namespace DlSystem
{
class IUserBuffer;
/** @addtogroup c_plus_plus_apis C++
@{ */
/**
* @brief .
*
* A class representing the map of UserBuffer.
*/
class ZDL_EXPORT UserBufferMap final
{
public:
/**
* @brief .
*
* Creates a new empty UserBuffer map
*/
UserBufferMap();
/**
* copy constructor.
* @param[in] other object to copy.
*/
UserBufferMap(const UserBufferMap& other);
/**
* assignment operator.
*/
UserBufferMap& operator=(const UserBufferMap& other);
/**
* @brief Adds a name and the corresponding UserBuffer pointer
* to the map
*
* @param[in] name The name of the UserBuffer
* @param[in] userBuffer The pointer to the UserBuffer
*
* @note If a UserBuffer with the same name already exists, the new
* UserBuffer pointer would be updated.
*/
void add(const char *name, zdl::DlSystem::IUserBuffer *buffer);
/**
* @brief Removes a mapping of one UserBuffer and its name by its name
*
* @param[in] name The name of UserBuffer to be removed
*
* @note If no UserBuffer with the specified name is found, nothing
* is done.
*/
void remove(const char *name) noexcept;
/**
* @brief Returns the number of UserBuffers in the map
*/
size_t size() const noexcept;
/**
* @brief .
*
* Removes all UserBuffers from the map
*/
void clear() noexcept;
/**
* @brief Returns the UserBuffer given its name.
*
* @param[in] name The name of the UserBuffer to get.
*
* @return nullptr if no UserBuffer with the specified name is
* found; otherwise, a valid pointer to the UserBuffer.
*/
zdl::DlSystem::IUserBuffer* getUserBuffer(const char *name) const noexcept;
/**
* @brief .
*
* Returns the names of all UserBuffers
*
* @return A list of UserBuffer names.
*/
zdl::DlSystem::StringList getUserBufferNames() const;
~UserBufferMap();
private:
void swap(const UserBufferMap &other);
std::unique_ptr<::DlSystem::UserBufferMapImpl> m_UserBufferMapImpl;
};
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */
} // DlSystem namespace
} // zdl namespace
#endif // DL_SYSTEM_TENSOR_MAP_HPP

View File

@@ -1,129 +0,0 @@
//=============================================================================
//
// Copyright (c) 2021 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//=============================================================================
#include <memory>
#include "ZdlExportDefine.hpp"
#include "StringList.hpp"
#ifndef DL_SYSTEM_USER_MEMORY_MAP_HPP
#define DL_SYSTEM_USER_MEMORY_MAP_HPP
namespace DlSystem
{
// Forward declaration of UserMemory map implementation.
class UserMemoryMapImpl;
}
namespace zdl
{
namespace DlSystem
{
class IUserBuffer;
/** @addtogroup c_plus_plus_apis C++
@{ */
/**
* @brief .
*
* A class representing the map of UserMemory.
*/
class ZDL_EXPORT UserMemoryMap final
{
public:
/**
* @brief .
*
* Creates a new empty UserMemory map
*/
UserMemoryMap();
/**
* copy constructor.
* @param[in] other object to copy.
*/
UserMemoryMap(const UserMemoryMap& other);
/**
* assignment operator.
*/
UserMemoryMap& operator=(const UserMemoryMap& other);
/**
* @brief Adds a name and the corresponding buffer address
* to the map
*
* @param[in] name The name of the UserMemory
* @param[in] address The pointer to the Buffer Memory
*
* @note If a UserBuffer with the same name already exists, the new
* address would be updated.
*/
void add(const char *name, void *address);
/**
* @brief Removes a mapping of one Buffer address and its name by its name
*
* @param[in] name The name of Memory address to be removed
*
* @note If no UserBuffer with the specified name is found, nothing
* is done.
*/
void remove(const char *name) noexcept;
/**
* @brief Returns the number of User Memory addresses in the map
*/
size_t size() const noexcept;
/**
* @brief .
*
* Removes all User Memory from the map
*/
void clear() noexcept;
/**
* @brief .
*
* Returns the names of all User Memory
*
* @return A list of Buffer names.
*/
zdl::DlSystem::StringList getUserBufferNames() const;
/**
* @brief Returns the no of UserMemory addresses mapped to the buffer
*
* @param[in] name The name of the UserMemory
*
*/
size_t getUserMemoryAddressCount(const char *name) const noexcept;
/**
* @brief Returns address at a specified index corresponding to a UserMemory buffer name
*
* @param[in] name The name of the buffer
* @param[in] index The index in the list of addresses
*
*/
void* getUserMemoryAddressAtIndex(const char *name, uint32_t index) const noexcept;
~UserMemoryMap();
private:
void swap(const UserMemoryMap &other);
std::unique_ptr<::DlSystem::UserMemoryMapImpl> m_UserMemoryMapImpl;
};
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */
} // DlSystem namespace
} // zdl namespace
#endif // DL_SYSTEM_TENSOR_MAP_HPP

View File

@@ -1,13 +0,0 @@
//=============================================================================
//
// Copyright (c) 2015, 2020 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//=============================================================================
#pragma once
#ifndef ZDL_EXPORT
#define ZDL_EXPORT
#endif

Some files were not shown because too many files have changed in this diff Show More