segmentation fault가 떠서 어디서 죽나 찾는데 꽤나 고생했네 -_-

(빌드가 느리면 역시 스트레스..)

 

그런데 도무지 allocateTensors() 라는 함수가 어떤 역활을 하는지 모르겠네..

한번 할당하고 또 할당하면 오류나는 느낌..

 

  // Allocate memory for the model's input `Tensor`s.
  try interpreter.allocateTensors()

[링크 : https://www.tensorflow.org/lite/guide/inference]

[링크 : https://www.tensorflow.org/lite/api_docs/cc/class/tflite/interpreter#allocatetensors]

 

여기 소스를 많이 참고했는데.. tensorflow의 label_image쪽이랑은 또 많이 달라서

어느 가이드를 따라가야 하나 고민..

[링크 : https://github.com/Qengineering/TensorFlow_Lite_SSD_RPi_64-bits/blob/master/MobileNetV1.cpp]

'프로그램 사용 > yolo_tensorflow' 카테고리의 다른 글

tflite yolov4  (0) 2021.06.14
tensorflow lite yolov4  (0) 2021.06.10
tflite common.h  (0) 2021.05.21
imx6q neon tensorlow lite  (0) 2021.05.10
tflite type  (0) 2021.05.01
Posted by 구차니
Linux API/linux2021. 5. 25. 15:00

mmap()으로 특정 메모리 영역을 접근하는데

이상한 순서로 에러 메시지가 뒤죽박죽 되어 나와서 겨우겨우 복구(?) 해봤더니 더 멘붕오는 듯한 용어만 잔뜩 -_-

Unhandled fault: external abort on non-linefetch (0x1818) at 0x70000000
pgd = cdbbc000
Error: [70000000] *pgd=0dbc3831, *pte=70000743, *ppte=70000c33

 

ppte는 약어를 못 찾음 (느낌은 pte에 대한 pointer 아닐까 싶긴 하지만..)

PGD : Page Global Directory
PTE : Page Table Entries

[링크 : https://www.kernel.org/doc/gorman/html/understand/understand006.html]

 

(0x1818) 음.. 딱 적절한 나의 마음을 나타내는 값은 ifsr 레지스터 라는데

The values in parenthesis are the ifsr (instruction fault status) register

[링크 : https://stackoverflow.com/questions/15889483/what-do-these-kernel-panic-errors-mean]

 

레지스터값의 의미를 요약하면 다음과 같은데

AXI Slave error로 인해서 abort가 발생,
write access가 abort를 발생
D1 domain?
precise external abort, nontranslation

도대체 무슨 말이야!!!

 




SD
Indicates whether an AXI Decode or Slave error caused an abort. This bit is only valid for external aborts. For all other aborts this bit Should Be Zero:
0 = AXI Decode error caused the abort, reset value
1 = AXI Slave error caused the abort.

RW
Indicates whether a read or write access caused an abort:
0 = read access caused the abort, reset value
1 = write access caused the abort.

Domain
Indicates which one of the 16 domains, D15-D0, is accessed when a data fault occurs. This field takes values 0-15.

Status
Indicates the type of exception generated. To determine the data fault, bits [12] and [10] must be used in conjunction with bits [3:0]. The following encodings are in priority order, 1 is the highest:

0b000001 alignment fault
0b000100 instruction cache maintenance fault
0bx01100 L1 translation, precise external abort
0bx01110 L2 translation, precise external abort
0b011100 L1 translation precise parity error
0b011110 L2 translation precise parity error
0b000101 translation fault, section
0b000111 translation fault, page
0b000011 access flag fault, section
0b000110 access flag fault, page
0b001001 domain fault, section
0b001011 domain fault, page
0b001101 permission fault, section
0b001111 permission fault, page
0bx01000 precise external abort, nontranslation
0bx10110 imprecise external abort
0b011000 imprecise error, parity or ECC
0b000010 debug event.

[링크 : https://developer.arm.com/documentation/.../c5--data-fault-status-register]

 

[링크 : https://github.com/brgl/busybox/blob/master/miscutils/devmem.c]

'Linux API > linux' 카테고리의 다른 글

파일 존재유무 확인하기  (0) 2022.02.11
select, poll, epoll  (0) 2021.11.02
Stopped (tty input)  (0) 2021.05.21
linux gpio interrupt poll?  (0) 2021.05.04
Floating point exception  (0) 2021.04.05
Posted by 구차니

요근래 기사중에 가장 아픈 곳을 찌르는 기사인듯.

나쁘게 말하면 무슨 국비지원 학원이 이번에 새로 선정되었나 싶을 정도로

학원 광고들이 넘쳐나는 느낌이었는데

 

콕 찍어서 그런거 해서 돈 벌 수 있는게 아니다.

실제는 정말 천재개발자 하나를 낚기 위한 밑밥일 뿐

이라는 느낌의 기사.

 

근데 개발자던 코더든 우리나라 환경에서 구분이 가능하긴 한가 싶다.

 

[링크 : https://news.v.daum.net/v/20210524113608246]

'개소리 왈왈 > 직딩의 비애' 카테고리의 다른 글

월 초 = 지름  (2) 2021.06.01
월 말  (2) 2021.05.31
시간만 잘간다~  (0) 2021.05.20
휴가인데 휴가 같지가 않다.  (0) 2021.05.17
놋북이 생겼습니다!  (0) 2021.05.12
Posted by 구차니
Programming/c# & winform2021. 5. 24. 18:28

터미널에서 알록달록하게 해주는 그것!

vt 에뮬레이터 결과를 richtextbox로 보낼까.. 아니면 HTML로 보낼까.. 흐음..

 

[링크 : https://en.wikipedia.org/wiki/ANSI_escape_code]

[링크 : https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797]

 

'Programming > c# & winform' 카테고리의 다른 글

winform 첨자(superscript/subscript)  (0) 2021.07.07
nuget RibbonWinForms  (0) 2021.07.06
c# richtextbox 글씨 색상 입히기  (0) 2021.05.24
c# named argument  (0) 2021.01.06
아.. 이놈의 인코딩..  (0) 2020.12.03
Posted by 구차니
Programming/c# & winform2021. 5. 24. 18:25

영역을 선택하고

선택 영역의 색상을 지정하는 느낌으로 색을 추가한다.

 

SelectionColor = 글씨 색상 <<

SelectionBackColor = 글씨 배경 색 <<

BackColor = richtextbox 전체 배경 색

 

[링크 : https://stackoverflow.com/questions/1926264/color-different-parts-of-a-richtextbox-string]

'Programming > c# & winform' 카테고리의 다른 글

nuget RibbonWinForms  (0) 2021.07.06
ansi escape code  (0) 2021.05.24
c# named argument  (0) 2021.01.06
아.. 이놈의 인코딩..  (0) 2020.12.03
c# vertical tab  (0) 2020.11.26
Posted by 구차니

쿨쿨쿨

'개소리 왈왈 > 육아관련 주저리' 카테고리의 다른 글

완전 연소  (0) 2021.05.28
외근  (0) 2021.05.27
비는 안와서 좋네  (0) 2021.05.19
무슨 주말 내내 비만 오냐 -_-  (0) 2021.05.16
샤오미 미에어 전원 케이블  (0) 2021.05.15
Posted by 구차니
분류가 모호한 글2021. 5. 22. 22:25

인터넷 유머글 보다가 댓글에서 갑자기 발견한 부고

 

21.05.06 사망했고

소식이 알려진 건 21.05.20

 

좋아했던 독자로서 작가님의 명복을 기원합니다..

 

[링크 : https://zdnet.co.kr/view/?no=20210520134059]

'분류가 모호한 글' 카테고리의 다른 글

buildroot rootfs overlay  (2) 2023.06.16
FMCW, MMIC  (0) 2022.03.22
good bye 척 예거  (2) 2020.12.09
FMCW  (0) 2018.07.19
우드락 / 보드롱 / 폼보드?  (0) 2018.05.03
Posted by 구차니
Linux API/linux2021. 5. 21. 17:33

stdin을 통해 입력을 받아 작동하는 프로그램을 쉘에서 실행하고 백드라운드로 돌리니 멈춘다?!

bg
[1] /test
#
[1]+  Stopped (tty input)        /test

 

[링크 : https://topic.alibabacloud.com/...-stopped-tty-input_1_16_30150438.html]

[링크 : https://unix.stackexchange.com/questions/294471/backgrounded-job-keeps-stopping]

 

아무튼 SIGTTIN이 들어와서 그렇다고 하는데

간단하게는.. 해당 시그널을 무시하면 되는거고..

다른 방법은 좀 더 고민해 봐야 할 듯 -_-

 

void
init_shell ()
{

  /* See if we are running interactively.  */
  shell_terminal = STDIN_FILENO;
  shell_is_interactive = isatty (shell_terminal);

  if (shell_is_interactive)
    {
      /* Loop until we are in the foreground.  */
      while (tcgetpgrp (shell_terminal) != (shell_pgid = getpgrp ()))
        kill (- shell_pgid, SIGTTIN);

      /* Ignore interactive and job-control signals.  */
      signal (SIGINT, SIG_IGN);
      signal (SIGQUIT, SIG_IGN);
      signal (SIGTSTP, SIG_IGN);
      signal (SIGTTIN, SIG_IGN);
      signal (SIGTTOU, SIG_IGN);
      signal (SIGCHLD, SIG_IGN);

      /* Put ourselves in our own process group.  */
      shell_pgid = getpid ();
      if (setpgid (shell_pgid, shell_pgid) < 0)
        {
          perror ("Couldn't put the shell in its own process group");
          exit (1);
        }

      /* Grab control of the terminal.  */
      tcsetpgrp (shell_terminal, shell_pgid);

      /* Save default terminal attributes for shell.  */
      tcgetattr (shell_terminal, &shell_tmodes);
    }
}

[링크 : https://www.gnu.org/software/libc/manual/html_node/Initializing-the-Shell.html]

 

Macro: int SIGTTINA process cannot read from the user’s terminal while it is running as a background job. When any process in a background job tries to read from the terminal, all of the processes in the job are sent a SIGTTIN signal. The default action for this signal is to stop the process. For more information about how this interacts with the terminal driver, see Access to the Terminal.

[링크 : https://www.gnu.org/software/libc/manual/html_node/Job-Control-Signals.html]

'Linux API > linux' 카테고리의 다른 글

select, poll, epoll  (0) 2021.11.02
Unhandled fault: external abort on non-linefetch  (0) 2021.05.25
linux gpio interrupt poll?  (0) 2021.05.04
Floating point exception  (0) 2021.04.05
실행파일 not fount, FATAL: kernel too old  (0) 2021.04.05
Posted by 구차니

label_image 예제를 보면 get_top_n 에서

(prediction[i] + 128) / 256.0 나 prediction[i] / 255.0 

같은 quantization 범위에 맞춘 무언가가 보이는데 

TfLiteQuantizationParams.scale 와 TfLiteQuantizationParams.zero_point을 이용하면 자동화 가능할 느낌.

template <class T>
void get_top_n(T* prediction, int prediction_size, size_t num_results,
               float threshold, std::vector<std::pair<float, int>>* top_results,
               TfLiteType input_type) {
  // Will contain top N results in ascending order.
  std::priority_queue<std::pair<float, int>, std::vector<std::pair<float, int>>,
                      std::greater<std::pair<float, int>>>
      top_result_pq;

  const long count = prediction_size;  // NOLINT(runtime/int)
  float value = 0.0;

  for (int i = 0; i < count; ++i) {
    switch (input_type) {
      case kTfLiteFloat32:
        value = prediction[i];
        break;
      case kTfLiteInt8:
        value = (prediction[i] + 128) / 256.0;
        break;
      case kTfLiteUInt8:
        value = prediction[i] / 255.0;
        break;
      default:
        break;
    }
    // Only add it if it beats the threshold and has a chance at being in
    // the top N.
    if (value < threshold) {
      continue;
    }

    top_result_pq.push(std::pair<float, int>(value, i));

    // If at capacity, kick the smallest value out.
    if (top_result_pq.size() > num_results) {
      top_result_pq.pop();
    }
  }

  // Copy to output vector and reverse into descending order.
  while (!top_result_pq.empty()) {
    top_results->push_back(top_result_pq.top());
    top_result_pq.pop();
  }
  std::reverse(top_results->begin(), top_results->end());
}

 

netron 에서 보면 quantization 범위가 나오는데, 어딘가 저장하고는 있는 듯 해서 검색 중

// SupportedQuantizationTypes.
typedef enum TfLiteQuantizationType {
  // No quantization.
  kTfLiteNoQuantization = 0,
  // Affine quantization (with support for per-channel quantization).
  // Corresponds to TfLiteAffineQuantization.
  kTfLiteAffineQuantization = 1,
} TfLiteQuantizationType;

// Structure specifying the quantization used by the tensor, if-any.
typedef struct TfLiteQuantization {
  // The type of quantization held by params.
  TfLiteQuantizationType type;
  // Holds a reference to one of the quantization param structures specified
  // below.
  void* params;
} TfLiteQuantization;

// Legacy. Will be deprecated in favor of TfLiteAffineQuantization.
// If per-layer quantization is specified this field will still be populated in
// addition to TfLiteAffineQuantization.
// Parameters for asymmetric quantization. Quantized values can be converted
// back to float using:
//     real_value = scale * (quantized_value - zero_point)
typedef struct TfLiteQuantizationParams {
  float scale;
  int32_t zero_point;
} TfLiteQuantizationParams;

// Parameters for asymmetric quantization across a dimension (i.e per output
// channel quantization).
// quantized_dimension specifies which dimension the scales and zero_points
// correspond to.
// For a particular value in quantized_dimension, quantized values can be
// converted back to float using:
//     real_value = scale * (quantized_value - zero_point)
typedef struct TfLiteAffineQuantization {
  TfLiteFloatArray* scale;
  TfLiteIntArray* zero_point;
  int32_t quantized_dimension;
} TfLiteAffineQuantization;

typedef struct TfLiteTensor {
  TfLiteType type;
  TfLitePtrUnion data;
  TfLiteIntArray* dims;
  TfLiteQuantizationParams params;
  TfLiteAllocationType allocation_type;
  size_t bytes;
  const void* allocation;
  const char* name;
  struct TfLiteDelegate* delegate;
  TfLiteBufferHandle buffer_handle;
  bool data_is_stale;
  bool is_variable;
  TfLiteQuantization quantization;
  TfLiteSparsity* sparsity;
  const TfLiteIntArray* dims_signature;
} TfLiteTensor;

 

+

2021.05.26

typedef struct TfLiteIntArray {
  int size;
// gcc 6.1+ have a bug where flexible members aren't properly handled
// https://github.com/google/re2/commit/b94b7cd42e9f02673cd748c1ac1d16db4052514c
#if (!defined(__clang__) && defined(__GNUC__) && __GNUC__ == 6 && \
     __GNUC_MINOR__ >= 1) ||                                      \
    defined(HEXAGON) || (__clang_major__ == 7 && __clang_minor__ == 1)
  int data[0];
#else
  int data[];
#endif
} TfLiteIntArray;

// Fixed size list of floats. Used for per-channel quantization.
typedef struct TfLiteFloatArray {
  int size;
// gcc 6.1+ have a bug where flexible members aren't properly handled
// https://github.com/google/re2/commit/b94b7cd42e9f02673cd748c1ac1d16db4052514c
// This also applies to the toolchain used for Qualcomm Hexagon DSPs.
#if !defined(__clang__) && defined(__GNUC__) && __GNUC__ == 6 && \
    __GNUC_MINOR__ >= 1
  float data[0];
#else
  float data[];
#endif
} TfLiteFloatArray;

 

class Interpreter {
  /// Invoke the interpreter (run the whole graph in dependency order).
  ///
  /// NOTE: It is possible that the interpreter is not in a ready state
  /// to evaluate (i.e. if a ResizeTensor() has been performed without an
  /// AllocateTensors().
  /// Returns status of success or failure.
  TfLiteStatus Invoke();

  /// WARNING: Experimental interface, subject to change
  Subgraph& primary_subgraph() {
    return *subgraphs_.front();  /// Safe as subgraphs_ always has 1 entry.
  }
  
  /// Read only access to list of inputs.
  const std::vector<int>& inputs() const { return primary_subgraph().inputs(); }
  
  /// Read only access to list of outputs.
  const std::vector<int>& outputs() const {
    return primary_subgraph().outputs();
  }
  
  // Subgraphs
  std::vector<std::unique_ptr<Subgraph>> subgraphs_;
};

[링크 : https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/interpreter.h]

 

class Subgraph {
  // Array of indices representing the tensors that are inputs to the
  // interpreter.
  std::vector<int> inputs_;

  // Array of indices representing the tensors that are outputs to the
  // interpreter.
  std::vector<int> outputs_;
  
  // Read only access to list of inputs.
  std::vector<int>& inputs() { return inputs_; }

  // Read only access to list of inputs.
  const std::vector<int>& inputs() const { return inputs_; }

  // Read only access to list of outputs.
  std::vector<int>& outputs() { return outputs_; }

  // Read only access to list of outputs.
  const std::vector<int>& outputs() const { return outputs_; }
};

[링크 : https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/core/subgraph.h]

'프로그램 사용 > yolo_tensorflow' 카테고리의 다른 글

tensorflow lite yolov4  (0) 2021.06.10
tensorflow lite interpreter->AllocateTensors()  (0) 2021.05.26
imx6q neon tensorlow lite  (0) 2021.05.10
tflite type  (0) 2021.05.01
tflite example  (0) 2021.04.19
Posted by 구차니
embeded/raspberry pi2021. 5. 21. 11:43

기본 설정으로는 1080p60 / 2160p30이 한계이고

config.txt에서 hdmi_enable_4kp60=1을 넣어주면 4kp60을 지원한다고.

근데 해보고 나서 리부팅 하고 해상도 설정 바꾸어 보는데 60p가 안뜬다 -_-

(USB-C 바로 옆에 HDMI-0만 된다는데 왜 안되냐고!!)

 

The Raspberry Pi 4 can drive up to two displays, with a resolution up to 1080p at a 60Hz refresh rate. At 4K resolution, if you connect two displays then you are limited to a 30Hz refresh rate. You can also drive a single display at 4K with a 60Hz refresh rate: this requires that the display is attached to the HDMI port adjacent to the USB-C power input (labelled HDMI0). You must also enable 4Kp60 output by setting the hdmi_enable_4kp60=1 flag in config.txt. 

[링크 : https://www.raspberrypi.org/documentation/configuration/hdmi-config.md]

 

다 넣어봐도 안되네 -_ㅠ

[링크 : https://www.raspberrypi.org/forums/viewtopic.php?t=246634]

 

+ 2021.05.24

config.txt 파일 뒤져보다 보니 어라?!

pi4 항목에 은근슬쩍 들어가있는 dtoverlay=vc4-fkms-v3d

이걸 주석처리 하니 1920x1080 0Hz로 인식되어버리고 메뉴에서도 화면설정하는 항목이 사라진다 -_-

[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-fkms-v3d
max_framebuffers=2

[all]
#dtoverlay=vc4-fkms-v3d

 

raspi-config 에서는 Advanced Options - HDMI / Composite 에 해당 항목이 존재한다.

 

 

'embeded > raspberry pi' 카테고리의 다른 글

rpi cm4 어댑터 보드 or RPI zero 케이블?  (0) 2021.06.04
rpi4 cm4 csi  (0) 2021.06.03
라즈베리 파이 이미지 dd로 굽기  (0) 2021.05.21
rpi usb boot 확인?  (0) 2021.05.18
rpi 4b / tensorflow lite 빌드  (0) 2021.05.18
Posted by 구차니