Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
iChizer0 committed Jan 30, 2024
1 parent fd4e8d3 commit 5033a65
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 21 deletions.
3 changes: 1 addition & 2 deletions core/algorithm/el_algorithm_yolo_pose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,7 @@ el_err_code_t AlgorithmYOLOPOSE::postprocess() {
const float scale_h = stride.second;

for (size_t i = 0; i < keypoint_nums; ++i) {
types::pt3_t<float> keypoint;
const auto offset = pre + i * 3;
const auto offset = pre + i * 3;

float x = utils::dequant_value_i(
offset, output_keypoints, output_keypoints_quant_parm.zero_point, output_keypoints_quant_parm.scale);
Expand Down
18 changes: 9 additions & 9 deletions core/algorithm/el_algorithm_yolov8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include "el_algorithm_yolov8.h"

#include <cmath>
#include <type_traits>

#include "core/el_common.h"
Expand Down Expand Up @@ -60,7 +61,6 @@ AlgorithmYOLOV8::~AlgorithmYOLOV8() {
}

bool AlgorithmYOLOV8::is_model_valid(const EngineType* engine) {

const auto& input_shape{engine->get_input_shape(0)};
if (input_shape.size != 4 || // B, W, H, C
input_shape.dims[0] != 1 || // B = 1
Expand Down Expand Up @@ -154,14 +154,14 @@ el_err_code_t AlgorithmYOLOV8::postprocess() {
IoUType iou_threshold{get_iou_threshold()};

// parse output
for (decltype(num_record) i{0}; i < num_record; ++i) {
auto idx{i};
auto target = 0;
for (decltype(num_record) idx{0}; idx < num_record; ++idx) {
uint16_t target = 0;
// get box target
int8_t max{-128};
int8_t max{INT8_MIN};
for (decltype(num_class) t{0}; t < num_class; ++t) {
if (max < data[idx + (t + INDEX_T) * num_record]) {
max = data[idx + (t + INDEX_T) * num_record];
auto n = data[idx + (t + INDEX_T) * num_record];
if (max < n) {
max = n;
target = t;
}
}
Expand All @@ -173,8 +173,8 @@ el_err_code_t AlgorithmYOLOV8::postprocess() {
.y = 0,
.w = 0,
.h = 0,
.score = static_cast<decltype(BoxType::score)>(score),
.target = target,
.score = static_cast<decltype(BoxType::score)>(std::round(score)),
.target = static_cast<decltype(BoxType::target)>(target),
};

// get box position, int8_t - int32_t (narrowing)
Expand Down
16 changes: 8 additions & 8 deletions porting/el_network.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,25 @@ namespace edgelab {
// WIFI-STA for MQTT
class Network {
public:
Network() : _ip({0}), _is_present(false), network_status(NETWORK_LOST) {}
Network() : _ip(), _is_present(false), network_status(NETWORK_LOST) {}
virtual ~Network() = default;

virtual void init(status_cb_t cb) = 0;
void init() {
this->init(nullptr);
void init() {
this->init(nullptr);
};
virtual void deinit() = 0;
el_net_sta_t status() {
return this->network_status;
};
void set_status(el_net_sta_t status) {
this->network_status = status;
void set_status(el_net_sta_t status) {
this->network_status = status;
if (this->status_cb) {
this->status_cb(this->network_status);
}
}
el_err_code_t get_ip(in4_info_t &ip) {
if (this->network_status == NETWORK_LOST ||
el_err_code_t get_ip(in4_info_t &ip) {
if (this->network_status == NETWORK_LOST ||
this->network_status == NETWORK_IDLE) {
return EL_EPERM;
}
Expand Down Expand Up @@ -127,4 +127,4 @@ class Network {

} // namespace edgelab

#endif
#endif
1 change: 1 addition & 0 deletions sscma/repl/executor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <string>
#include <utility>

#include "core/el_debug.h"
#include "core/synchronize/el_guard.hpp"
#include "core/synchronize/el_mutex.hpp"
#include "sscma/definations.hpp"
Expand Down
11 changes: 9 additions & 2 deletions sscma/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@ typedef std::function<int(void*)> mutable_cb_t;
typedef std::unordered_map<std::string, mutable_cb_t> mutable_map_t;

struct ipv4_addr_t {
ipv4_addr_t() : addr{0} {}

~ipv4_addr_t() = default;

uint8_t addr[4];

// we're not going to validate the input string
static decltype(auto) from_str(std::string s) {
ipv4_addr_t r{0};
ipv4_addr_t r;
uint8_t l{0};

for (std::size_t i = 0; i < s.length(); ++i) {
Expand Down Expand Up @@ -50,11 +54,14 @@ struct ipv4_addr_t {
};

struct ipv6_addr_t {
ipv6_addr_t() : addr{0} {}
~ipv6_addr_t() = default;

uint16_t addr[8];

decltype(auto) to_str() const {
static const char* digits = "0123456789abcdef";
std::string r{};
std::string r;
r.reserve(sizeof "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff:");
for (std::size_t i = 0; i < 8; ++i) {
if (addr[i])
Expand Down

0 comments on commit 5033a65

Please sign in to comment.