KR102670314B1 - Device and Method for Calculating Function Approximation in Floating Point - Google Patents

Device and Method for Calculating Function Approximation in Floating Point Download PDF

Info

Publication number
KR102670314B1
KR102670314B1 KR1020210100619A KR20210100619A KR102670314B1 KR 102670314 B1 KR102670314 B1 KR 102670314B1 KR 1020210100619 A KR1020210100619 A KR 1020210100619A KR 20210100619 A KR20210100619 A KR 20210100619A KR 102670314 B1 KR102670314 B1 KR 102670314B1
Authority
KR
South Korea
Prior art keywords
input
function
approximation
value
exponent
Prior art date
Application number
KR1020210100619A
Other languages
Korean (ko)
Other versions
KR20230018742A (en
Inventor
한정호
Original Assignee
주식회사 사피온코리아
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 주식회사 사피온코리아 filed Critical 주식회사 사피온코리아
Priority to KR1020210100619A priority Critical patent/KR102670314B1/en
Priority to PCT/KR2022/011592 priority patent/WO2023008984A1/en
Publication of KR20230018742A publication Critical patent/KR20230018742A/en
Application granted granted Critical
Publication of KR102670314B1 publication Critical patent/KR102670314B1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F17/00Digital computing or data processing equipment or methods, specially adapted for specific functions
    • G06F17/10Complex mathematical operations
    • G06F17/17Function evaluation by approximation methods, e.g. inter- or extrapolation, smoothing, least mean square method
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F5/00Methods or arrangements for data conversion without changing the order or content of the data handled
    • G06F5/01Methods or arrangements for data conversion without changing the order or content of the data handled for shifting, e.g. justifying, scaling, normalising
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F5/00Methods or arrangements for data conversion without changing the order or content of the data handled
    • G06F5/01Methods or arrangements for data conversion without changing the order or content of the data handled for shifting, e.g. justifying, scaling, normalising
    • G06F5/012Methods or arrangements for data conversion without changing the order or content of the data handled for shifting, e.g. justifying, scaling, normalising in floating-point computations
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/38Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation
    • G06F7/48Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation using non-contact-making devices, e.g. tube, solid state device; using unspecified devices
    • G06F7/483Computations with numbers represented by a non-linear combination of denominational numbers, e.g. rational numbers, logarithmic number system or floating-point numbers
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/38Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation
    • G06F7/48Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation using non-contact-making devices, e.g. tube, solid state device; using unspecified devices
    • G06F7/544Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation using non-contact-making devices, e.g. tube, solid state device; using unspecified devices for evaluating functions by calculation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/38Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation
    • G06F7/48Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation using non-contact-making devices, e.g. tube, solid state device; using unspecified devices
    • G06F7/544Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation using non-contact-making devices, e.g. tube, solid state device; using unspecified devices for evaluating functions by calculation
    • G06F7/5443Sum of products
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/38Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation
    • G06F7/48Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation using non-contact-making devices, e.g. tube, solid state device; using unspecified devices
    • G06F7/544Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation using non-contact-making devices, e.g. tube, solid state device; using unspecified devices for evaluating functions by calculation
    • G06F7/556Logarithmic or exponential functions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/06Physical realisation, i.e. hardware implementation of neural networks, neurons or parts of neurons
    • G06N3/063Physical realisation, i.e. hardware implementation of neural networks, neurons or parts of neurons using electronic means

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computational Mathematics (AREA)
  • Mathematical Analysis (AREA)
  • Pure & Applied Mathematics (AREA)
  • Mathematical Optimization (AREA)
  • General Engineering & Computer Science (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Mathematical Physics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Health & Medical Sciences (AREA)
  • Software Systems (AREA)
  • Neurology (AREA)
  • Nonlinear Science (AREA)
  • Evolutionary Computation (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Computational Linguistics (AREA)
  • Artificial Intelligence (AREA)
  • Algebra (AREA)
  • Databases & Information Systems (AREA)
  • Complex Calculations (AREA)

Abstract

부동 소수점 표현에서 함수 근사를 연산하는 방법 및 장치를 개시한다.
본 발명의 일 측면에 의하면, 부동 소수점 표현에서 함수 근사의 연산을 위한 컴퓨터 구현 방법에 있어서 입력의 지수부를 기 설정된 값으로 치환함으로써 전처리된 입력을 생성하고, 상기 입력의 지수부의 치환에 따른 오프셋(offset)을 생성하는 제1 명령어 실행 단계; 상기 전처리된 입력에 대해 함수의 근사 결과를 구하는 제2 명령어 실행 단계; 및 상기 오프셋을 이용하여 상기 근사 결과를 후처리함으로써, 상기 입력에 대한 상기 함수의 근사값을 계산하는 제3 명령어 실행 단계를 포함하는 방법 및 장치를 제공한다.
A method and apparatus for computing function approximation in floating point representation are disclosed.
According to one aspect of the present invention, in a computer implementation method for calculating a function approximation in a floating point expression, a preprocessed input is generated by replacing the exponent part of the input with a preset value, and an offset ( A first instruction execution step of generating an offset); A second instruction execution step of obtaining an approximation result of a function for the preprocessed input; and a third instruction execution step of calculating an approximation value of the function for the input by post-processing the approximation result using the offset.

Description

부동 소수점 표현에서 함수 근사를 연산하는 방법 및 장치{Device and Method for Calculating Function Approximation in Floating Point}{Device and Method for Calculating Function Approximation in Floating Point}

본 발명의 실시예들은 부동 소수점 표현을 이용한 함수 근사를 연산하는 방법 및 장치, 자세하게는 부동 소수점 포맷에 기반하여 최소한의 명령어들을 이용하여 함수의 근사값을 계산하는 방법 및 장치에 관한 것이다.Embodiments of the present invention relate to a method and device for calculating a function approximation using a floating point representation, and more specifically, to a method and device for calculating an approximation of a function using a minimum number of instructions based on a floating point format.

이 부분에 기술된 내용은 단순히 본 발명에 대한 배경 정보를 제공할 뿐 종래기술을 구성하는 것은 아니다.The content described in this section simply provides background information about the present invention and does not constitute prior art.

뉴럴 네트워크(Neural network) 분야에서는 다양한 초월 함수들이 연산에 이용된다. 초월 함수의 예로써, 지수 함수(exponential function), 로그 함수(logarithmic function), 또는 제곱근 함수(square root function) 등이 있다. PC, 클라우드 서버와 같은 연산 장치가 초월 함수들의 값을 계산한다. In the field of neural networks, various transcendental functions are used for calculations. Examples of transcendental functions include exponential functions, logarithmic functions, or square root functions. Computing devices such as PCs and cloud servers calculate the values of transcendental functions.

하지만, 연산 장치가 초월 함수들의 값을 정확하게 계산하기 위해서는 수십 내지 수백 사이클(cycle)의 시간이 소요된다는 문제점이 있다. However, there is a problem that it takes tens to hundreds of cycles for the computing device to accurately calculate the values of transcendental functions.

이러한 문제점을 해결하기 위해, 초월 함수들의 값을 신속하게 계산하는 방법들이 연구되고 있다. 초월 함수에 대한 연산 시간을 줄이는 방법은 대표적으로 두 가지가 있다. To solve this problem, methods for quickly calculating the values of transcendental functions are being studied. There are two representative ways to reduce the calculation time for transcendental functions.

첫 번째, 초월 함수의 값을 계산하도록 설계된 전용 연산 장치를 추가하는 방법이 있다. 예를 들면, 첫 번째 방법은 하드웨어 가속기 또는 AI(Artificial Intelligent) 가속기를 이용하여 초월 함수의 값을 계산하는 것이다. 첫 번째 방법은 전용 하드웨어를 이용함으로써 초월 함수를 계산하는 데 소요되는 시간을 줄일 수 있다. First, there is a way to add a dedicated computational unit designed to calculate the values of transcendental functions. For example, the first method is to calculate the value of the transcendental function using a hardware accelerator or AI (Artificial Intelligent) accelerator. The first method can reduce the time required to calculate the transcendental function by using dedicated hardware.

하지만, 전용 하드웨어 장치 또는 전용 하드웨어 유닛은 차지하는 면적 또는 부피가 크기 때문에, 첫 번째 방법은 활용도가 떨어진다는 단점이 있다.However, since the dedicated hardware device or dedicated hardware unit occupies a large area or volume, the first method has the disadvantage of low usability.

두 번째, 초월 함수의 입력 범위를 여러 구간으로 나눈 후 개별 구간에서 초월 함수의 근사값을 출력하는 근사화 방법이 있다. 예를 들면, 두 번째 방법은 개별 구간 마다 초월 함수를 직선 함수 또는 다항 함수 중 어느 하나로 근사화하고, 근사화된 함수를 이용하여 입력 값에 대한 초월 함수의 근사값을 계산한다. 이를 구간별 직선 근사(piecewise linear approximation) 또는 구간별 다항 근사(piecewise polynomial approximation)라 한다. Second, there is an approximation method that divides the input range of the transcendental function into several sections and then outputs the approximate value of the transcendental function in each section. For example, the second method approximates the transcendental function with either a linear function or a polynomial function for each individual interval, and uses the approximated function to calculate the approximate value of the transcendental function for the input value. This is called piecewise linear approximation or piecewise polynomial approximation.

하지만, 두 번째 방법에 의하면, 초월 함수값의 변화가 큰 개별 구간에서는 근사값의 근사 오차가 커지는 문제점이 있다. 예를 들면, 지수 함수의 입력 값이 클수록 근사 오차가 커지고, 로그 함수의 입력 값이 0에 가까울수록 근사 오차가 커진다.However, according to the second method, there is a problem that the approximation error of the approximate value increases in individual sections where the change in the transcendental function value is large. For example, the larger the input value of the exponential function, the larger the approximation error, and the closer the input value of the logarithmic function is to 0, the larger the approximation error.

근사 오차를 줄이기 위해, 두 번째 방법은 입력 값에 전처리(pre-processing)를 적용하고, 근사값에 후처리(pro-processing)를 적용할 수 있다. 여기서, 전처리는 주어진 함수보다 변화량이 적은 함수의 도메인으로 입력 값을 매핑하는 것이다. 후처리는 매핑된 도메인에서 계산된 결과를 원래 도메인으로 변환하는 것이다. To reduce the approximation error, the second method can apply pre-processing to the input value and post-processing to the approximate value. Here, preprocessing is mapping the input value to the domain of a function with less change than the given function. Post-processing is to convert the results calculated from the mapped domain to the original domain.

구체적으로, 두 번째 방법은 초월 함수에 따라 입력 값을 전처리하고, 전처리된 값에 대해 함수의 근사값을 구하며, 근사값을 다시 후처리함으로써, 입력 값에 대한 초월 함수의 근사값을 계산할 수 있다. 전처리 및 후처리를 이용하는 근사화 방법은 초월 함수값의 변화가 큰 구간에서 근사 오차를 줄일 수 있다. Specifically, the second method can calculate the approximate value of the transcendental function for the input value by preprocessing the input value according to the transcendental function, obtaining an approximate value of the function for the preprocessed value, and postprocessing the approximate value again. The approximation method using pre-processing and post-processing can reduce approximation errors in sections where there is a large change in the transcendental function value.

하지만, 종래의 초월 함수 근사를 연산하는 방법은 전처리와 후처리를 수행함에 있어서, 부동 소수점(Floating Point; FP) 표현과 정수(integer; INT) 표현을 함께 사용하기 때문에 명령어(instruction)의 수가 많아지는 단점이 있다. 전처리 및 후처리에 따른 명령어의 수로 인해, 초월 함수의 근사값을 계산하는 데 많은 시간이 소요된다.However, the conventional method of calculating transcendental function approximation requires a large number of instructions because it uses both floating point (FP) and integer (INT) expressions when performing pre-processing and post-processing. There is a downside to losing. Due to the number of instructions required for pre-processing and post-processing, it takes a lot of time to calculate the approximation of the transcendental function.

구체적으로, 종래의 초월 함수 근사를 연산하는 프로세서(processor)는 사칙연산과 같은 산술 명령어들(Arithmetic instructions)을 이용하여 초월 함수 근사를 연산한다. 이때, 프로세서는 부동 소수점 표현과 정수 표현의 수 체계(number system)을 지원한다. 두 가지 수 체계를 지원하기 위해서, 프로세서는 부동 소수점으로 표현된 숫자를 정수로 변환하는 명령어 또는 정수로 표현된 숫자를 부동 소수점으로 변환하는 명령어들을 산술 명령어와 함께 이용한다. 또한, 프로세서는 초월 함수를 위한 전처리와 후처리를 수행함에 있어서, 부동 소수점으로 표현된 수에서 지수(Exponential) 부분의 값을 추출하는 명령어, 지수부의 값을 특정 값으로 바꾸어 주는 명령어, 특정 조건에 따라 지수부에서 추출한 값에 특정 연산을 적용하는 명령어 등 많은 수의 명령어들을 이용한다. Specifically, a processor that calculates a conventional transcendental function approximation calculates a transcendental function approximation using arithmetic instructions such as four arithmetic operations. At this time, the processor supports number systems of floating point representation and integer representation. To support the two number systems, the processor uses instructions that convert numbers expressed as floating point to integers or instructions that convert numbers expressed as integers to floating point along with arithmetic instructions. In addition, when performing pre-processing and post-processing for transcendental functions, the processor uses instructions to extract the value of the exponential part from a number expressed in floating point, an instruction to change the value of the exponential part to a specific value, and a specific condition. Accordingly, a large number of instructions are used, including instructions that apply specific operations to the value extracted from the exponent part.

이처럼, 프로세서가 전처리와 후처리를 수행하는 데 많은 명령어들을 실행하고 많은 시간을 소비하기 때문에, 단위 시간당 초월함수 계산 횟수가 낮아지는 문제점이 발생한다. 특히 수 많은 초월함수 값을 계산하는 뉴럴 네트워크에서는 초월함수 값의 계산 처리속도를 효율적으로 높일 수 있는 방법 및 효율적인 명령어 구축에 관한 연구가 필요하다.As such, because the processor executes many instructions and consumes a lot of time to perform pre-processing and post-processing, a problem occurs in which the number of transcendental function calculations per unit time is lowered. In particular, in neural networks that calculate numerous transcendental function values, research is needed on methods to efficiently increase the calculation processing speed of transcendental function values and the construction of efficient commands.

본 발명의 실시예들은, 부동 소수점 표현 방식의 수 체계에서 함수 근사를 위한 전처리 및 후처리를 효율적으로 처리할 수 있는 명령어들을 정의하고 이용함으로써, 함수 근사에 필요한 명령어 수 및 소요 시간을 줄이기 위한 연산 방법 및 장치를 제공하는 데 주된 목적이 있다.Embodiments of the present invention define and use instructions that can efficiently process pre-processing and post-processing for function approximation in a floating-point representation number system, thereby reducing the number of instructions and time required for function approximation. The main purpose is to provide methods and devices.

본 발명의 다른 실시예들은, 주어진 입력을 함수값의 변화가 적은 도메인으로 매핑(mapping)하여 매핑된 도메인 내에서 함수의 근사값을 구하고, 매핑된 도메인 내 근사값을 다시 주어진 입력의 도메인으로 변환함으로써, 함수값의 변화가 큰 도메인에서도 근사 오차를 줄이기 위한 연산 방법 및 장치를 제공하는 데 일 목적이 있다.Other embodiments of the present invention map a given input to a domain with little change in the function value, obtain an approximate value of the function within the mapped domain, and convert the approximate value within the mapped domain back to the domain of the given input, The purpose is to provide a computational method and device to reduce approximation errors even in domains where there is a large change in function values.

본 발명의 일 측면에 의하면, 부동 소수점 표현에서 함수 근사의 연산을 위한 컴퓨터 구현 방법에 있어서 입력의 지수부를 기 설정된 값으로 치환함으로써 전처리된 입력을 생성하고, 상기 입력의 지수부의 치환에 따른 오프셋(offset)을 생성하는 제1 명령어 실행 단계; 상기 전처리된 입력에 대해 함수의 근사 결과를 구하는 제2 명령어 실행 단계; 및 상기 오프셋을 이용하여 상기 근사 결과를 후처리함으로써, 상기 입력에 대한 상기 함수의 근사값을 계산하는 제3 명령어 실행 단계를 포함하는 방법을 제공한다.According to one aspect of the present invention, in a computer implementation method for calculating a function approximation in a floating point expression, a preprocessed input is generated by replacing the exponent part of the input with a preset value, and an offset ( A first instruction execution step of generating an offset); A second instruction execution step of obtaining an approximation result of a function for the preprocessed input; and a third instruction execution step of calculating an approximation value of the function for the input by post-processing the approximation result using the offset.

본 실시예의 다른 측면에 의하면, 명령어들을 저장하는 메모리; 및 상기 명령어들을 실행하는 프로세서를 포함하며, 상기 프로세서는, 입력의 지수부를 기 설정된 값으로 치환함으로써 전처리된 입력을 생성하고, 상기 입력의 지수부의 치환에 따른 오프셋(offset)을 생성하고, 상기 전처리된 입력에 대해 상기 함수의 근사 결과를 구하고, 상기 오프셋을 이용하여 상기 근사 결과를 후처리함으로써, 상기 입력에 대한 상기 함수의 근사값을 계산하는, 연산 장치를 제공한다.According to another aspect of the present embodiment, a memory for storing instructions; and a processor executing the instructions, wherein the processor generates a preprocessed input by replacing the exponent part of the input with a preset value, generates an offset according to the substitution of the exponent part of the input, and performs the preprocessing. An arithmetic device is provided that calculates an approximation of the function for the input by obtaining an approximation result of the function for the input and post-processing the approximation result using the offset.

본 실시예의 다른 측면에 의하면, 제1항 내지 제12항 중 어느 한 항의 방법을 실행하기 위한 컴퓨터 프로그램을 기록한 컴퓨터로 판독 가능한 기록매체를 제공한다.According to another aspect of this embodiment, a computer-readable recording medium recording a computer program for executing the method of any one of claims 1 to 12 is provided.

이상에서 설명한 바와 같이 본 발명의 일 실시예에 의하면, 부동 소수점 표현 방식의 수 체계에서 함수 근사를 위한 전처리 및 후처리를 효율적으로 처리할 수 있는 명령어들을 정의하고 이용함으로써, 함수 근사에 필요한 명령어 수 및 소요 시간을 줄일 수 있다.As described above, according to an embodiment of the present invention, by defining and using instructions that can efficiently process pre-processing and post-processing for function approximation in the floating point representation number system, the number of instructions required for function approximation is increased. and time required can be reduced.

본 발명의 다른 실시예에 의하면, 주어진 입력을 함수값의 변화가 적은 도메인으로 매핑(mapping)하여 매핑된 도메인 내에서 함수의 근사값을 구하고, 매핑된 도메인 내 근사값을 다시 주어진 입력의 도메인으로 변환함으로써, 함수값의 변화가 큰 구간에서도 근사 오차를 줄일 수 있다.According to another embodiment of the present invention, the given input is mapped to a domain with little change in the function value, an approximate value of the function is obtained within the mapped domain, and the approximate value within the mapped domain is converted back to the domain of the given input. , approximation error can be reduced even in sections where the change in function value is large.

도 1은 본 발명의 일 실시예에 따른 반정밀도 부동 소수점(half-precision floating point)를 설명하기 위해 예시한 도면이다.
도 2는 본 발명의 일 실시예에 따른 연산 시스템에 대한 구성도다.
도 3은 본 발명의 일 실시예에 따라 함수 근사를 연산하는 방법을 설명하기 위한 순서도다.
도 4는 본 발명의 일 실시예에 따라 함수 근사를 연산하기 위한 명령어들을 예시한 도면이다.
도 5a 및 도 5b는 입력에 대한 지수 함수 및 전처리된 입력에 대한 지수 함수를 나타낸 도면이다.
도 5c 및 도 5d는 자연 지수 함수의 근사를 위한 종래의 명령어들과 본 발명의 일 실시예에 따른 명령어들을 비교하기 위한 도면이다.
도 6a 및 도 6b는 입력에 대한 로그 함수 및 전처리된 입력에 대한 로그 함수를 나타낸 도면이다.
도 6c 및 도 6d는 로그 함수의 근사를 위한 종래의 명령어들과 본 발명의 일 실시예에 따른 명령어들을 비교하기 위한 도면이다.
도 7a 및 도 7b는 입력에 대한 제곱근 함수 및 전처리된 입력에 대한 제곱근 함수를 나타낸 도면이다.
도 7c 및 도 7d는 제곱근 함수의 근사를 위한 종래의 명령어들과 본 발명의 일 실시예에 따른 명령어들을 비교하기 위한 도면이다.
도 8a 및 도 8b는 입력에 대한 제곱근의 역수 함수 및 전처리된 입력에 대한 제곱근의 역수 함수를 나타낸 도면이다.
도 8c 및 도 8d는 제곱근의 역수 함수의 근사를 위한 종래의 명령어들과 본 발명의 일 실시예에 따른 명령어들을 비교하기 위한 도면이다.
도 9a 및 도 9b는 입력에 대한 역수 함수 및 전처리된 입력에 대한 역수 함수를 나타낸 도면이다.
도 9c 및 도 9d는 역수 함수의 근사를 위한 종래의 명령어들과 본 발명의 일 실시예에 따른 명령어들을 비교하기 위한 도면이다.
1 is a diagram illustrating a half-precision floating point according to an embodiment of the present invention.
Figure 2 is a configuration diagram of an operation system according to an embodiment of the present invention.
Figure 3 is a flowchart for explaining a method of calculating function approximation according to an embodiment of the present invention.
Figure 4 is a diagram illustrating instructions for calculating function approximation according to an embodiment of the present invention.
5A and 5B are diagrams showing an exponential function for input and an exponential function for preprocessed input.
5C and 5D are diagrams for comparing conventional instructions for approximation of a natural exponential function and instructions according to an embodiment of the present invention.
Figures 6a and 6b are diagrams showing a logarithmic function for input and a logarithmic function for preprocessed input.
6C and 6D are diagrams for comparing conventional instructions for approximating a logarithmic function and instructions according to an embodiment of the present invention.
7A and 7B are diagrams showing the square root function for the input and the square root function for the preprocessed input.
7C and 7D are diagrams for comparing conventional instructions for approximating a square root function and instructions according to an embodiment of the present invention.
Figures 8a and 8b are diagrams showing the reciprocal square root function for the input and the reciprocal square root function for the preprocessed input.
8C and 8D are diagrams for comparing conventional instructions for approximating the reciprocal square root function with instructions according to an embodiment of the present invention.
9A and 9B are diagrams showing a reciprocal function for an input and a reciprocal function for a preprocessed input.
9C and 9D are diagrams for comparing conventional instructions for approximating a reciprocal function with instructions according to an embodiment of the present invention.

이하, 본 발명의 일부 실시예들을 예시적인 도면을 통해 상세하게 설명한다. 각 도면의 구성요소들에 참조부호를 부가함에 있어서, 동일한 구성요소들에 대해서는 비록 다른 도면 상에 표시되더라도 가능한 한 동일한 부호를 가지도록 하고 있음에 유의해야 한다. 또한, 본 발명을 설명함에 있어, 관련된 공지 구성 또는 기능에 대한 구체적인 설명이 본 발명의 요지를 흐릴 수 있다고 판단되는 경우에는 그 상세한 설명은 생략한다.Hereinafter, some embodiments of the present invention will be described in detail through illustrative drawings. When adding reference numerals to components in each drawing, it should be noted that the same components are given the same reference numerals as much as possible even if they are shown in different drawings. Additionally, in describing the present invention, if it is determined that a detailed description of a related known configuration or function may obscure the gist of the present invention, the detailed description will be omitted.

또한, 본 발명의 구성 요소를 설명하는 데 있어서, 제 1, 제 2, A, B, (a), (b) 등의 용어를 사용할 수 있다. 이러한 용어는 그 구성 요소를 다른 구성 요소와 구별하기 위한 것일 뿐, 그 용어에 의해 해당 구성 요소의 본질이나 차례 또는 순서 등이 한정되지 않는다. 명세서 전체에서, 어떤 부분이 어떤 구성요소를 '포함', '구비'한다고 할 때, 이는 특별히 반대되는 기재가 없는 한 다른 구성요소를 제외하는 것이 아니라 다른 구성요소를 더 포함할 수 있는 것을 의미한다. 또한, 명세서에 기재된 '~부', '모듈' 등의 용어는 적어도 하나의 기능이나 동작을 처리하는 단위를 의미하며, 이는 하드웨어나 소프트웨어 또는 하드웨어 및 소프트웨어의 결합으로 구현될 수 있다.Additionally, when describing the components of the present invention, terms such as first, second, A, B, (a), and (b) may be used. These terms are only used to distinguish the component from other components, and the nature, sequence, or order of the component is not limited by the term. Throughout the specification, when a part is said to 'include' or 'have' a certain component, this means that it does not exclude other components but may further include other components, unless specifically stated to the contrary. . Additionally, terms such as 'unit' and 'module' used in the specification refer to a unit that processes at least one function or operation, and may be implemented through hardware, software, or a combination of hardware and software.

도 1은 본 발명의 일 실시예에 따른 부동 소수점을 설명하기 위해 예시한 도면이다.1 is a diagram illustrating floating point numbers according to an embodiment of the present invention.

도 1을 참조하면, 반정밀도 부동소수점의 구성이 도시되어 있다.Referring to Figure 1, the configuration of a half-precision floating point is shown.

부동 소수점(Floating Point; FP) 표현은 IEEE 표준 754 부동 소수점 표현을 의미한다. Floating Point (FP) representation refers to IEEE Standard 754 floating point representation.

부동 소수점의 정밀도는 반정밀도(half-precision), 단정밀도(single-precision) 및 배정밀도(double-precision) 중 어느 하나일 수 있다. 반정밀도 부동 소수점은 16 비트(bits)로 표현되며, 단정밀도 부동 소수점은 32 비트로 표현되고, 배정밀도 부동 소수점은 64 비트로 표현된다. The precision of floating point can be half-precision, single-precision, or double-precision. Half-precision floating point points are expressed with 16 bits, single-precision floating point points are expressed with 32 bits, and double-precision floating point points are expressed with 64 bits.

부동 소수점의 구성은 부호부(bit sign), 지수부(Exponent; E), 및 가수부(Mantissa; M)를 포함한다. 예를 들어, 반정밀도 부동 소수점은 1 비트의 부호 비트, 5비트의 지수부, 10 비트의 가수부로 구성된다. The composition of floating point includes a bit sign, exponent (E), and mantissa (M). For example, a half-precision floating point consists of a 1-bit sign bit, a 5-bit exponent part, and a 10-bit mantissa bit.

단정밀도 부동 소수점 표현은 지수부 및 가수부의 값에 따라 정규값(normalized number), 비정규값(subnormal number), 제로(+/- zero), NaN(Not a Number), 및 무한대(+/- Infinity)를 나타낼 수 있다. Single-precision floating point representation can be normalized number, subnormal number, zero (+/- zero), NaN (Not a Number), and infinity (+/- Infinity) depending on the values of the exponent and mantissa. ) can be indicated.

정규값은 일반적은 수를 나타내며, 값을 십진수 표현에서 의 형태로 나타낸다. E는 지수부이고, M은 가수부다. 지수부는 바이어스를 포함하는 것을 전제한다. 가수는 암시된 선행하는 1을 가진다. 가수가 선행하는 1을 갖는 수인 경우, 정규값은 값을 형태로 표현한다.A regular value represents a common number and can be converted to decimal representation. It is expressed in the form of . E is the exponent part, and M is the mantissa part. The exponent part is assumed to contain a bias. The mantissa has a leading 1 implied. If the mantissa is a number with a leading 1, the normal value is Express it in form.

정규값과 달리, 비정규값의 가수는 선행하는 1을 가지지 않는다. 비정규값은 십진수 표현에서 형태로 표현된다. 반정밀도 부동 소수점에서 는 -14로 정의된다. 비정규값을 통해 0에 가까운 수를 나타낼 수 있다.Unlike regular values, the mantissa of non-normal values does not have a leading 1. Non-normal values have decimal representation expressed in form. In half-precision floating point is defined as -14. Numbers close to 0 can be expressed through non-normal values.

지수부는 부호 비트가 없기 때문에 음수를 취급하기 위해 바이어스를 이용한다. 정규값의 지수부는 최상위 비트가 1 비트인 바이어스를 이용할 수 있다. 반정밀도 부동 소수점 표현에서 바이어스를 통해 -15 내지 16의 범위를 가지는 지수부는 0 내지 31의 범위로 표현될 수 있다. 예를 들어, 지수부의 이진수 비트열이 10000인 경우, 십진수 표현에서 16으로 계산되지만, 바이어스 비트열도 10000이므로 실질적으로 0의 지수를 의미한다. 따라서, 십진수 표현에서 의 값은 1이 된다. 다른 예로써, 지수부의 이진수 비트열이 01111인 경우, 십진수 표현에서 15로 계산되지만, 실질적으로 -1을 의미한다. 의 값은 0.5가 된다. Because the exponent part does not have a sign bit, a bias is used to handle negative numbers. The exponent part of a regular value can use a bias where the most significant bit is 1 bit. In half-precision floating point representation, the exponent part, which has a range of -15 to 16, can be expressed in the range of 0 to 31 through bias. For example, if the binary bit string of the exponent part is 10000, it is calculated as 16 in decimal representation, but since the bias bit string is also 10000, it actually means an exponent of 0. Therefore, in decimal representation The value of becomes 1. As another example, if the binary bit string of the exponent part is 01111, it is calculated as 15 in decimal representation, but actually means -1. The value of becomes 0.5.

도 2는 본 발명의 일 실시예에 따른 연산 시스템에 대한 구성도다.Figure 2 is a configuration diagram of an operation system according to an embodiment of the present invention.

도 2를 참조하면, 연산 시스템(20)은 데이터 메모리(200), 프로그램 메모리(210) 및 프로세서(220)를 포함한다. Referring to FIG. 2 , the computing system 20 includes a data memory 200, a program memory 210, and a processor 220.

연산 시스템(20)은 뉴럴 네트워크를 기초로 입력 데이터를 실시간으로 분석하여 유효한 정보를 추출하고, 추출된 정보를 기초로 상황을 판단하거나 연산 시스템(20)이 탑재되는 전자 장치의 구성들을 제어할 수 있다. 데이터 메모리(200), 프로그램 메모리(210) 및 프로세서(220)는 하나의 반도체 칩 또는 복수의 반도체 칩으로 구현될 수 있다.The computing system 20 can extract valid information by analyzing input data in real time based on a neural network, judge the situation based on the extracted information, or control the configuration of the electronic device on which the computing system 20 is mounted. there is. The data memory 200, program memory 210, and processor 220 may be implemented with one semiconductor chip or a plurality of semiconductor chips.

데이터 메모리(200) 및 프로그램 메모리(210)는 프로그램들, 데이터, 또는 명령들(instructions)을 저장할 수 있다. Data memory 200 and program memory 210 may store programs, data, or instructions.

데이터 메모리(200) 및 프로그램 메모리(210)는 DRAM(Dynamic RAM) 또는 SRAM(Static RAM) 등의 메모리를 이용해 구현될 수 있다.The data memory 200 and program memory 210 may be implemented using memory such as dynamic RAM (DRAM) or static RAM (SRAM).

프로세서(220)는 연산 시스템(20)의 전반적인 동작을 제어한다. The processor 220 controls the overall operation of the computing system 20.

프로세서(220)는 시스템 버스를 통해 데이터 메모리(200) 및 프로그램 메모리(210) 중 적어도 하나로부터 입력 데이터를 수신할 수 있고, 입력 데이터를 기초로 정보 신호를 생성할 수 있다. 본 발명의 일 실시예에 의하면, 프로세서(220)는 데이터 메모리(200) 및 프로그램 메모리(210)에 저장된 프로그램 및 데이터를 이용하여 함수에 대한 함수 근사를 수행할 수 있다. The processor 220 may receive input data from at least one of the data memory 200 and the program memory 210 through a system bus and generate an information signal based on the input data. According to one embodiment of the present invention, the processor 220 may perform function approximation for a function using programs and data stored in the data memory 200 and the program memory 210.

프로세서(220)는 중앙 처리 장치(Central Processing Unit; CPU), 뉴럴 네트워크 처리 장치(Neural network Processing Unit; NPU)일 수 있다. The processor 220 may be a central processing unit (CPU) or a neural network processing unit (NPU).

그렇지 않으면, 프로세서(220)는 뉴럴 네트워크의 모델들에 따른 연산을 수행하기 위한 하드웨어 가속기(accelerator)일 수 있다. 하드웨어 가속기는 일반적으로, 콘볼루션(convolution) 연산과 같은 행렬 연산을 전용으로 수행하는 엔진; 활성화 함수(activation function)와 같은 비선형 함수(non-linear function), 또는 풀링(pooling) 기능을 수행하는 프로세서; 온칩 메모리(on-chip memory); 및 외부 메모리 접속을 위한 DMA(Direct Memory Access)를 포함한다. Otherwise, the processor 220 may be a hardware accelerator for performing calculations according to neural network models. A hardware accelerator generally includes an engine that specifically performs matrix operations such as convolution operations; A processor that performs a non-linear function, such as an activation function, or a pooling function; on-chip memory; and DMA (Direct Memory Access) for external memory access.

프로세서(220)가 CPU 또는 NPU로 구현되는 경우, 프로세서(220)는 제어부(미도시), 레지스터(register, 미도시), 연산부(미도시), 및 메모리 접근부(미도시)를 포함할 수 있다. 레지스터는 연산부의 연산 입출력이 저장되는 장소이고, 메모리 접근부는 데이터 메모리(200) 및 프로그램 메모리(210)에 대한 접근을 수행하는 구성이다. 제어부는 프로세서(220)의 동작(예컨대, 파워 관리, 인터럽트 처리 등)을 통제한다. When the processor 220 is implemented as a CPU or NPU, the processor 220 may include a control unit (not shown), a register (not shown), an operation unit (not shown), and a memory access unit (not shown). there is. The register is a place where the operation input and output of the operation unit is stored, and the memory access unit is a component that performs access to the data memory 200 and the program memory 210. The control unit controls the operation of the processor 220 (eg, power management, interrupt processing, etc.).

본 발명의 일 실시예에 따른 연산 장치는 연산 시스템(20) 또는 프로세서(220) 상에서 구현될 수 있다. 연산 장치는 뉴럴 네트워크 연산을 위한 하드웨어 가속기로도 구현될 수 있다.The computing device according to an embodiment of the present invention may be implemented on the computing system 20 or the processor 220. The computational device can also be implemented as a hardware accelerator for neural network computation.

도 3은 본 발명의 일 실시예에 따라 함수 근사를 연산하는 방법을 설명하기 위한 순서도다.Figure 3 is a flowchart for explaining a method of calculating function approximation according to an embodiment of the present invention.

이하에서는, 본 발명의 일 실시예에 따른 연산 장치의 개략적인 동작을 설명한다.Below, a schematic operation of the computing device according to an embodiment of the present invention will be described.

본 발명의 일 실시예에 의하면, 연산 장치는 부동 소수점 표현에서 입력의 가수부만 분리하여 구간별 함수 근사를 적용한 뒤, 입력의 지수부를 근사 결과에 반영함으로써, 최종 근사값을 계산한다. According to one embodiment of the present invention, the computing device separates only the mantissa part of the input from the floating point expression, applies sectional function approximation, and then reflects the exponent part of the input in the approximation result to calculate the final approximation value.

입력의 가수부를 분리하는 과정은 지수부를 바이어스 또는 바이어스에 1을 더한 값(바이어스+1)으로 치환하는 과정이다. 입력의 지수부가 바이어스 또는 바이어스에 1을 더한 값으로 치환되면, 전처리된 입력은 십진수 표현에서 1 내지 2 또는 1 내지 4의 범위를 가진다. 일반적으로, 초월 함수에서 1 내지 4의 범위를 가지는 도메인으로 입력을 매핑하는 경우, 해당 범위에서 초월 함수의 변화량이 작아진다. 예를 들면, 10 내지 11의 입력 범위에서 지수 함수의 변화량보다 1 내지 2의 입력 범위에서 지수 함수의 변화량이 작다. 다시 말하면, 입력의 지수부를 바이어스 또는 바이어스에 1을 더한 값으로 치환하는 과정은, 입력을 함수의 변화량이 큰 도메인에서 작은 도메인으로 매핑하는 과정을 의미한다. The process of separating the mantissa part of the input is the process of replacing the exponent part with bias or bias plus 1 (bias + 1). If the exponent of the input is replaced with the bias or bias plus 1, the preprocessed input has the range 1 to 2 or 1 to 4 in decimal representation. In general, when mapping an input from a transcendental function to a domain with a range of 1 to 4, the amount of change in the transcendental function becomes small in that range. For example, the amount of change of the exponential function in the input range of 1 to 2 is smaller than the amount of change of the exponential function in the input range of 10 to 11. In other words, the process of replacing the exponent part of the input with the bias or the bias plus 1 means the process of mapping the input from a domain with a large change in the function to a domain with a small change in the function.

연산 장치는 함수의 변화량이 작은 도메인에서 함수 근사를 연산하므로, 함수의 변화량이 큰 도메인에서의 함수 근사보다 근사 오차를 줄일 수 있다.Since the computing device calculates function approximation in a domain where the change amount of the function is small, the approximation error can be reduced compared to function approximation in a domain where the change amount of the function is large.

나아가, 근사 전 입력의 전처리 및 근사 후 근사 결과에 대한 후처리를 수행함에 있어서, 종래의 연산 장치가 많은 수의 산술 연산 명령어들(Arithmetic operation instructions)과 논리 연산 명령어들(logic operation instructions)을 사용하는 것과 달리, 본 발명의 일 실시예에 따른 연산 장치는 초월함수의 연산 시 도메인 매핑을 위한 전처리와 후처리 작업을 효율적으로 구현할 수 있는 명령어들을 사용함으로써 전처리와 후처리 작업에 사용되는 명령어의 수를 최소화 한다.Furthermore, in performing preprocessing of the input before approximation and postprocessing of the approximation result after approximation, conventional computing devices use a large number of arithmetic operation instructions and logic operation instructions. Unlike this, the computing device according to an embodiment of the present invention uses instructions that can efficiently implement pre-processing and post-processing tasks for domain mapping when calculating transcendental functions, thereby increasing the number of instructions used in pre-processing and post-processing tasks. Minimize.

따라서, 연산 장치는 근사 오차를 줄이되, 연산 사이클을 감소시켜 연산 속도를 향상시킬 수 있다.Accordingly, the computing device can reduce the approximation error and improve the computational speed by reducing the computational cycle.

이하에서는, 본 발명의 일 실시예에 따른 연산 장치의 구체적인 동작을 설명한다.Below, specific operations of the computing device according to an embodiment of the present invention will be described.

도 3을 참조하면, 연산 장치는 입력의 지수부를 기 설정된 값으로 치환함으로써 전처리된 입력을 생성하고, 입력의 지수부의 치환에 따른 오프셋(offset)을 생성한다(S300). Referring to FIG. 3, the computing device generates a preprocessed input by replacing the exponent part of the input with a preset value and generates an offset according to the replacement of the exponent part of the input (S300).

본 발명의 일 실시예에 의하면, 연산 장치는 입력의 지수부를 기 설정된 값인 바이어스로 치환하여 전처리된 입력을 생성한다. 연산 장치가 입력의 지수부를 바이어스로 치환하는 것은 근사 오차를 줄이기 위한 것이다.According to one embodiment of the present invention, the computing device generates a preprocessed input by replacing the exponent part of the input with a bias that is a preset value. The purpose of the calculation device to replace the exponent part of the input with a bias is to reduce approximation errors.

만약 입력의 지수부가 바이어스되지 않은 경우, 입력은 넓은 도메인을 가진다. 바이어스되지 않은 입력의 넓은 도메인에서는 함수의 변화량이 큰 구간이 존재한다. 따라서, 전처리 되지 않은 입력에 함수 근사를 수행하더라도, 함수의 변화량이 큰 구간으로 인해 근사 오차가 크게 발생할 수 있다. If the exponent of the input is unbiased, the input has a wide domain. In a wide domain of unbiased input, there is a section where the amount of change in the function is large. Therefore, even if function approximation is performed on input that has not been preprocessed, a large approximation error may occur due to a section in which the change amount of the function is large.

반대로, 입력의 지수부가 바이어스로 치환된 경우, 지수부가 의미하는 값이 20 또는 1이 된다. 이때, 입력값은 가수부가 표현하는 범위의 값으로 변환되므로 1 내지 2의 좁은 도메인을 가지게 된다. 특히 초월 함수의 경우, 가수부로 표현되는 도메인의 범위에서는 초월 함수의 변화량이 적다. 즉, 입력의 지수부가 바이어스로 치환되는 것은 입력이 함수의 변화량이 적은 도메인으로 매핑되는 것을 의미한다. 연산 장치는 함수의 변화량이 적은 구간에서 근사를 수행하기 때문에 근사 오차를 줄일 수 있다.Conversely, when the exponent part of the input is replaced with bias, the value indicated by the exponent part becomes 2 0 or 1. At this time, the input value is converted to a value in the range expressed by the mantissa, so it has a narrow domain of 1 to 2. In particular, in the case of transcendental functions, the amount of change in the transcendental function is small in the range of the domain expressed by the mantissa. In other words, replacing the exponent part of the input with a bias means that the input is mapped to a domain where the change in the function is small. The calculation device can reduce approximation errors because it performs approximation in sections where the amount of change in the function is small.

한편, 본 발명의 일 실시예에 의하면, 연산 장치는 입력의 지수부와 기 설정된 값 차이에 기초하여 오프셋을 생성할 수 있다. 기 설정된 값이 바이어스인 경우, 연산 장치는 입력의 지수부와 바이어스 간 차이에 기초하여 오프셋을 생성할 수 있다. 입력의 지수부와 바이어스 간 차이는 십진수 표현에서 지수부의 실질적인 값을 의미한다.Meanwhile, according to an embodiment of the present invention, the arithmetic device may generate an offset based on the difference between the exponent part of the input and a preset value. If the preset value is a bias, the arithmetic device may generate an offset based on the difference between the exponent of the input and the bias. The difference between the exponent and bias of the input refers to the actual value of the exponent in decimal representation.

오프셋은 전처리된 입력에 대한 함수의 근사 결과로부터, 원래 구하고자 했던 입력에 대한 함수의 근사값을 계산하는 데 이용된다. 입력의 지수부 관점에서, 오프셋은 바이어스로 치환되기 전의 지수부를 고려하여 근사 결과의 지수부를 조정하는 데 이용된다. 입력의 매핑 관점에서, 오프셋은 함수의 변화량이 적은 도메인으로 매핑된 입력을 다시 원래 도메인으로 변환하는 데 이용된다.The offset is used to calculate the approximation value of the function for the originally intended input from the approximation result of the function for the preprocessed input. In terms of the exponent of the input, the offset is used to adjust the exponent of the approximation result by taking into account the exponent before being replaced with a bias. From the input mapping perspective, the offset is used to transform the mapped input back to the original domain, to a domain where the change in the function is small.

본 발명의 다른 실시예에 의하면, 연산 장치는 입력의 지수부와 기 설정된 값 간 차이만큼 원 비트(one-bit)를 시프트(shift)하여 오프셋을 생성한다. 기 설정된 값이 바이어스인 경우, 연산 장치는 입력의 지수부와 바이어스 간 차이만큼 원 비트를 시프트하여 오프셋을 생성한다. 예를 들어, 입력의 지수부와 바이어스 간 차이가 3인 경우, 연산 장치는 원 비트를 좌측 시프트하여 이진수 비트열 1000을 오프셋으로 생성할 수 있다. 이때, 오프셋은 십진수 표현에서 8이 된다. 상기 동작을 통해 생성된 오프셋은 지수 함수의 근사에 이용될 수 있다. 이에 대한 예시는 도 5d에 서술되어 있다.According to another embodiment of the present invention, the arithmetic device generates an offset by shifting one-bit by the difference between the exponent part of the input and a preset value. If the preset value is a bias, the arithmetic device generates an offset by shifting the original bit by the difference between the exponent part of the input and the bias. For example, if the difference between the exponent of the input and the bias is 3, the arithmetic device can left-shift the original bit to generate a binary bit string of 1000 as an offset. At this time, the offset is 8 in decimal representation. The offset generated through the above operation can be used to approximate an exponential function. An example of this is depicted in Figure 5d.

본 발명의 일 실시예에 의하면, 연산 장치는 입력의 지수부와 바이어스 간 차이값이 홀수인지 짝수인지 여부에 따라, 입력의 지수부를 다른 값으로 치환할 수 있다. 나아가, 연산 장치는 입력의 지수부와 바이어스 간 차이값이 홀수인지 짝수인지 여부에 따라, 오프셋을 다르게 생성할 수 있다. 이에 대한 예시는 도 7d 및 도 8d에 서술되어 있다.According to an embodiment of the present invention, the computing device may replace the exponent part of the input with a different value depending on whether the difference between the exponent part of the input and the bias is odd or even. Furthermore, the computing device may generate different offsets depending on whether the difference between the exponent of the input and the bias is odd or even. Examples of this are depicted in Figures 7d and 8d.

입력의 지수부와 바이어스 간 차이값이 짝수인 경우, 연산 장치는 입력의 지수부를 바이어스로 치환함으로써 전처리된 입력을 생성한다. 나아가, 연산 장치는 입력의 지수부와 바이어스 간 차이에 비트 시프트를 수행함으로써 오프셋을 생성한다. 예를 들어, 연산 장치는 입력의 지수부와 바이어스 간 차이를 1만큼 우측 시프트하여 오프셋을 생성할 수 있다. 상기 동작을 통해 생성된 오프셋은 제곱근 함수 또는 제곱근 역수 함수의 근사에 이용될 수 있다.If the difference between the exponent of the input and the bias is an even number, the computing device generates a preprocessed input by replacing the exponent of the input with the bias. Furthermore, the arithmetic unit generates an offset by performing a bit shift on the difference between the exponent of the input and the bias. For example, the computing device may generate an offset by right shifting the difference between the exponent of the input and the bias by 1. The offset generated through the above operation can be used for approximation of the square root function or the square root reciprocal function.

입력의 지수부와 바이어스 간 차이값이 홀수인 경우, 연산 장치는 입력의 지수부를 바이어스와 홀수의 합으로 치환함으로써 전처리된 입력을 생성한다. 나아가, 연산 장치는 입력의 지수부와 상기 합 간 차이에 비트 시프트를 수행함으로써 오프셋을 생성한다. 예를 들어, 연산 장치는 입력의 지수부를 바이어스에 1을 더한 값(바이어스+1)으로 치환함으로써 전처리된 입력을 생성한다. 또한, 연산 장치는 입력의 지수부로부터, 바이어스에 1을 더한 값(바이어스+1)을 뺄셈하고, 뺄셈 결과를 1만큼 우측 시프트하여 오프셋을 생성한다. 뺄셈 결과를 1만큼 우측 시프트하는 것은 뺄셈 결과의 제곱근을 제거하는 동작에 대응된다. 상기 동작을 통해 생성된 오프셋은 제곱근 함수 또는 제곱근 역수 함수의 근사에 이용될 수 있다.If the difference between the exponent of the input and the bias is an odd number, the computing device generates a preprocessed input by replacing the exponent of the input with the sum of the bias and the odd number. Furthermore, the computing device generates an offset by performing a bit shift on the difference between the exponent of the input and the sum. For example, the computing device generates a preprocessed input by replacing the exponent of the input with a bias plus 1 (bias + 1). Additionally, the arithmetic device subtracts the bias plus 1 (bias + 1) from the exponent part of the input, and right-shifts the subtraction result by 1 to generate an offset. Shifting the subtraction result to the right by 1 corresponds to the operation of removing the square root of the subtraction result. The offset generated through the above operation can be used for approximation of the square root function or the square root reciprocal function.

연산 장치는 전처리된 입력에 대해 함수의 근사 결과를 구한다(S302). The computing device obtains the approximation result of the function for the preprocessed input (S302).

구체적으로, 연산 장치는 함수의 입력 범위가 복수 개의 구간으로 나누고, 구간별로 함수에 직선 근사 또는 다항 근사를 적용한다. 연산 장치는 구간별 근사를 통해 전처리된 입력에 대한 함수 근사값을 계산할 수 있다. 계산된 근사값을 근사 결과라 한다.Specifically, the computing device divides the input range of the function into a plurality of sections and applies a linear approximation or polynomial approximation to the function for each section. The computing device can calculate a function approximation value for the preprocessed input through section-by-section approximation. The calculated approximate value is called the approximation result.

한편, 전처리된 입력에 대한 함수 근사값은 룩업 테이블(look-up table)에 기반하여 계산될 수 있다. 연산 장치는 전체 입력값의 범위를 복수의 세부 구간으로 나누고, 개별 구간에 해당하는 복수의 입력 범위마다 근사 계수를 설정한 룩업 테이블을 미리 저장하고, 저장된 룩업 테이블을 참조하여 입력 값에 대한 함수 근사값을 계산할 수 있다. 여기서, 직선 근사 방식에서 근사 계수는 기울기 및 오프셋을 포함한다. 다항 근사 방식에서 근사 계수는 다항 함수의 계수 및 오프셋을 포함할 수 있다. 예를 들면, 연산 장치는 입력이 포함되는 입력 범위를 식별하고, 룩업 테이블을 참조하여 입력 범위에 설정된 근사 계수를 획득하고, 근사 계수를 이용하여 입력에 대한 함수의 근사값을 계산한다.Meanwhile, the function approximation value for the preprocessed input can be calculated based on a look-up table. The calculation device divides the entire input value range into a plurality of detailed sections, stores in advance a lookup table with approximation coefficients set for each of the multiple input ranges corresponding to each section, and refers to the stored lookup table to obtain a function approximation value for the input value. can be calculated. Here, in the straight line approximation method, the approximation coefficients include slope and offset. In the polynomial approximation method, the approximation coefficients may include the coefficients and offsets of the polynomial function. For example, the computing device identifies the input range that includes the input, obtains the approximation coefficient set in the input range by referring to the lookup table, and calculates the approximation value of the function for the input using the approximation coefficient.

연산 장치는 오프셋을 이용하여 근사 결과를 후처리함으로써, 입력에 대한 함수의 근사값을 계산한다(S304). 이때, 입력에 대한 함수의 근사값을 최종 근사값이라 한다.The computing device calculates the approximate value of the function for the input by post-processing the approximation result using the offset (S304). At this time, the approximation value of the function for the input is called the final approximation value.

구체적으로, 연산 장치는 오프셋을 기반으로 근사 결과의 지수부를 조정한다. 조정된 근사 결과는 원래 구하고자 했던 입력에 대한 함수의 근사값이 된다. 매핑 관점에서, 근사 결과의 지수부가 오프셋에 따라 조정됨으로써, 입력이 함수의 변화량이 큰 도메인에서 함수의 변화량이 적은 도메인으로 매핑된다.Specifically, the computing unit adjusts the exponent part of the approximation result based on the offset. The adjusted approximation result becomes an approximation of the function for the input originally sought. From a mapping perspective, the exponent of the approximation result is adjusted according to the offset, so that the input is mapped from a domain with a large change in the function to a domain with a small change in the function.

본 발명의 일 실시예에 의하면, 연산 장치는 근사 결과의 지수부와 오프셋의 합에 기초하여, 입력에 대한 함수의 근사값을 계산한다. 상기 동작은 지수 함수 및 제곱근 함수의 근사에 이용될 수 있다.According to one embodiment of the present invention, the arithmetic device calculates an approximate value of a function for an input based on the sum of the exponent and the offset of the approximation result. This operation can be used for approximation of exponential and square root functions.

본 발명의 일 실시예에 의하면, 연산 장치는 근사 결과의 지수부와 오프셋의 차이에 기초하여, 입력에 대한 함수의 근사값을 계산한다. 상기 동작은 제곱근의 역수 함수 및 역수 함수의 근사에 이용될 수 있다.According to one embodiment of the present invention, the arithmetic device calculates an approximation value of a function for an input based on the difference between an exponent and an offset of the approximation result. This operation can be used for the approximation of the reciprocal function and the reciprocal function of the square root.

본 발명의 일 실시예에 의하면, 연산 장치는 오프셋, 기 설정된 로그값 및 근사 결과에 곱셈 누적(Multiply Accumulate; MAC) 연산을 수행함으로써, 입력에 대한 함수의 근사값을 계산한다. 상기 동작은 로그 함수의 근사에 이용될 수 있다. 이에 대한 예시는 도 6d에서 서술되어 있다.According to one embodiment of the present invention, the computing device calculates an approximate value of a function for an input by performing a Multiply Accumulate (MAC) operation on an offset, a preset logarithmic value, and an approximation result. This operation can be used to approximate logarithmic functions. An example of this is depicted in Figure 6d.

한편, 본 발명의 일 실시예에 의하면, 연산 장치는 입력의 전처리 전에 입력에 기 설정된 로그값을 곱합으로써, 입력을 조정할 수 있다. 이후, 연산 장치는 조정된 입력의 지수부에 대해 전처리를 수행하고, 오프셋을 생성한다. 나아가, 연산 장치는 근사값을 구하려는 대상 함수가 아닌, 기 설정된 로그값과 연관된 지수 함수의 근사 결과를 구한다. 즉 연산 장치는 전처리된 입력에 대해, 기 설정된 로그값과 연관된 지수 함수의 근사 결과를 구한다. 이후, 연산 장치는 오프셋을 이용하여 근사 결과를 후처리하여, 입력에 대한 대상 함수의 근사값을 계산할 수 있다. 상기 동작은 자연 지수 함수의 근사에 이용될 수 있다. 이에 대한 예시는 도 5d에서 서술되어 있다.Meanwhile, according to an embodiment of the present invention, the computing device can adjust the input by multiplying the input by a preset logarithmic value before preprocessing the input. Afterwards, the arithmetic unit performs preprocessing on the exponent part of the adjusted input and generates an offset. Furthermore, the computing device obtains an approximation result of an exponential function associated with a preset logarithmic value, rather than the target function to be approximated. That is, the computing device obtains an approximation result of an exponential function associated with a preset logarithmic value for the preprocessed input. Afterwards, the computing device can post-process the approximation result using the offset to calculate an approximation value of the target function for the input. This operation can be used for approximation of natural exponential functions. An example of this is depicted in Figure 5d.

본 발명의 일 실시예에 의하면, 연산 장치는 입력에 대한 함수의 근사값이 부동 소수점 체계의 표현 범위를 벗어나는 경우, 최종 근사값을 제로(zero) 또는 무한대(infinity) 중 어느 하나로 설정한다. 이를 클리핑(clipping)이라 한다.According to one embodiment of the present invention, if the approximation value of the function for the input is outside the expression range of the floating point system, the arithmetic device sets the final approximation value to either zero or infinity. This is called clipping.

단계 S300, S302 및 S304는 연산 장치가 각 단계마다 하나의 명령어를 실행함으로써 수행된다. 즉, 연산 장치는 단계 S300를 제1 명령어로 생성하고, 단계 S302를 제2 명령어로 생성하며, 단계 S304를 제3 명령어로 생성한다. 연산 장치는 각 명령어를 실행함으로써, 함수의 근사값을 계산한다. 연산 장치는 제1 명령어의 실시예와 제3 명령어의 실시예를 조합하여 입력에 대한 함수의 근사값을 계산할 수 있다.Steps S300, S302, and S304 are performed by the computing device executing one instruction for each step. That is, the computing device generates step S300 as a first instruction, generates step S302 as a second instruction, and generates step S304 as a third instruction. The computing device calculates an approximate value of the function by executing each instruction. The computing device may calculate an approximate value of a function for an input by combining the embodiment of the first instruction and the embodiment of the third instruction.

본 발명의 일 실시예에 의하면, 함수 근사를 위해 1개 내지 2개의 전처리 명령어와 1개의 후처리 명령어를 사용하므로, 연산 장치는 최소한의 명령어로 함수 근사를 연산할 수 있다.According to one embodiment of the present invention, one to two pre-processing instructions and one post-processing instruction are used for function approximation, so the computing device can calculate the function approximation with a minimum number of instructions.

도 4는 본 발명의 일 실시예에 따라 함수 근사를 연산하기 위한 명령어들을 예시한 도면이다.Figure 4 is a diagram illustrating instructions for calculating function approximation according to an embodiment of the present invention.

도 4를 참조하면, 제1 명령어의 실시예와 제3 명령어의 실시예의 조합이 도시되어 있다. 각 조합에 기반하여, 연산 장치는 지수 함수, 로그 함수, 제곱근 함수, 제곱근의 역수 함수 및 역수 함수의 근사를 연산할 수 있다.Referring to Figure 4, a combination of an embodiment of a first instruction and an embodiment of a third instruction is shown. Based on each combination, the computing device can calculate the exponential function, the logarithmic function, the square root function, the reciprocal function of the square root, and the approximation of the reciprocal function.

Extract_Exp() 명령어는 입력의 지수부를 바이어스 또는 바이어스에 1을 더한 값으로 치환함으로써 전처리된 입력을 생성하고, 치환에 따른 오프셋을 생성하는 제1 명령어이다. Extract_Exp() 명령어에 의해, 입력은 1 내지 2의 범위 또는 1 내지 4의 범위로 매핑된다. X'은 전처리된 입력이고, Est는 오프셋이고, Y는 전처리된 입력에 대한 함수의 근사 결과이며, Y'은 최종 근사값이다. 기호 << 및 >>는 비트 시프트 연산을 의미한다.The Extract_Exp() command is the first command that generates a preprocessed input by replacing the exponent of the input with a bias or a bias plus 1, and generates an offset according to the substitution. By the Extract_Exp() instruction, the input is mapped to the range 1 to 2 or the range 1 to 4. X' is the preprocessed input, E st is the offset, Y is the result of approximation of the function to the preprocessed input, and Y' is the final approximation value. The symbols << and >> indicate bit shift operations.

Apply_ExpOffset() 명령어는 오프셋을 이용하여 근사 결과를 후처리함으로써, 입력에 대한 함수의 근사값을 계산하는 제3 명령어이다. Apply_ExpOffset() 명령어는 전처리된 입력으로부터 계산된 근사 결과의 지수부에 오프셋을 더하거나 빼줌으로써, 입력에 대한 함수의 최종 근사값을 구하는 명령어다.The Apply_ExpOffset() command is a third command that calculates the approximate value of the function for the input by post-processing the approximation result using the offset. The Apply_ExpOffset() command is a command that obtains the final approximation value of a function for the input by adding or subtracting an offset to the exponent of the approximation result calculated from the preprocessed input.

본 발명의 일 실시예에 의하면, 연산 장치는 부동 소수점 표현 방식의 수 체계에서 초월 함수 근사를 위한 전처리 및 후처리 과정을 효율적으로 수행할 수 있는 전용 명령어들을 정의하고 이용함으로써, 입력이 주어질 때 최소한의 명령어들을 이용하여 함수의 근사를 연산할 수 있다.According to an embodiment of the present invention, the computing device defines and uses dedicated instructions that can efficiently perform pre-processing and post-processing for transcendental function approximation in a floating-point representation number system, so that the minimum You can calculate the approximation of a function using the instructions.

도 5a 및 도 5b는 입력에 대한 지수 함수 및 전처리된 입력에 대한 지수 함수를 나타낸 도면이다.5A and 5B are diagrams showing an exponential function for input and an exponential function for preprocessed input.

도 5a를 참조하면, 입력 x에 대한 자연 지수 함수 y가 도시되어 있다. Referring to Figure 5A, the natural exponential function y for input x is shown.

입력 x에 대한 자연 지수 함수 y의 근사 오차를 줄이기 위해, 연산 장치는 구간별 근사를 이용할 수 있다. 구체적으로, 연산 장치는 자연 지수 함수 y에 대해 전체 입력을 8개의 구간으로 나누어 직선 근사 또는 다항 근사를 적용한다. 연산 장치는 입력 x에 대응되는 구간 내 함수 근사를 이용하여 입력 x에 대한 함수 y의 근사값을 계산할 수 있다.To reduce the approximation error of the natural exponential function y for the input x, the computing device can use piecewise approximation. Specifically, the computing device divides the entire input into 8 sections and applies a linear approximation or polynomial approximation to the natural exponential function y. The computing device may calculate an approximate value of a function y for input x using function approximation within an interval corresponding to input x.

구간 S0 내지 구간 S4에서는 자연 지수 함수 y의 변화량이 상대적으로 작기 때문에, 연산 장치가 구간별 직선 근사 또는 다항 근사를 적용하더라도, 참값과 근사값 간 근사 오차가 작다.Since the amount of change in the natural exponential function y is relatively small in the section S 0 to the section S 4 , the approximation error between the true value and the approximated value is small even if the calculation device applies linear approximation or polynomial approximation for each section.

하지만, 구간 S5 내지 구간 S7에서는 자연 지수 함수 y의 변화량이 상대적으로 크기 때문에, 연산 장치가 구간별 직선 근사 또는 다항 근사를 적용하는 경우, 참값과 근사값 간 근사 오차가 크다.However, since the amount of change in the natural exponential function y is relatively large in the section S 5 to section S 7 , when the calculation device applies linear approximation or polynomial approximation for each section, the approximation error between the true value and the approximated value is large.

근사 오차를 줄이기 위해, 연산 장치는 입력을 함수의 변화량이 큰 도메인에서 함수의 변화량이 적은 도메인으로 매핑한다. To reduce approximation error, the computing device maps the input from a domain with a large change in the function to a domain with a small change in the function.

도 5b를 참조하면, 입력 t에 대한 지수 함수 yt가 도시되어 있다. 입력 t는 입력 x가 매핑된 것이다. Referring to Figure 5b, the exponential function y t for input t is shown. Input t is the mapped input x.

입력 t의 도메인 범위는 입력 x의 도메인 범위보다 좁다. 입력 x의 도메인 범위가 0 내지 10인 반면, 입력 t의 도메인 범위는 1 내지 2이다. The domain range of input t is narrower than the domain range of input x. The domain range of input x is 0 to 10, while the domain range of input t is 1 to 2.

또한, 입력 t에 대한 함수 yt의 변화량은 입력 x에 대한 함수 y의 변화량보다 작다. Additionally, the amount of change in function y t with respect to input t is smaller than the amount of change in function y with respect to input x.

입력 x가 함수 y의 변화량이 큰 구간인 S7 내 값이더라도, 전처리를 통해 함수의 변화량이 상대적으로 작은 t 도메인으로 될 수 있다. t 도메인에서 함수 근사를 적용하는 경우, x 도메인에서 함수 근사를 적용하는 경우보다 근사 오차가 작다.Even if the input When applying function approximation in the t domain, the approximation error is smaller than when applying function approximation in the x domain.

연산 장치는 t 도메인에서의 근사 결과를 다시 입력 x의 도메인으로 변환함으로써, 입력 x에 대한 함수 y의 근사값을 구할 수 있다.The computing device can obtain an approximation value of the function y for the input x by converting the approximation result in the t domain back to the domain of the input x.

이하에서는, 입력의 전처리, 전처리된 입력에 대한 함수의 근사, 및 근사 결과에 대한 후처리를 수행하는 데 이용되는 명령어들 및 실행 순서를 종래의 연산 장치와 비교하여 설명한다.Hereinafter, the instructions and execution order used to perform preprocessing of input, approximation of a function for the preprocessed input, and postprocessing of the approximation result will be described in comparison with a conventional computing device.

도 5c 및 도 5d는 자연 지수 함수의 근사를 위한 종래의 명령어들과 본 발명의 일 실시예에 따른 명령어들을 비교하기 위한 도면이다.5C and 5D are diagrams for comparing conventional instructions for approximating a natural exponential function and instructions according to an embodiment of the present invention.

종래의 연산 장치는 자연 지수 함수를 근사하기 위해, 수학식 1을 이용한다.Conventional computing devices use Equation 1 to approximate a natural exponential function.

수학식 1에서 a는 정수부이고, b는 소수부를 의미한다.In Equation 1, a means the integer part, and b means the decimal part.

수학식 1을 참조하면, 종래 연산 장치는 입력 x에 를 곱하고, 곱셈 결과를 정수부와 소수부로 분리한다. 종래 연산 장치는 2를 밑으로 하고 정수부를 지수로 가지는 제1 값과 2를 밑으로 하고 소수부를 지수로 가지는 제2 값을 계산한다. 마지막으로, 종래 연산 장치는 제1 값과 제2 값의 곱셈을 자연 지수 함수의 값으로 계산할 수 있다. Referring to Equation 1, the conventional arithmetic device inputs Multiply and separate the multiplication result into an integer part and a decimal part. A conventional arithmetic device calculates a first value with 2 as the base and an integer portion as an exponent, and a second value with 2 as the base and a decimal portion as an exponent. Finally, the conventional computing device can calculate the multiplication of the first value and the second value as the value of the natural exponential function.

제1 값과 제2 값의 곱셈 결과는 부동 소수점(Floating Point; FP)으로 표현될 수 있다. 이때, 제1 값의 지수 a는 입력 x와 의 곱셈 결과의 정수부에 해당한다. 다시 말하면, 곱셈 결과의 정수부가 자연 지수 함수의 지수부에 해당한다. 종래 연산 장치는 원 비트를 정수부만큼 좌측 시프트하여 제1 값을 생성할 수 있다. The result of multiplying the first value and the second value can be expressed as a floating point (FP). At this time, the exponent a of the first value is the input x and Corresponds to the integer part of the multiplication result. In other words, the integer part of the multiplication result corresponds to the exponent part of the natural exponential function. A conventional arithmetic device can generate the first value by left-shifting the original bit by the integer part.

한편, 종래 연산 장치는 제2 값에 대해서는 함수 근사를 적용한다. 제2 값은 소수부를 입력으로 가지고, 2를 밑으로 하는 지수 함수로 모델링될 수 있다. 이때, 소수부는 0 내지 1 사이의 값을 가지므로, 제2 값은 1 내지 2의 값을 가진다. 소수부는 입력 x에 비해 표현 범위가 좁고, 표현 범위 내에서 제2 값의 변화량이 작다. 따라서, 제2 값에 대해 함수 근사가 적용되더라도, 근사 오차가 작다. Meanwhile, a conventional computing device applies function approximation to the second value. The second value can be modeled as an exponential function with the decimal part as input and base 2. At this time, since the decimal part has a value between 0 and 1, the second value has a value between 1 and 2. The expression range of the decimal part is narrow compared to the input x, and the amount of change in the second value is small within the expression range. Therefore, even if function approximation is applied to the second value, the approximation error is small.

종래 연산 장치는 제1 값과 제2 값의 근사값을 곱함으로써, 입력에 대한 자연 지수 함수의 최종 근사값을 계산한다.Conventional computing devices calculate the final approximation of the natural exponential function for the input by multiplying the approximation of the first and second values.

도 5c를 참조하면, 종래 연산 장치가 수학식 1에 따른 함수 근사를 실행하기 위한 명령어들이 도시되어 있다.Referring to FIG. 5C, instructions for a conventional computing device to perform function approximation according to Equation 1 are shown.

종래 연산 장치는 입력에 를 곱하여 입력을 조정한다(S500). Conventional computing devices input Adjust the input by multiplying (S500).

이때, 입력은 FP로 표현된다.At this time, the input is expressed as FP.

종래 연산 장치는 조정된 입력의 정수부를 추출한다(S502). A conventional computing device extracts the integer part of the adjusted input (S502).

종래 연산 장치는 FP로 표현되는 수를 정수(integer; INT) 표현으로 변환하는 명령어를 실행함으로써, 조정된 입력의 정수부를 추출할 수 있다. 추출된 정수부는 INT로 표현된다. 이 과정에서, 조정된 입력의 소수부는 무시된다.A conventional computing device can extract the integer portion of the adjusted input by executing an instruction that converts a number expressed in FP into an integer (INT) representation. The extracted integer part is expressed as INT. In this process, the fractional part of the adjusted input is ignored.

종래 연산 장치는 정수부의 표현을 INT에서 FP로 변환한다(S504). A conventional computing device converts the expression of the integer part from INT to FP (S504).

종래 연산 장치는 INT로 표현되는 수를 FP 표현으로 변환하는 명령어를 실행함으로써, 정수부의 표현을 FP로 변환한다.A conventional computing device converts the expression of the integer part into FP by executing an instruction that converts a number expressed in INT into an FP expression.

종래 연산 장치는 조정된 입력의 소수부를 추출한다(S506). A conventional computing device extracts the fractional part of the adjusted input (S506).

종래 연산 장치는 FP 표현 체계에서 조정된 입력에서 조정된 입력의 정수부를 뺄셈함으로써, 조정된 입력의 소수부를 추출할 수 있다.A conventional computing device can extract the decimal part of the adjusted input by subtracting the integer part of the adjusted input from the adjusted input in the FP representation system.

종래 연산 장치는 상기 단계를 통해 조정된 입력을 정수부와 소수부로 분리한다.A conventional computing device separates the input adjusted through the above steps into an integer part and a decimal part.

종래 연산 장치는 2를 밑으로 하는 지수 함수에 구간별 근사를 적용하여 소수부에 대한 근사 결과를 계산한다(S508). A conventional computing device calculates the approximation result for the decimal part by applying sectional approximation to an exponential function with base 2 (S508).

구체적으로, 종래 연산 장치는 조정된 입력의 소수부를 입력으로 가지고, 2를 밑으로 하는 지수 함수에 대해 함수 근사를 적용할 수 있다. 소수부의 표현 범위에 따른 지수 함수의 변화량은 입력의 표현 범위에 따른 자연 지수 함수의 변화량보다 적으므로, 종래 연산 장치는 근사 오차가 적은 근사 결과를 구할 수 있다.Specifically, a conventional computing device can take the fractional part of the adjusted input as input and apply function approximation to an exponential function with 2 as the base. Since the amount of change in the exponential function depending on the expression range of the decimal part is less than the amount of change in the natural exponential function depending on the expression range of the input, the conventional computing device can obtain an approximation result with less approximation error.

한편, 종래 연산 장치는 원 비트(one-bit)를 정수부만큼 좌측 시프트하여 오프셋을 생성한다(S510). Meanwhile, a conventional arithmetic device generates an offset by left-shifting a one-bit by an integer (S510).

이진수 표현에서 원 비트를 좌측 시프트하는 경우, 밑이 2이고, 시프트량(shift amount)이 지수인 값이 생성된다. 즉, 오프셋은 2를 밑으로 하고, 정수부를 지수로 가지는 값이다. 이때, 오프셋은 INT로 표현된다.When one bit is left shifted in binary representation, a value with a base of 2 and an exponent of the shift amount is created. In other words, the offset is a value with 2 as the base and the integer part as the exponent. At this time, the offset is expressed as INT.

종래 연산 장치는 오프셋의 표현을 INT에서 FP로 변환한다(S512).A conventional arithmetic device converts the expression of the offset from INT to FP (S512).

종래 연산 장치는 근사 결과에 오프셋을 곱하여 최종 근사값을 계산한다(S514). 종래 연산 장치는 소수부에 대한 근사 결과에 오프셋을 곱함으로써, 수학식 1과 같이 입력에 대한 자연 지수 함수의 근사값을 구할 수 있다.A conventional computing device calculates the final approximation value by multiplying the approximation result by an offset (S514). A conventional computing device can obtain an approximation value of a natural exponential function for an input as shown in Equation 1 by multiplying the approximation result for the decimal part by an offset.

결과적으로, 종래 연산 장치는 단계 S508의 명령어를 제외하고, 입력을 전처리하는 데 4개의 명령어를 사용하고, 근사 결과를 후처리하는 데 3개의 명령어를 사용한다.As a result, the conventional computing device uses four instructions to preprocess the input and three instructions to postprocess the approximation result, excluding the instruction in step S508.

이와 달리, 본 발명의 일 실시예에 따른 연산 장치는 적은 수의 명령어를 이용하여 자연 지수 함수를 근사하기 위해, 수학식 2를 이용한다.In contrast, the computing device according to an embodiment of the present invention uses Equation 2 to approximate a natural exponential function using a small number of instructions.

수학식 2를 참조하면, 연산 장치는 자연 지수 함수에 를 곱하고, 곱셈 결과를 지수부와 가수부로 표현할 수 있다.는 곱셈 결과의 지수부이고, 는 곱셈 결과의 가수부다. Referring to Equation 2, the arithmetic unit uses the natural exponential function You can multiply and express the multiplication result in the exponent and mantissa. is the exponent part of the multiplication result, is the mantissa of the multiplication result.

연산 장치는 곱셈 결과의 가수부에 대해 함수 근사를 연산한다. 그리고 연산 장치는 2를 밑으로 하고, 곱셈 결과의 지수부를 지수로 하는 제3 값()을 계산한다. 제3 값은 오프셋과 관련된 값이다. 연산 장치는 근사 결과의 지수부에 제3 값을 더함으로써, 자연 지수 함수의 근사값을 계산한다. The arithmetic unit calculates a function approximation on the mantissa of the multiplication result. And the arithmetic unit uses 2 as the base and the third value ( ) is calculated. The third value is a value related to the offset. The arithmetic unit calculates the approximation value of the natural exponential function by adding a third value to the exponent part of the approximation result.

도 5d를 참조하면, 본 발명의 일 실시예에 따른 연산 장치가 수학식 2에 따른 함수 근사를 실행하기 위한 명령어들이 도시되어 있다. Referring to FIG. 5D, instructions for a computing device according to an embodiment of the present invention to perform function approximation according to Equation 2 are shown.

본 발명의 일 실시예에 따른 연산 장치는 입력에 를 곱하여 입력을 조정한다(S520).The computing device according to an embodiment of the present invention inputs Adjust the input by multiplying (S520).

연산 장치는 조정된 입력의 지수부를 바이어스로 치환하여 전처리된 입력을 생성하고, 원 비트(one-bit)를 지수부와 바이어스 간 차이만큼 시프트하여 오프셋을 생성한다(S522).The arithmetic unit generates a preprocessed input by replacing the exponent of the adjusted input with a bias, and generates an offset by shifting the one-bit by the difference between the exponent and the bias (S522).

다시 말하면, 전처리된 입력은 지수부가 바이어스이고, 가수부가 조정된 입력의 가수부인 값이다. 전처리된 입력은 십진수 표현에서 1 내지 2의 값을 가진다. 지수부와 바이어스 간 차이를 시프트량(shift amount)라 할 때, 오프셋은 이진수 표현에서 밑이 2이고 시프트량이 지수인 값이다. 예를 들어, 입력의 지수부와 바이어스 간 차이가 2인 경우, 오프셋은 이진수 비트열 100이고, 십진수 표현에서 4가 된다.In other words, the preprocessed input is a value where the exponent is the bias and the mantissa is the mantissa of the adjusted input. The preprocessed input has a value of 1 to 2 in decimal representation. When the difference between the exponent and the bias is called the shift amount, the offset is a value whose base is 2 in binary representation and the shift amount is the exponent. For example, if the difference between the exponent of the input and the bias is 2, the offset is the binary bit string 100, which in decimal representation is 4.

연산 장치는 2를 밑으로 하는 지수함수에 구간별 근사를 적용하여 전처리된 입력에 대한 근사 결과를 계산한다(S524).The computing device calculates the approximation result for the preprocessed input by applying sectional approximation to the exponential function with base 2 (S524).

구체적으로, 연산 장치는 2를 밑으로 하는 지수 함수를 여러 구간으로 나누고, 전처리된 입력이 속한 구간을 식별한다. 연산 장치는 식별된 구간에서 직선 근사 계수 또는 다항 근사 계수를 직접 계산하거나, 기 저장된 룩업 테이블로부터 구할 수 있다. 연산 장치는 직선 근사 계수 또는 다항 근사 계수 중 어느 하나와 전처리된 입력으로부터 근사 결과를 구한다. 십진수 표현에서 전처리된 입력의 범위가 1 내지 2이므로, 근사 결과의 범위는 2 내지 4이다. 근사 결과의 범위가 2 내지 4이므로, FP 표현에서 근사 결과의 지수부는 바이어스에 1을 더한 값이다. Specifically, the computing device divides the base 2 exponential function into several sections and identifies the section to which the preprocessed input belongs. The computing device can directly calculate the linear approximation coefficient or polynomial approximation coefficient in the identified section, or obtain it from a previously stored lookup table. The computing device obtains an approximation result from either a linear approximation coefficient or a polynomial approximation coefficient and a preprocessed input. Since the range of the preprocessed input in decimal representation is 1 to 2, the range of the approximation result is 2 to 4. Since the range of the approximation result is 2 to 4, the exponent of the approximation result in the FP expression is the bias plus 1.

연산 장치는 근사 결과의 지수부에 오프셋을 더함으로써, 입력에 대한 자연 지수 함수의 최종 근사값을 계산한다(S526).The computing device calculates the final approximation value of the natural exponential function for the input by adding an offset to the exponent part of the approximation result (S526).

단계 S520 내지 S526을 간략히 설명하면, 연산 장치는 부동 소수점 표현에서 입력의 가수부만 분리하여 구간별 함수 근사를 적용한 뒤, 입력의 지수부를 근사 결과에 반영함으로써, 최종 근사값을 계산한다.Briefly explaining steps S520 to S526, the computing device separates only the mantissa part of the input from the floating point expression, applies sectional function approximation, and then reflects the exponent part of the input in the approximation result to calculate the final approximation value.

본 발명의 일 실시예에 따른 연산 장치는 단계 S524의 명령어를 제외하고, 입력을 전처리하는 데 2개의 명령어를 사용하고, 근사 결과를 후처리하는 데 1개의 명령어를 사용한다. 단계 S520, 단계 S522 및 단계 S526의 각 명령어는 FP 표현을 기반하므로, INT와 FP 사이 변환 명령어를 필요로 하지 않는다. 연산 장치는 부동 소수점 표현에만 기반하여 전처리 명령어와 후처리 명령어를 최소화한다.The computing device according to an embodiment of the present invention uses two instructions to preprocess the input and one instruction to postprocess the approximation result, except for the instruction in step S524. Since each instruction in step S520, step S522, and step S526 is based on the FP expression, a conversion instruction between INT and FP is not required. The computational unit minimizes preprocessing and postprocessing instructions based solely on floating point representation.

또한, 연산 장치는 함수의 변화량이 작은 도메인에서 함수 근사를 연산하므로, 함수의 변화량이 큰 도메인에서의 함수 근사보다 근사 오차를 줄일 수 있다. Additionally, since the computing device calculates function approximation in a domain where the change amount of the function is small, approximation errors can be reduced compared to function approximation in a domain where the change amount of the function is large.

도 6a 및 도 6b는 입력에 대한 로그 함수 및 전처리된 입력에 대한 로그 함수를 나타낸 도면이다.Figures 6a and 6b are diagrams showing a logarithmic function for input and a logarithmic function for preprocessed input.

도 6a를 참조하면, 입력 x에 대한 로그 함수 y가 도시되어 있다.Referring to Figure 6A, the logarithmic function y for input x is shown.

구간 S1 내지 구간 S7에서는 로그 함수 y의 변화량이 상대적으로 작기 때문에, 연산 장치가 구간별 직선 근사 또는 다항 근사를 적용하더라도, 참값과 근사값 간 근사 오차가 작다.Since the amount of change in the logarithmic function y is relatively small in the section S 1 to the section S 7 , the approximation error between the true value and the approximated value is small even if the calculation device applies linear approximation or polynomial approximation for each section.

하지만, 구간 S0에서는 로그 함수 y의 변화량이 상대적으로 크기 때문에, 연산 장치가 구간별 직선 근사 또는 다항 근사를 적용하는 경우, 참값과 근사값 간 근사 오차가 크다.However, since the amount of change in the logarithmic function y is relatively large in the section S 0 , when the computing device applies linear approximation or polynomial approximation for each section, the approximation error between the true value and the approximated value is large.

근사 오차를 줄이기 위해, 연산 장치는 입력을 함수의 변화량이 큰 도메인에서 함수의 변화량이 적은 도메인으로 매핑한다. To reduce approximation error, the computing device maps the input from a domain with a large change in the function to a domain with a small change in the function.

도 6b를 참조하면, 입력 t에 대한 로그 함수 yt가 도시되어 있다. Referring to Figure 6b, the logarithmic function y t for input t is shown.

입력 t의 도메인 범위는 입력 x의 도메인 범위보다 좁다. 또한, 입력 t에 대한 함수 yt의 변화량은 입력 x에 대한 함수 y의 변화량보다 작다. 입력 x의 범위에서 로그 함수의 변화량보다 입력 t의 범위에서 로그 함수의 변화량이 작다.The domain range of input t is narrower than the domain range of input x. Additionally, the amount of change in function y t with respect to input t is smaller than the amount of change in function y with respect to input x. The amount of change in the logarithmic function in the range of input t is smaller than the amount of change in the logarithmic function in the range of input x.

입력 x가 함수 y의 변화량이 큰 구간인 S0 내 값이더라도, 전처리를 통해 함수의 변화량이 상대적으로 작은 t 도메인으로 될 수 있다. t 도메인에서 함수 근사를 적용하는 경우, x 도메인에서 함수 근사를 적용하는 경우보다 근사 오차가 작다.Even if the input When applying function approximation in the t domain, the approximation error is smaller than when applying function approximation in the x domain.

연산 장치는 t 도메인에서의 근사 결과를 다시 입력 x의 도메인으로 변환함으로써, 입력 x에 대한 함수 y의 근사값을 구할 수 있다.The computing device can obtain an approximation value of the function y for the input x by converting the approximation result in the t domain back to the domain of the input x.

이하에서는, 입력의 전처리, 전처리된 입력에 대한 함수의 근사, 및 근사 결과에 대한 후처리를 수행하는 데 이용되는 명령어들 및 실행 순서를 종래의 연산 장치와 비교하여 설명한다.Hereinafter, the instructions and execution order used to perform preprocessing of input, approximation of a function for the preprocessed input, and postprocessing of the approximation result will be described in comparison with a conventional computing device.

도 6c 및 도 6d는 로그 함수의 근사를 위한 종래의 명령어들과 본 발명의 일 실시예에 따른 명령어들을 비교하기 위한 도면이다.6C and 6D are diagrams for comparing conventional instructions for approximating a logarithmic function and instructions according to an embodiment of the present invention.

종래의 연산 장치는 로그 함수를 근사하기 위해, 수학식 3을 이용한다.Conventional computing devices use Equation 3 to approximate a logarithmic function.

수학식 3에서 k는 입력 x의 지수부이고, 은 입력 x의 가수부이다.In Equation 3, k is the exponent of input x, is the mantissa of input x.

수학식 3을 참조하면, 종래 연산 장치는 입력 x의 지수부 k, log(2) 및 에 곱셈 누적(Multiply-Accumulate; MAC) 연산함으로써, 입력 x에 대한 로그 함수의 함수값을 계산한다. Referring to Equation 3, the conventional arithmetic device uses the exponent k, log(2), and By performing a Multiply-Accumulate (MAC) operation, the function value of the logarithmic function for input x is calculated.

이때, 종래 연산 장치는 에 대해 구간별 근사를 적용할 수 있다. 입력 x의 가수부는 1 내지 2의 값을 가지므로, 입력 x보다 표현 범위가 좁다. 또한, 입력 x의 가수부의 범위에서 로그 함수의 변화량이 입력 x의 범위에서 로그 함수의 변화량보다 작다. 입력 x의 가수부에 대한 근사 오차가 입력 x에 대한 근사 오차보다 작다. 따라서, 종래 연산 장치는 입력 x의 가수부에 대한 구간별 근사를 통해 근사 오차를 줄일 수 있다.At this time, the conventional computing device is A sectional approximation can be applied to . Since the mantissa of input x has a value of 1 to 2, the expression range is narrower than that of input x. Additionally, the amount of change in the logarithmic function in the range of the mantissa of input x is smaller than the amount of change in the logarithmic function in the range of input x. The approximation error for the mantissa of input x is smaller than the approximation error for input x. Therefore, the conventional computing device can reduce the approximation error through section-by-section approximation to the mantissa part of the input x.

종래 연산 장치는 지수부 k, log(2) 및 근사값에 MAC 연산을 수행함으로써, 입력 x에 대한 로그 함수의 최종 근사값을 계산할 수 있다.A conventional computing device can calculate the final approximation value of a logarithmic function for input x by performing a MAC operation on the exponent k, log(2), and the approximation value.

도 6c를 참조하면, 종래 연산 장치가 수학식 3에 따른 함수 근사를 실행하기 위한 명령어들이 도시되어 있다.Referring to FIG. 6C, instructions for a conventional computing device to perform function approximation according to Equation 3 are shown.

종래 연산 장치는 입력의 지수부를 추출한다(S600).A conventional computing device extracts the exponent part of the input (S600).

종래 연산 장치는 입력에 시프트 연산, 마스크(mask) 연산 및 뺄셈(subtraction) 연산에 관한 명령어들을 실행함으로써, 입력의 지수부를 추출할 수 있다. 종래 연산 장치가 입력의 지수부를 추출하기 위해, 3개의 명령어가 필요하다.A conventional computing device can extract the exponent part of an input by executing instructions related to a shift operation, a mask operation, and a subtraction operation on the input. In order for a conventional computing device to extract the exponent part of the input, three instructions are required.

종래 연산 장치는 추출한 지수부를 바이어스로 치환한다(S602). A conventional computing device replaces the extracted exponent with a bias (S602).

종래 연산 장치는 입력의 지수부에 비트별 마스크(bit-wise mask) 연산 및 OR 연산에 관한 명령어들을 실행함으로써, 추출한 지수부를 바이어스로 치환할 수 있다. 종래 연산 장치가 추출한 지수부를 바이어스로 치환하기 위해, 2개의 명령어가 필요하다.A conventional computing device can replace the extracted exponent with a bias by executing instructions related to a bit-wise mask operation and OR operation on the exponent of the input. In order to replace the exponent extracted by a conventional computing device with a bias, two instructions are required.

단계 S600 및 S602를 통해 종래 연산 장치는 입력을 전처리한다.Through steps S600 and S602, the conventional computing device preprocesses the input.

종래 연산 장치는 로그 함수에 구간별 근사를 적용하여 전처리된 입력에 대한 근사 결과를 계산한다(S508).A conventional computing device calculates the approximation result for the preprocessed input by applying sectional approximation to the logarithmic function (S508).

종래 연산 장치는 전처리된 입력에 대한 로그 함수의 근사 결과를 구한다. 전처리된 입력의 표현 범위에 따른 로그 함수의 변화량은 입력의 표현 범위에 따른 로그 함수의 변화량보다 적으므로, 종래 연산 장치는 근사 오차가 적은 근사 결과를 구할 수 있다.A conventional computing device obtains an approximation result of a logarithmic function for a preprocessed input. Since the amount of change in the logarithmic function according to the expression range of the preprocessed input is less than the amount of change in the logarithmic function according to the expression range of the input, the conventional computing device can obtain an approximation result with a small approximation error.

종래 연산 장치는 지수부, log(2) 및 근사 결과에 MAC 연산을 수행함으로써, 입력에 대한 로그 함수의 최종 근사값을 계산한다(S606).The conventional computing device calculates the final approximation value of the logarithmic function for the input by performing MAC operation on the exponent part, log(2), and the approximation result (S606).

종래 연산 장치는 단계 S604의 명령어를 제외하고, 입력을 전처리하는 데 5개의 명령어를 사용하고, 근사 결과를 후처리하는 데 1개의 명령어를 사용한다.Excluding the instruction in step S604, the conventional computing device uses five instructions to preprocess the input and one instruction to postprocess the approximation result.

이와 달리, 본 발명의 일 실시예에 따른 연산 장치는 수학식 3을 이용하여 로그 함수의 근사를 연산하되, 종래 연산 장치보다 적은 수의 명령어로 로그 함수의 근사값을 구할 수 있다. In contrast, the computing device according to an embodiment of the present invention calculates the approximation of the logarithmic function using Equation 3, but can obtain the approximate value of the logarithmic function with fewer instructions than a conventional computing device.

도 6d를 참조하면, 본 발명의 일 실시예에 따른 연산 장치가 수학식 3에 따른 함수 근사를 실행하기 위한 명령어들이 도시되어 있다. Referring to FIG. 6D, instructions for a computing device according to an embodiment of the present invention to perform function approximation according to Equation 3 are shown.

본 발명의 일 실시예에 따른 연산 장치는 입력의 지수부를 바이어스로 치환하여 입력을 전처리하고, 입력의 지수부와 바이어스 간 차이를 오프셋으로 생성한다(S610).The computing device according to an embodiment of the present invention preprocesses the input by replacing the exponent part of the input with a bias, and generates the difference between the exponent part of the input and the bias as an offset (S610).

다시 말하면, 전처리된 입력은 입력의 지수부가 바이어스로 치환된 값이고, 오프셋은 입력의 지수부에서 오프셋을 뺀 값이다. In other words, the preprocessed input is a value in which the exponent part of the input is replaced with a bias, and the offset is a value obtained by subtracting the offset from the exponent part of the input.

연산 장치는 로그 함수에 구간별 근사를 적용하여 전처리된 입력에 대한 근사 결과를 계산한다(S612).The computing device calculates the approximation result for the preprocessed input by applying sectional approximation to the logarithmic function (S612).

연산 장치는 오프셋, log(2) 및 근사 결과에 MAC 연산을 수행함으로써, 입력 x에 대한 로그 함수의 최종 근사값을 계산한다(S614). 여기서, log(2)는 기 설정된 값일 수 있다.The computing device calculates the final approximation value of the logarithmic function for the input x by performing MAC operation on the offset, log(2), and the approximation result (S614). Here, log(2) may be a preset value.

본 발명의 일 실시예에 따른 연산 장치는 단계 S612의 명령어를 제외하고, 입력을 전처리하는 데 1개의 명령어를 사용하고, 근사 결과를 후처리하는 데 1개의 명령어를 사용한다. 종래 연산 장치에 비해, 연산 장치는 적은 수의 명령어들로 로그 함수의 근사를 연산할 수 있다.The computing device according to an embodiment of the present invention uses one instruction to preprocess the input and one instruction to postprocess the approximation result, except for the instruction in step S612. Compared to conventional computing devices, the computing device can compute an approximation of a logarithmic function with a small number of instructions.

또한, 연산 장치는 함수의 변화량이 작은 도메인에서 함수 근사를 연산하므로, 함수의 변화량이 큰 도메인에서의 함수 근사보다 근사 오차를 줄일 수 있다. Additionally, since the computing device calculates function approximation in a domain where the change amount of the function is small, approximation errors can be reduced compared to function approximation in a domain where the change amount of the function is large.

도 7a 및 도 7b는 입력에 대한 제곱근 함수 및 전처리된 입력에 대한 제곱근 함수를 나타낸 도면이다.7A and 7B are diagrams showing the square root function for input and the square root function for preprocessed input.

도 7a를 참조하면, 입력 x에 대한 제곱근(square root; sqrt) 함수 y가 도시되어 있다.Referring to Figure 7A, the square root (sqrt) function y for input x is shown.

구간 S1 내지 구간 S7에서는 제곱근 함수 y의 변화량이 상대적으로 작기 때문에, 연산 장치가 구간별 직선 근사 또는 다항 근사를 적용하더라도, 참값과 근사값 간 근사 오차가 작다.Since the amount of change in the square root function y is relatively small in the section S 1 to the section S 7 , the approximation error between the true value and the approximated value is small even if the calculation device applies linear approximation or polynomial approximation for each section.

하지만, 구간 S0에서는 제곱근 함수 y의 변화량이 상대적으로 크기 때문에, 연산 장치가 구간별 직선 근사 또는 다항 근사를 적용하는 경우, 참값과 근사값 간 근사 오차가 크다.However, since the amount of change in the square root function y is relatively large in the section S 0 , when the calculation device applies linear approximation or polynomial approximation for each section, the approximation error between the true value and the approximated value is large.

근사 오차를 줄이기 위해, 연산 장치는 입력을 함수의 변화량이 큰 도메인에서 함수의 변화량이 적은 도메인으로 매핑한다. To reduce approximation error, the computing device maps the input from a domain with a large change in the function to a domain with a small change in the function.

도 7b를 참조하면, 입력 t에 대한 제곱근 함수 yt가 도시되어 있다. 입력 t는 입력 x가 매핑된 것이다. Referring to Figure 7b, the square root function y t for input t is shown. Input t is the mapped input x.

입력 t의 도메인 범위는 입력 x의 도메인 범위보다 좁다. 또한, 입력 t에 대한 함수 yt의 변화량은 입력 x에 대한 함수 y의 변화량보다 작다. 즉, 입력 x의 범위에서 제곱근 함수의 변화량보다 입력 t의 범위에서 제곱근 함수의 변화량이 적다.The domain range of input t is narrower than the domain range of input x. Additionally, the amount of change in function y t with respect to input t is smaller than the amount of change in function y with respect to input x. In other words, the amount of change in the square root function in the range of input t is less than the amount of change in the square root function in the range of input x.

입력 x가 함수 y의 변화량이 큰 구간인 S0 내 값이더라도, 전처리를 통해 함수의 변화량이 상대적으로 작은 t 도메인으로 될 수 있다. t 도메인에서 함수 근사를 적용하는 경우, x 도메인에서 함수 근사를 적용하는 경우보다 근사 오차가 작다.Even if the input When applying function approximation in the t domain, the approximation error is smaller than when applying function approximation in the x domain.

연산 장치는 t 도메인에서의 근사 결과를 다시 입력 x의 도메인으로 변환함으로써, 입력 x에 대한 함수 y의 근사값을 구할 수 있다.The computing device can obtain an approximation value of the function y for the input x by converting the approximation result in the t domain back to the domain of the input x.

이하에서는, 입력의 전처리, 전처리된 입력에 대한 함수의 근사, 및 근사 결과에 대한 후처리를 수행하는 데 이용되는 명령어들 및 실행 순서를 종래의 연산 장치와 비교하여 설명한다.Hereinafter, the instructions and execution order used to perform preprocessing of input, approximation of a function for the preprocessed input, and postprocessing of the approximation result will be described in comparison with a conventional computing device.

도 7c 및 도 7d는 제곱근 함수의 근사를 위한 종래의 명령어들과 본 발명의 일 실시예에 따른 명령어들을 비교하기 위한 도면이다.7C and 7D are diagrams for comparing conventional instructions for approximating a square root function and instructions according to an embodiment of the present invention.

종래의 연산 장치는 제곱근 함수를 근사하기 위해, 수학식 4를 이용한다.Conventional computing devices use Equation 4 to approximate the square root function.

수학식 4에서 k 및 n은 0 이상의 정수이다. n은 입력의 지수부에 해당한다.In Equation 4, k and n are integers greater than or equal to 0. n corresponds to the exponent part of the input.

수학식 4를 참조하면, 종래 연산 장치는 2를 밑으로 하고, 입력의 지수부를 지수로 가지는 제4 값을 계산한다. 종래 연산 장치는 입력의 가수부에 대한 제곱근 함수의 함수값을 계산한다. 종래 연산 장치는 제4 값과 가수부에 대한 제곱근 함수값을 곱함으로써, 입력에 대한 제곱근 함수의 함수값을 계산한다.Referring to Equation 4, the conventional arithmetic device calculates the fourth value with 2 as the base and the exponent of the input as the exponent. A conventional computing device calculates the function value of the square root function for the mantissa part of the input. A conventional computing device calculates the function value of the square root function for the input by multiplying the fourth value and the square root function value for the mantissa.

이때, 종래 연산 장치는 에 대해 구간별 근사를 적용할 수 있다. 종래 연산 장치는 제4 값 및 근사 결과의 곱셈을, 입력 x에 대한 제곱근 함수의 최종 근사값으로 계산한다.At this time, the conventional computing device is A sectional approximation can be applied to . A conventional computing device calculates the multiplication of the fourth value and the approximation result into the final approximation value of the square root function for the input x.

한편, 종래 연산 장치는 입력의 지수부가 홀수인지 짝수인지 여부에 따라 함수값을 달리 계산할 수 있다. 입력의 지수부가 짝수인 경우, 종래 연산 장치는 입력의 가수부에 대한 근사 결과를 구하고, 제4 값과 근사 결과의 곱셈을 입력 x에 대한 제곱근 함수의 근사값으로 계산한다. 반면 입력의 지수부가 홀수인 경우, 종래 연산 장치는 입력의 가수부에 2를 곱한 값에 대한 근사 결과를 구하고, 제4 값과 근사 결과의 곱셈을 입력 x에 대한 제곱근 함수의 근사값으로 계산한다.Meanwhile, a conventional computing device can calculate function values differently depending on whether the exponent part of the input is odd or even. When the exponent part of the input is an even number, the conventional computing device obtains an approximation result for the mantissa part of the input, and calculates the product of the fourth value and the approximation result as an approximation value of the square root function for the input x. On the other hand, when the exponent part of the input is an odd number, the conventional arithmetic device obtains an approximation result for the value of the mantissa part of the input multiplied by 2, and calculates the product of the fourth value and the approximation result as an approximation value of the square root function for the input x.

도 7c를 참조하면, 종래 연산 장치가 수학식 4에 따른 함수 근사를 실행하기 위한 명령어들이 도시되어 있다.Referring to FIG. 7C, instructions for a conventional computing device to perform function approximation according to Equation 4 are shown.

종래 연산 장치는 입력의 지수부를 추출한다(S700).A conventional computing device extracts the exponent part of the input (S700).

종래 연산 장치는 추출한 지수부를 바이어스로 치환한다(S702). A conventional computing device replaces the extracted exponent with a bias (S702).

종래 연산 장치는 입력의 지수부가 홀수인지 여부를 판단한다(S704). 종래 연산 장치가 입력의 지수부의 홀수 여부를 판단하기 위해, 2개의 명령어가 필요하다.The conventional arithmetic device determines whether the exponent part of the input is odd (S704). In order for a conventional computing device to determine whether the exponent of the input is odd, two instructions are required.

입력의 지수부가 홀수인 경우, 종래 연산 장치는 입력의 지수부를 1만큼 감소시킨다(S706).If the exponent of the input is an odd number, the conventional arithmetic device decreases the exponent of the input by 1 (S706).

또한, 종래 연산 장치는 지수부가 바이어스로 치환된 입력에 2를 곱한다(S708).Additionally, the conventional arithmetic device multiplies the input whose exponent part is replaced with a bias by 2 (S708).

종래 연산 장치는 제곱근 함수에 구간별 근사를 적용하여 전처리된 입력에 대한 근사 결과를 계산한다(S710).A conventional computing device calculates the approximation result for the preprocessed input by applying sectional approximation to the square root function (S710).

단계 S704에서 입력의 지수부가 짝수인 경우, 종래 연산 장치는 단계 S706 및 S708를 수행하지 않고, 곧바로 전처리된 입력에 대한 근사 결과를 계산한다.If the exponent part of the input is an even number in step S704, the conventional computing device does not perform steps S706 and S708 and immediately calculates the approximation result for the preprocessed input.

종래 연산 장치는 원 비트를 지수부의 반만큼 좌측 시프트하여 오프셋을 생성한다(S712).A conventional arithmetic device generates an offset by left-shifting the original bit by half of the exponent (S712).

원 비트의 시프트를 통해 생성된 오프셋은 INT 표현을 가진다.The offset created through shifting of one bit has an INT representation.

종래 연산 장치는 오프셋의 표현을 INT에서 FP로 변환한다(S714).A conventional arithmetic device converts the expression of the offset from INT to FP (S714).

종래 연산 장치는 근사 결과에 오프셋을 곱함으로써, 입력에 대한 제곱근 함수의 최종 근사값을 계산한다(S716).A conventional computing device calculates the final approximation value of the square root function for the input by multiplying the approximation result by an offset (S716).

종래 연산 장치는 단계 S710의 명령어를 제외하고, 입력을 전처리하는 데 7개 내지 9개의 명령어를 사용하고, 근사 결과를 후처리하는 데 4개의 명령어를 사용한다.Excluding the instruction in step S710, a conventional computing device uses 7 to 9 instructions to preprocess the input and 4 instructions to postprocess the approximation result.

이와 달리, 본 발명의 일 실시예에 따른 연산 장치는 수학식 4를 이용하여 제곱근 함수의 근사를 연산하되, 종래 연산 장치보다 적은 수의 명령어로 제곱근 함수의 근사값을 구할 수 있다.In contrast, the computing device according to an embodiment of the present invention calculates the approximation of the square root function using Equation 4, and can obtain the approximate value of the square root function with fewer instructions than a conventional computing device.

도 7d를 참조하면, 본 발명의 일 실시예에 따른 연산 장치가 수학식 4에 따른 함수 근사를 실행하기 위한 명령어들이 도시되어 있다. Referring to FIG. 7D, instructions for a computing device according to an embodiment of the present invention to perform function approximation according to Equation 4 are shown.

본 발명의 일 실시예에 따른 연산 장치는 입력의 지수부와 바이어스 간 차이값이 홀수인지 짝수인지 여부에 기초하여, 전처리된 입력 및 오프셋을 생성한다(S720).The computing device according to an embodiment of the present invention generates a preprocessed input and an offset based on whether the difference between the exponent part of the input and the bias is odd or even (S720).

입력의 지수부와 바이어스 간 차이가 짝수인 경우, 연산 장치는 입력의 지수부를 바이어스로 치환함으로써, 전처리된 입력을 생성한다. 연산 장치는 입력의 지수부와 바이어스 간 차이값을 1만큼 우측 시프트함으로써, 오프셋을 생성한다.If the difference between the exponent of the input and the bias is an even number, the computing device generates a preprocessed input by replacing the exponent of the input with the bias. The arithmetic unit generates an offset by right-shifting the difference between the exponent of the input and the bias by 1.

입력의 지수부와 바이어스 간 차이가 홀수인 경우, 연산 장치는 입력의 지수부를 바이어스에 1을 더한 값으로 치환함으로써, 전처리된 입력을 생성한다. 연산 장치는 입력의 지수부로부터, 바이어스에 1을 더한 값(바이어스+1)을 뺄셈하고, 뺄셈 결과를 1만큼 우측 시프트하여 오프셋을 생성한다.If the difference between the exponent of the input and the bias is an odd number, the computing device generates a preprocessed input by replacing the exponent of the input with the bias plus 1. The arithmetic unit subtracts the bias plus 1 (bias + 1) from the exponent part of the input, and right-shifts the subtraction result by 1 to generate an offset.

연산 장치는 제곱근 함수에 구간별 근사를 적용하여 전처리된 입력에 대한 근사 결과를 계산한다(S722).The computing device calculates the approximation result for the preprocessed input by applying sectional approximation to the square root function (S722).

연산 장치는 근사 결과의 지수부에 오프셋을 더함으로써, 입력에 대한 제곱근 함수의 최종 근사값을 계산한다(S724).The computing device calculates the final approximation value of the square root function for the input by adding an offset to the exponent of the approximation result (S724).

본 발명의 일 실시예에 따른 연산 장치는 단계 S722의 명령어를 제외하고, 입력을 전처리하는 데 1개의 명령어를 사용하고, 근사 결과를 후처리하는 데 1개의 명령어를 사용한다. 종래 연산 장치에 비해, 연산 장치는 적은 수의 명령어들로 제곱근 함수의 근사를 연산할 수 있다.The computing device according to an embodiment of the present invention uses one instruction to preprocess the input and one instruction to postprocess the approximation result, except for the instruction in step S722. Compared to conventional computing devices, the computing device can calculate the approximation of the square root function with a small number of instructions.

또한, 연산 장치는 함수의 변화량이 작은 도메인에서 함수 근사를 연산하므로, 함수의 변화량이 큰 도메인에서의 함수 근사보다 근사 오차를 줄일 수 있다. Additionally, since the computing device calculates function approximation in a domain where the change amount of the function is small, approximation errors can be reduced compared to function approximation in a domain where the change amount of the function is large.

도 8a 및 도 8b는 입력에 대한 제곱근의 역수 함수 및 전처리된 입력에 대한 제곱근의 역수 함수를 나타낸 도면이다.Figures 8a and 8b are diagrams showing the reciprocal square root function for the input and the reciprocal square root function for the preprocessed input.

도 8a를 참조하면, 입력 x에 대한 제곱근의 역수(reciprocal square root; rsqrt) 함수 y가 도시되어 있다.Referring to FIG. 8A, the reciprocal square root (rsqrt) function y for input x is shown.

구간 S1 내지 구간 S7에서는 제곱근의 역수 함수 y의 변화량이 상대적으로 작기 때문에, 연산 장치가 구간별 직선 근사 또는 다항 근사를 적용하더라도, 참값과 근사값 간 근사 오차가 작다.Since the amount of change in the square root reciprocal function y is relatively small in the section S 1 to section S 7 , the approximation error between the true value and the approximated value is small even if the calculation device applies linear approximation or polynomial approximation for each section.

하지만, 구간 S0에서는 제곱근의 역수 함수 y의 변화량이 상대적으로 크기 때문에, 연산 장치가 구간별 직선 근사 또는 다항 근사를 적용하는 경우, 참값과 근사값 간 근사 오차가 크다.However, in the interval S 0 , the amount of change in the square root reciprocal function y is relatively large, so when the calculation device applies linear approximation or polynomial approximation for each section, the approximation error between the true value and the approximated value is large.

근사 오차를 줄이기 위해, 연산 장치는 입력을 함수의 변화량이 큰 도메인에서 함수의 변화량이 적은 도메인으로 매핑한다. To reduce approximation error, the computing device maps the input from a domain with a large change in the function to a domain with a small change in the function.

도 8b를 참조하면, 입력 t에 대한 제곱근의 역수 함수 yt가 도시되어 있다. 입력 t는 입력 x가 매핑된 것이다. Referring to Figure 8b, the square root reciprocal function y t for the input t is shown. Input t is the mapped input x.

입력 t에 대한 함수 yt의 변화량은 입력 x에 대한 함수 y의 변화량보다 작다. 즉, 입력 x의 범위에서 제곱근의 역수 함수의 변화량보다 입력 t의 범위에서 제곱근의 역수 함수의 변화량이 적다.The amount of change in function y t for input t is smaller than the amount of change in function y for input x. In other words, the amount of change in the reciprocal square root function in the range of input t is less than the amount of change in the reciprocal square root function in the range of input x.

입력 x가 함수 y의 변화량이 큰 구간인 S0 내 값이더라도, 전처리를 통해 함수의 변화량이 상대적으로 작은 t 도메인으로 될 수 있다. t 도메인에서 함수 근사를 적용하는 경우, x 도메인에서 함수 근사를 적용하는 경우보다 근사 오차가 작다.Even if the input When applying function approximation in the t domain, the approximation error is smaller than when applying function approximation in the x domain.

연산 장치는 t 도메인에서의 근사 결과를 다시 입력 x의 도메인으로 변환함으로써, 입력 x에 대한 함수 y의 근사값을 구할 수 있다.The computing device can obtain an approximation value of the function y for the input x by converting the approximation result in the t domain back to the domain of the input x.

이하에서는, 입력의 전처리, 전처리된 입력에 대한 함수의 근사, 및 근사 결과에 대한 후처리를 수행하는 데 이용되는 명령어들 및 실행 순서를 종래의 연산 장치와 비교하여 설명한다.Hereinafter, the instructions and execution order used to perform preprocessing of input, approximation of a function for the preprocessed input, and postprocessing of the approximation result will be described in comparison with a conventional computing device.

도 8c 및 도 8d는 제곱근의 역수 함수의 근사를 위한 종래의 명령어들과 본 발명의 일 실시예에 따른 명령어들을 비교하기 위한 도면이다.FIGS. 8C and 8D are diagrams for comparing conventional instructions for approximating the reciprocal square root function with instructions according to an embodiment of the present invention.

종래의 연산 장치는 제곱근의 역수 함수를 근사하기 위해, 수학식 5를 이용한다.Conventional computing devices use Equation 5 to approximate the reciprocal function of the square root.

수학식 5에서 k 및 n은 0 이상의 정수이다. n은 입력의 지수부에 해당한다.In Equation 5, k and n are integers greater than or equal to 0. n corresponds to the exponent part of the input.

수학식 5를 참조하면, 종래 연산 장치는 2를 밑으로 하고, 입력의 지수부에 음수를 취한 값을 지수로 가지는 제5 값을 계산한다. 종래 연산 장치는 입력의 가수부에 대한 제곱근의 역수 함수의 함수값을 계산한다. 종래 연산 장치는 제5 값과 가수부에 대한 제곱근의 역수 함수값을 곱함으로써, 입력에 대한 제곱근의 역수 함수의 함수값을 계산한다.Referring to Equation 5, the conventional computing device calculates the fifth value with 2 as the base and a negative number taken as the exponent of the input. A conventional arithmetic device calculates the function value of the reciprocal of the square root of the mantissa of the input. A conventional arithmetic device calculates the function value of the reciprocal square root function for the input by multiplying the fifth value and the reciprocal square root function value for the mantissa part.

이때, 종래 연산 장치는 에 대해 구간별 근사를 적용할 수 있다. 종래 연산 장치는 제5 값 및 근사 결과의 곱셈을, 입력 x에 대한 제곱근의 역수 함수의 최종 근사값으로 계산한다.At this time, the conventional computing device is A sectional approximation can be applied to . A conventional computing device calculates the multiplication of the fifth value and the approximation result into a final approximation value of the reciprocal square root function for the input x.

한편, 종래 연산 장치는 입력의 지수부가 홀수인지 짝수인지 여부에 따라 함수값을 달리 계산할 수 있다. 입력의 지수부가 짝수인 경우, 종래 연산 장치는 입력의 가수부에 대한 근사 결과를 구하고, 제5 값과 근사 결과의 곱셈을 입력 x에 대한 제곱근의 역수 함수의 근사값으로 계산한다. 반면 입력의 지수부가 홀수인 경우, 종래 연산 장치는 입력의 가수부에 2를 곱한 값에 대한 근사 결과를 구하고, 제5 값과 근사 결과의 곱셈을 입력 x에 대한 제곱근의 역수 함수의 근사값으로 계산한다.Meanwhile, a conventional computing device can calculate function values differently depending on whether the exponent part of the input is odd or even. When the exponent part of the input is an even number, the conventional computing device obtains an approximation result for the mantissa part of the input, and calculates the product of the fifth value and the approximation result as an approximation of the reciprocal square root function for the input x. On the other hand, when the exponent part of the input is an odd number, the conventional calculation device obtains an approximation result for the value of the mantissa part of the input multiplied by 2, and calculates the product of the fifth value and the approximation result as an approximation of the reciprocal square root function for the input x do.

도 8c를 참조하면, 종래 연산 장치가 수학식 5에 따른 함수 근사를 실행하기 위한 명령어들이 도시되어 있다.Referring to FIG. 8C, instructions for a conventional computing device to perform function approximation according to Equation 5 are shown.

단계 S800 내지 S808, 및 단계 S812 내지 S814는 단계 S700 내지 S708, 및 단계 S712 내지 S714에 대응되므로, 자세한 설명은 생략한다.Since steps S800 to S808 and steps S812 to S814 correspond to steps S700 to S708 and steps S712 to S714, detailed descriptions are omitted.

단계 S810에서 종래 연산 장치는 제곱근의 역수 함수에 구간별 근사를 적용하여 전처리된 입력에 대한 근사 결과를 계산한다(S810).In step S810, the conventional computing device calculates the approximation result for the preprocessed input by applying sectional approximation to the reciprocal square root function (S810).

종래 연산 장치는 근사 결과에 오프셋을 나눔으로써, 입력에 대한 제곱근의 역수 함수의 최종 근사값을 계산한다(S816).The conventional computing device calculates the final approximation value of the reciprocal square root function for the input by dividing the offset by the approximation result (S816).

종래 연산 장치는 단계 S810의 명령어를 제외하고, 입력을 전처리하는 데 7개 내지 9개의 명령어를 사용하고, 근사 결과를 후처리하는 데 4개의 명령어를 사용한다.Excluding the instruction in step S810, a conventional computing device uses 7 to 9 instructions to preprocess the input and 4 instructions to postprocess the approximation result.

이와 달리, 본 발명의 일 실시예에 따른 연산 장치는 수학식 5를 이용하여 제곱근의 역수 함수의 근사를 연산하되, 종래 연산 장치보다 적은 수의 명령어로 제곱근의 역수 함수의 근사값을 구할 수 있다.In contrast, the computing device according to an embodiment of the present invention calculates the approximation of the reciprocal square root function using Equation 5, and can obtain the approximate value of the reciprocal square root function with fewer instructions than a conventional computing device.

도 8d를 참조하면, 본 발명의 일 실시예에 따른 연산 장치가 수학식 5에 따른 함수 근사를 실행하기 위한 명령어들이 도시되어 있다. Referring to FIG. 8D, instructions for a computing device according to an embodiment of the present invention to perform function approximation according to Equation 5 are shown.

단계 S820은 단계 S720에 대응되고, 단계 S822는 단계 810에 대응되므로, 자세한 설명은 생략한다.Since step S820 corresponds to step S720 and step S822 corresponds to step 810, detailed description is omitted.

연산 장치는 근사 결과의 지수부에서 오프셋을 뺄셈으로써, 입력에 대한 제곱근의 역수 함수의 최종 근사값을 계산한다(S824).The arithmetic unit calculates the final approximation value of the reciprocal square root function for the input by subtracting the offset from the exponent of the approximation result (S824).

본 발명의 일 실시예에 따른 연산 장치는 단계 S822의 명령어를 제외하고, 입력을 전처리하는 데 1개의 명령어를 사용하고, 근사 결과를 후처리하는 데 1개의 명령어를 사용한다. 종래 연산 장치에 비해, 연산 장치는 적은 수의 명령어들로 제곱근의 역수 함수의 근사를 연산할 수 있다.The computing device according to an embodiment of the present invention uses one instruction to preprocess the input and one instruction to postprocess the approximation result, except for the instruction in step S822. Compared to conventional computing devices, the computing device can calculate the approximation of the inverse square root function with a small number of instructions.

또한, 연산 장치는 함수의 변화량이 작은 도메인에서 함수 근사를 연산하므로, 함수의 변화량이 큰 도메인에서의 함수 근사보다 근사 오차를 줄일 수 있다. Additionally, since the computing device calculates function approximation in a domain where the change amount of the function is small, approximation errors can be reduced compared to function approximation in a domain where the change amount of the function is large.

도 9a 및 도 9b는 입력에 대한 역수 함수 및 전처리된 입력에 대한 역수 함수를 나타낸 도면이다.9A and 9B are diagrams showing a reciprocal function for an input and a reciprocal function for a preprocessed input.

도 9a를 참조하면, 입력 x에 대한 역수(reciprocal) 함수 y가 도시되어 있다.Referring to Figure 9A, the reciprocal function y for input x is shown.

입력 x에 대한 역수 함수 y의 근사 오차를 줄이기 위해, 연산 장치는 구간별 근사를 이용할 수 있다. To reduce the approximation error of the reciprocal function y for the input x, the computing device may use piecewise approximation.

구간 S1 내지 구간 S7에서는 역수 함수 y의 변화량이 상대적으로 작기 때문에, 연산 장치가 구간별 직선 근사 또는 다항 근사를 적용하더라도, 참값과 근사값 간 근사 오차가 작다.Since the amount of change in the reciprocal function y is relatively small in the section S 1 to the section S 7 , the approximation error between the true value and the approximated value is small even if the calculation device applies linear approximation or polynomial approximation for each section.

하지만, 구간 S0에서는 역수 함수 y의 변화량이 상대적으로 크기 때문에, 연산 장치가 구간별 직선 근사 또는 다항 근사를 적용하는 경우, 참값과 근사값 간 근사 오차가 크다.However, since the amount of change in the reciprocal function y is relatively large in the section S 0 , when the computing device applies linear approximation or polynomial approximation for each section, the approximation error between the true value and the approximated value is large.

근사 오차를 줄이기 위해, 연산 장치는 입력을 함수의 변화량이 큰 도메인에서 함수의 변화량이 적은 도메인으로 매핑한다. To reduce approximation error, the computing device maps the input from a domain with a large change in the function to a domain with a small change in the function.

도 9b를 참조하면, 입력 t에 대한 역수 함수 yt가 도시되어 있다. 입력 t는 입력 x가 매핑된 것이다. Referring to Figure 9b, the reciprocal function y t for input t is shown. Input t is the mapped input x.

입력 t에 대한 함수 yt의 변화량은 입력 x에 대한 함수 y의 변화량보다 작다. 즉, 입력 x의 범위에서 역수 함수의 변화량보다 입력 t의 범위에서 역수 함수의 변화량이 적다.The amount of change in function y t for input t is smaller than the amount of change in function y for input x. In other words, the amount of change in the reciprocal function in the range of input t is less than the amount of change in the reciprocal function in the range of input x.

입력 x가 함수 y의 변화량이 큰 구간인 S0 내 값이더라도, 전처리를 통해 함수의 변화량이 상대적으로 작은 t 도메인으로 될 수 있다. t 도메인에서 함수 근사를 적용하는 경우, x 도메인에서 함수 근사를 적용하는 경우보다 근사 오차가 작다.Even if the input When applying function approximation in the t domain, the approximation error is smaller than when applying function approximation in the x domain.

연산 장치는 t 도메인에서의 근사 결과를 다시 입력 x의 도메인으로 변환함으로써, 입력 x에 대한 함수 y의 근사값을 구할 수 있다.The computing device can obtain an approximation value of the function y for the input x by converting the approximation result in the t domain back to the domain of the input x.

이하에서는, 입력의 전처리, 전처리된 입력에 대한 함수의 근사, 및 근사 결과에 대한 후처리를 수행하는 데 이용되는 명령어들 및 실행 순서를 종래의 연산 장치와 비교하여 설명한다.Hereinafter, the instructions and execution order used to perform preprocessing of input, approximation of a function for the preprocessed input, and postprocessing of the approximation result will be described in comparison with a conventional computing device.

도 9c 및 도 9d는 역수 함수의 근사를 위한 종래의 명령어들과 본 발명의 일 실시예에 따른 명령어들을 비교하기 위한 도면이다.9C and 9D are diagrams for comparing conventional instructions for approximating a reciprocal function and instructions according to an embodiment of the present invention.

종래의 연산 장치는 역수 함수를 근사하기 위해, 수학식 6을 이용한다.Conventional computing devices use Equation 6 to approximate the reciprocal function.

수학식 6을 참조하면, 종래 연산 장치는 2를 밑으로 하고, 입력의 지수부에 음수를 취한 값을 지수로 가지는 제6 값을 계산한다. 종래 연산 장치는 입력의 가수부에 대한 역수 함수의 함수값을 계산한다. 종래 연산 장치는 제6 값과 가수부에 대한 역수 함수값을 곱함으로써, 입력에 대한 역수 함수의 함수값을 계산한다.Referring to Equation 6, the conventional computing device calculates the sixth value with 2 as the base and a negative number taken as the exponent of the input. A conventional arithmetic device calculates the function value of the reciprocal function for the mantissa part of the input. A conventional arithmetic device calculates the function value of the reciprocal function for the input by multiplying the sixth value and the reciprocal function value for the mantissa part.

이때, 종래 연산 장치는 가수부의 역수 함수값에 대해 구간별 근사를 적용할 수 있다. 종래 연산 장치는 제6 값 및 근사 결과의 곱셈을, 입력 x에 대한 역수 함수의 최종 근사값으로 계산한다.At this time, the conventional arithmetic device can apply section-by-section approximation to the reciprocal function value of the mantissa. A conventional computing device calculates the multiplication of the sixth value and the approximation result to the final approximation value of the reciprocal function for the input x.

도 8c를 참조하면, 종래 연산 장치가 수학식 6에 따른 함수 근사를 실행하기 위한 명령어들이 도시되어 있다.Referring to FIG. 8C, instructions for a conventional computing device to perform function approximation according to Equation 6 are shown.

종래 연산 장치는 입력의 지수부를 추출한다(S900).A conventional computing device extracts the exponent part of the input (S900).

종래 연산 장치는 추출한 지수부를 바이어스로 치환한다(S902). A conventional computing device replaces the extracted exponent with a bias (S902).

종래 연산 장치는 역수 함수에 구간별 근사를 적용하여 전처리된 입력에 대한 근사 결과를 계산한다(S904).A conventional computing device calculates the approximation result for the preprocessed input by applying section-by-section approximation to the reciprocal function (S904).

종래 연산 장치는 원 비트를 지수부만큼 좌측 시프트하여 오프셋을 생성한다(S906).A conventional arithmetic device generates an offset by shifting the original bit to the left by the exponent (S906).

종래 연산 장치는 오프셋의 표현을 INT에서 FP로 변환한다(S908).A conventional computing device converts the expression of the offset from INT to FP (S908).

종래 연산 장치는 근사 결과를 오프셋으로 나눔으로써, 입력에 대한 역수 함수의 최종 근사값을 계산한다(S910).A conventional computing device calculates the final approximation value of the reciprocal function for the input by dividing the approximation result by the offset (S910).

종래 연산 장치는 단계 S904의 명령어를 제외하고, 입력을 전처리하는 데 5개의 명령어를 사용하고, 근사 결과를 후처리하는 데 3개의 명령어를 사용한다.Excluding the instruction in step S904, the conventional computing device uses five instructions to preprocess the input and three instructions to postprocess the approximation result.

이와 달리, 본 발명의 일 실시예에 따른 연산 장치는 수학식 6을 이용하여 역수 함수의 근사를 연산하되, 종래 연산 장치보다 적은 수의 명령어로 역수 함수의 근사값을 구할 수 있다.In contrast, the computing device according to an embodiment of the present invention calculates the approximation of the reciprocal function using Equation 6, and can obtain the approximate value of the reciprocal function with fewer instructions than a conventional computing device.

본 발명의 일 실시예에 따른 연산 장치는 입력의 지수부를 바이어스로 치환하여 입력을 전처리하고, 입력의 지수부와 바이어스 간 차이를 오프셋으로 생성한다(S920).The computing device according to an embodiment of the present invention preprocesses the input by replacing the exponent part of the input with a bias, and generates the difference between the exponent part of the input and the bias as an offset (S920).

연산 장치는 역수 함수에 구간별 근사를 적용하여 전처리된 입력에 대한 근사 결과를 계산한다(S922).The computing device calculates the approximation result for the preprocessed input by applying section-by-section approximation to the reciprocal function (S922).

연산 장치는 근사 결과의 지수부에서 오프셋을 뺄셈으로써, 입력에 대한 역수 함수의 최종 근사값을 계산한다(S924).The computing device calculates the final approximation value of the reciprocal function for the input by subtracting the offset from the exponent of the approximation result (S924).

본 발명의 일 실시예에 따른 연산 장치는 단계 S922의 명령어를 제외하고, 입력을 전처리하는 데 1개의 명령어를 사용하고, 근사 결과를 후처리하는 데 1개의 명령어를 사용한다. 종래 연산 장치에 비해, 연산 장치는 적은 수의 명령어들로 역수 함수의 근사를 연산할 수 있다.The computing device according to an embodiment of the present invention uses one instruction to preprocess the input and one instruction to postprocess the approximation result, except for the instruction in step S922. Compared to conventional computing devices, the computing device can calculate the approximation of the reciprocal function with a small number of instructions.

또한, 연산 장치는 함수의 변화량이 작은 도메인에서 함수 근사를 연산하므로, 함수의 변화량이 큰 도메인에서의 함수 근사보다 근사 오차를 줄일 수 있다. Additionally, since the computing device calculates function approximation in a domain where the change amount of the function is small, approximation errors can be reduced compared to function approximation in a domain where the change amount of the function is large.

표 1은 종래의 명령어들의 수와 본 발명의 일 실시예에 따른 명령어들의 수를 비교하기 위한 것이다.Table 1 is for comparing the number of conventional instructions and the number of instructions according to an embodiment of the present invention.

함수function 종래 방법에 따른 명령어 수Number of instructions according to the conventional method 본 개시에 따른 명령어 수Number of instructions according to the present disclosure 전처리Pretreatment 후처리After treatment 합계Sum 전처리Pretreatment 후처리After treatment 합계Sum 지수(exp)exponent (exp) 44 33 7(100%)7(100%) 22 1One 3(43%)3(43%) 로그(log)log 55 1One 6(100%)6(100%) 1One 1One 2(33%)2(33%) 제곱근(sqrt)square root (sqrt) 99 44 13(100%)13(100%) 1One 1One 2(15%)2(15%) 제곱근의 역수(rsqrt)Reciprocal of square root (rsqrt) 99 33 12(100%)12(100%) 1One 1One 2(17%)2(17%) 역수(recip)reciprocal 55 33 8(100%)8(100%) 1One 1One 2(25%)2(25%)

표 1을 참조하면, 본 발명의 일 실시예에 따른 연산 방법에서 사용되는 명령어들의 수가 종래 방법에 따른 명령어의 수보다 적다. 이에 따라, 본 발명의 일 실시예에 따른 연산 방법은 종래 방법에 비해 오버헤드(overhead)를 15 ~ 43% 수준으로 줄일 수 있다.도 3에서는 과정 S300 내지 과정 S304를 순차적으로 실행하는 것으로 기재하고 있으나, 이는 본 발명의 일 실시예의 기술 사상을 예시적으로 설명한 것에 불과한 것이다. 다시 말해, 본 발명의 일 실시예가 속하는 기술 분야에서 통상의 지식을 가진 자라면 본 발명의 일 실시예의 본질적인 특성에서 벗어나지 않는 범위에서 도 3에 기재된 순서를 변경하여 실행하거나 과정 S300 내지 과정 S304 중 하나 이상의 과정을 병렬적으로 실행하는 것으로 다양하게 수정 및 변형하여 적용 가능할 것이므로, 도 3은 시계열적인 순서로 한정되는 것은 아니다.Referring to Table 1, the number of instructions used in the operation method according to an embodiment of the present invention is less than the number of instructions according to the conventional method. Accordingly, the calculation method according to an embodiment of the present invention can reduce overhead to 15 to 43% compared to the conventional method. In Figure 3, steps S300 to S304 are described as being sequentially executed. However, this is merely an exemplary description of the technical idea of an embodiment of the present invention. In other words, a person of ordinary skill in the technical field to which an embodiment of the present invention pertains can change the sequence shown in FIG. 3 and perform one of processes S300 to S304 without departing from the essential characteristics of an embodiment of the present invention. Since the above processes can be applied in various modifications and variations by executing them in parallel, FIG. 3 is not limited to a time series order.

한편, 도 3에 도시된 과정들은 컴퓨터로 읽을 수 있는 기록매체에 컴퓨터가 읽을 수 있는 코드로서 구현하는 것이 가능하다. 컴퓨터가 읽을 수 있는 기록매체는 컴퓨터 시스템에 의하여 읽혀질 수 있는 데이터가 저장되는 모든 종류의 기록장치를 포함한다. 즉, 이러한 컴퓨터가 읽을 수 있는 기록매체는 ROM, RAM, CD-ROM, 자기 테이프, 플로피디스크, 광 데이터 저장장치 등의 비일시적인(non-transitory) 매체를 포함한다. 또한 컴퓨터가 읽을 수 있는 기록매체는 네트워크로 연결된 컴퓨터 시스템에 분산되어 분산방식으로 컴퓨터가 읽을 수 있는 코드가 저장되고 실행될 수 있다.Meanwhile, the processes shown in FIG. 3 can be implemented as computer-readable codes on a computer-readable recording medium. Computer-readable recording media include all types of recording devices that store data that can be read by a computer system. In other words, such computer-readable recording media include non-transitory media such as ROM, RAM, CD-ROM, magnetic tape, floppy disk, and optical data storage devices. Additionally, computer-readable recording media can be distributed across networked computer systems so that computer-readable code can be stored and executed in a distributed manner.

또한, 본 발명의 구성 요소들은 메모리, 프로세서, 논리 회로, 룩-업 테이블(look-up table) 등과 같은 집적 회로 구조를 사용할 수 있다. 이러한 집적 회로 구조는 하나 이상의 마이크로 프로세서 또는 다른 제어 장치의 제어를 통해 본 명세서에 기술 된 각각의 기능을 실행한다. 또한, 본 발명의 구성 요소들은 특정 논리 기능을 수행하기 위한 하나 이상의 실행 가능한 명령을 포함하고 하나 이상의 마이크로 프로세서 또는 다른 제어 장치에 의해 실행되는 프로그램 또는 코드의 일부에 의해 구체적으로 구현될 수 있다. 또한, 본 발명의 구성 요소들은 각각의 기능을 수행하는 중앙 처리 장치(CPU), 마이크로 프로세서 등을 포함하거나 이에 의해 구현될 수 있다. 또한, 본 발명의 구성 요소들은 하나 이상의 프로세서에 의해 실행되는 명령어들을 하나 이상의 메모리에 저장할 수 있다.Additionally, the components of the present invention may use integrated circuit structures such as memory, processor, logic circuit, look-up table, etc. These integrated circuit structures execute each function described herein through control of one or more microprocessors or other control devices. Additionally, the components of the present invention may be specifically implemented by a program or portion of code that includes one or more executable instructions for performing specific logical functions and is executed by one or more microprocessors or other control devices. Additionally, the components of the present invention may include or be implemented by a central processing unit (CPU), a microprocessor, etc. that perform their respective functions. Additionally, the components of the present invention may store instructions executed by one or more processors in one or more memories.

이상의 설명은 본 실시예의 기술 사상을 예시적으로 설명한 것에 불과한 것으로서, 본 실시예가 속하는 기술 분야에서 통상의 지식을 가진 자라면 본 실시예의 본질적인 특성에서 벗어나지 않는 범위에서 다양한 수정 및 변형이 가능할 것이다. 따라서, 본 실시예들은 본 실시예의 기술 사상을 한정하기 위한 것이 아니라 설명하기 위한 것이고, 이러한 실시예에 의하여 본 실시예의 기술 사상의 범위가 한정되는 것은 아니다. 본 실시예의 보호 범위는 아래의 청구범위에 의하여 해석되어야 하며, 그와 동등한 범위 내에 있는 모든 기술 사상은 본 실시예의 권리범위에 포함되는 것으로 해석되어야 할 것이다.The above description is merely an illustrative explanation of the technical idea of the present embodiment, and those skilled in the art will be able to make various modifications and variations without departing from the essential characteristics of the present embodiment. Accordingly, the present embodiments are not intended to limit the technical idea of the present embodiment, but rather to explain it, and the scope of the technical idea of the present embodiment is not limited by these examples. The scope of protection of this embodiment should be interpreted in accordance with the claims below, and all technical ideas within the equivalent scope should be interpreted as being included in the scope of rights of this embodiment.

20: 연산 시스템 200: 데이터 메모리
210: 프로그램 메모리 220: 프로세서
20: operation system 200: data memory
210: program memory 220: processor

Claims (14)

부동 소수점으로 표현되는 입력에 대한 함수의 근사값을 계산하기 위한 컴퓨터 구현 방법에 있어서
입력의 지수부를 기 설정된 값으로 치환함으로써 전처리된 입력을 생성하는 단계;
상기 입력의 지수부의 치환에 따른 오프셋(offset)을 생성하는 단계;
상기 전처리된 입력에 대해 함수의 근사 결과를 계산하는 단계; 및
상기 오프셋을 이용하여 상기 근사 결과를 후처리함으로써, 상기 입력에 대한 상기 함수의 근사값을 계산하는 단계
를 포함하되,
상기 전처리된 입력의 위치에서 상기 함수의 변화량이 상기 입력의 위치에서 상기 함수의 변화량보다 적은 방법.
In a computer implementation method for calculating an approximation of a function for an input expressed in floating point numbers
generating a preprocessed input by replacing the exponent part of the input with a preset value;
generating an offset according to replacement of the exponent part of the input;
calculating an approximation result of a function for the preprocessed input; and
Calculating an approximation of the function for the input by post-processing the approximation result using the offset.
Including,
A method in which the amount of change in the function at the location of the preprocessed input is less than the amount of change in the function at the location of the input.
제1항에 있어서,
상기 전처리된 입력을 생성하는 단계는,
상기 입력의 지수부를 바이어스(bias)로 치환함으로써 상기 전처리된 입력을 생성하는 단계를 포함하는 방법.
According to paragraph 1,
The step of generating the preprocessed input is,
A method comprising generating the preprocessed input by replacing exponents of the input with a bias.
제1항에 있어서,
상기 오프셋을 생성하는 단계는,
상기 입력의 지수부와 상기 기 설정된 값 간 차이에 기초하여 상기 오프셋을 생성하는 단계를 포함하는 방법.
According to paragraph 1,
The step of generating the offset is,
A method comprising generating the offset based on a difference between an exponent of the input and the preset value.
제1항에 있어서,
상기 오프셋을 생성하는 단계는,
상기 입력의 지수부와 상기 기 설정된 값 간 차이만큼 원 비트를 시프트(shift)하여 상기 오프셋을 생성하는 단계를 포함하는 방법.
According to paragraph 1,
The step of generating the offset is,
A method comprising generating the offset by shifting an original bit by a difference between the exponent of the input and the preset value.
제1항에 있어서,
상기 전처리된 입력을 생성하는 단계는,
상기 입력의 지수부와 바이어스 간 차이값이 홀수인지 짝수인지 여부에 따라, 상기 입력의 지수부를 다른 값으로 치환하는 단계를 포함하는 방법.
According to paragraph 1,
The step of generating the preprocessed input is,
A method comprising replacing the exponent of the input with a different value depending on whether the difference between the exponent of the input and the bias is odd or even.
제5항에 있어서,
상기 치환하는 단계는,
상기 차이값이 짝수인 경우, 상기 입력의 지수부를 바이어스로 치환함으로써 상기 전처리된 입력을 생성하는 단계를 포함하고,
상기 오프셋을 생성하는 단계는,
상기 입력의 지수부와 상기 바이어스 간 차이에 비트 시프트를 수행함으로써 상기 오프셋을 생성하는 단계를 포함하는 방법.
According to clause 5,
The substitution step is,
If the difference value is an even number, generating the preprocessed input by replacing the exponent of the input with a bias,
The step of generating the offset is,
generating the offset by performing a bit shift on the difference between the exponent of the input and the bias.
제5항에 있어서,
상기 치환하는 단계는,
상기 차이값이 홀수인 경우, 상기 입력의 지수부를 바이어스와 홀수의 합으로 치환함으로써 상기 전처리된 입력을 생성하는 단계를 포함하고,
상기 오프셋을 생성하는 단계는,
상기 입력의 지수부와 상기 합 간 차이에 비트 시프트를 수행함으로써 상기 오프셋을 생성하는 단계를 포함하는 방법.
According to clause 5,
The substitution step is,
When the difference value is an odd number, generating the preprocessed input by replacing the exponent part of the input with the sum of a bias and an odd number,
The step of generating the offset is,
Generating the offset by performing a bit shift on the difference between the exponent of the input and the sum.
제1항에 있어서,
상기 함수의 근사값을 계산하는 단계,
상기 근사 결과의 지수부와 상기 오프셋의 합에 기초하여, 상기 입력에 대한 상기 함수의 근사값을 계산하는 단계를 포함하는 방법.
According to paragraph 1,
calculating an approximation of the function,
Computing an approximation of the function for the input based on a sum of the offset and an exponent of the approximation result.
제1항에 있어서,
상기 함수의 근사값을 계산하는 단계는,
상기 근사 결과의 지수부와 상기 오프셋의 차이에 기초하여, 상기 입력에 대한 상기 함수의 근사값을 계산하는 단계를 포함하는 방법.
According to paragraph 1,
The step of calculating the approximate value of the function is,
Computing an approximation of the function for the input based on a difference between the exponent of the approximation result and the offset.
제1항에 있어서,
상기 함수의 근사값을 계산하는 단계는,
상기 입력에 대한 상기 함수의 근사값이 부동 소수점 체계의 표현 범위를 벗어나는 경우, 상기 근사값을 제로(zero) 또는 무한대(infinity) 중 어느 하나로 설정하는 단계를 포함하는 방법.
According to paragraph 1,
The step of calculating the approximate value of the function is,
If the approximation of the function for the input is outside the representation range of the floating point system, setting the approximation to either zero or infinity.
제1항에 있어서,
상기 입력의 전처리 전에 상기 입력에 기 설정된 로그값을 곱합으로써, 상기 입력을 조정하는 단계를 더 포함하고,
상기 함수의 근사 결과를 계산하는 단계는,
상기 전처리된 입력에 대해 상기 기 설정된 로그값과 연관된 지수함수의 근사 결과를 계산하는 단계를 포함하는 방법.
According to paragraph 1,
Further comprising adjusting the input by multiplying the input by a preset logarithmic value before preprocessing the input,
The step of calculating the approximation result of the function is,
A method comprising calculating an approximation result of an exponential function associated with the preset logarithmic value for the preprocessed input.
제1항에 있어서,
상기 함수의 근사값을 계산하는 단계는,
상기 오프셋, 기 설정된 로그값 및 상기 근사 결과에 곱셈 누적(Multiply Accumulate; MAC) 연산을 수행함으로써, 상기 입력에 대한 상기 함수의 근사값을 계산하는 단계를 포함하는 방법.
According to paragraph 1,
The step of calculating the approximate value of the function is,
A method comprising calculating an approximation value of the function for the input by performing a Multiply Accumulate (MAC) operation on the offset, a preset logarithmic value, and the approximation result.
명령어들을 저장하는 메모리; 및
상기 명령어들을 실행하는 프로세서를 포함하며,
상기 프로세서는,
입력의 지수부를 기 설정된 값으로 치환함으로써 전처리된 입력을 생성하고, 상기 입력의 지수부의 치환에 따른 오프셋(offset)을 생성하고,
상기 전처리된 입력에 대해 함수의 근사 결과를 계산하고,
상기 오프셋을 이용하여 상기 근사 결과를 후처리함으로써, 상기 입력에 대한 함수의 근사값을 계산하되,
상기 전처리된 입력의 위치에서 상기 함수의 변화량이 상기 입력의 위치에서 상기 함수의 변화량보다 적은, 연산 장치.
Memory for storing instructions; and
It includes a processor that executes the instructions,
The processor,
Generate a preprocessed input by replacing the exponent part of the input with a preset value, and generate an offset according to the substitution of the exponent part of the input,
Calculate the approximation result of the function for the preprocessed input,
By post-processing the approximation result using the offset, an approximation value of the function for the input is calculated,
A computing device, wherein the amount of change in the function at the location of the preprocessed input is less than the amount of change in the function at the location of the input.
제1항 내지 제12항 중 어느 한 항의 방법을 실행하기 위한 컴퓨터 프로그램을 기록한 컴퓨터로 판독 가능한 기록매체.A computer-readable recording medium recording a computer program for executing the method of any one of claims 1 to 12.
KR1020210100619A 2021-07-30 2021-07-30 Device and Method for Calculating Function Approximation in Floating Point KR102670314B1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
KR1020210100619A KR102670314B1 (en) 2021-07-30 2021-07-30 Device and Method for Calculating Function Approximation in Floating Point
PCT/KR2022/011592 WO2023008984A1 (en) 2021-07-30 2022-08-04 Method and device for computing function approximation in floating point representation

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
KR1020210100619A KR102670314B1 (en) 2021-07-30 2021-07-30 Device and Method for Calculating Function Approximation in Floating Point

Publications (2)

Publication Number Publication Date
KR20230018742A KR20230018742A (en) 2023-02-07
KR102670314B1 true KR102670314B1 (en) 2024-05-29

Family

ID=85087121

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020210100619A KR102670314B1 (en) 2021-07-30 2021-07-30 Device and Method for Calculating Function Approximation in Floating Point

Country Status (2)

Country Link
KR (1) KR102670314B1 (en)
WO (1) WO2023008984A1 (en)

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5224064A (en) * 1991-07-11 1993-06-29 Honeywell Inc. Transcendental function approximation apparatus and method
US6163791A (en) * 1998-02-02 2000-12-19 International Business Machines Corporation High accuracy estimates of elementary functions
JP3845636B2 (en) * 2004-01-21 2006-11-15 株式会社東芝 Function approximation calculator
JP4388980B2 (en) * 2005-12-02 2009-12-24 富士通株式会社 Arithmetic apparatus and method for performing floating-point division or square root operation
JP6770777B2 (en) * 2015-04-07 2020-10-21 ビバンテ コーポレーション Systems and methods for calculating mathematical functions
US11775805B2 (en) * 2018-06-29 2023-10-03 Intel Coroporation Deep neural network architecture using piecewise linear approximation

Also Published As

Publication number Publication date
WO2023008984A1 (en) 2023-02-02
KR20230018742A (en) 2023-02-07

Similar Documents

Publication Publication Date Title
US9483232B2 (en) Data processing apparatus and method for multiplying floating point operands
GB2586559A (en) Enhanced low precision binary floating-point formatting
WO2002023326A1 (en) Handler for floating-point denormalized numbers
US8751555B2 (en) Rounding unit for decimal floating-point division
CN110569020A (en) Transcendental function evaluation
CN111695671A (en) Method and device for training neural network and electronic equipment
CN112241291A (en) Floating point unit for exponential function implementation
KR102481418B1 (en) Method and apparatus for fused multiply-add
US6182100B1 (en) Method and system for performing a logarithmic estimation within a data processing system
Chen et al. Approximate softmax functions for energy-efficient deep neural networks
JP2022512211A (en) Image processing methods, equipment, in-vehicle computing platforms, electronic devices and systems
WO2018196750A1 (en) Device for processing multiplication and addition operations and method for processing multiplication and addition operations
KR102670314B1 (en) Device and Method for Calculating Function Approximation in Floating Point
CN113805974A (en) Application-based data type selection
KR20060103920A (en) Floating-point operations using scaled integers
CN111831257A (en) Implementation method and device for calculating sine or cosine function
CN116166217A (en) System and method for performing floating point operations
CN114860193A (en) Hardware operation circuit for calculating Power function and data processing method
Ismail et al. Hybrid logarithmic number system arithmetic unit: A review
CN114691082A (en) Multiplier circuit, chip, electronic device, and computer-readable storage medium
Bärthel et al. Hardware implementation of basic arithmetics and elementary functions for unum computing
Tian et al. A low-latency power series approximate computing and architecture for co-calculation of division and square root
CN109089125A (en) A kind of DCT coefficient distribution characteristics model optimization method in Video coding
KR100974190B1 (en) Complex number multiplying method using floating point
Trivedi et al. A Review on Single Precision Floating Point Arithmetic Unit of 32 bit Number

Legal Events

Date Code Title Description
E902 Notification of reason for refusal
E902 Notification of reason for refusal
E701 Decision to grant or registration of patent right