Skip to content

Instantly share code, notes, and snippets.

View hayunjong83's full-sized avatar

hayunjong83

  • Seoul National University
  • Seoul
View GitHub Profile
###################################################################################################
# #
# RAG(Retrieval Augmented Generation) example #
# <hayunjong83@gmail.com> #
# #
# Used: #
# Application : Streamlit #
# LLM Framework : LangChain #
# LLM Related : llama-2 7B, GPT4All(embedding model) #
# #
@hayunjong83
hayunjong83 / example2_3_2.py
Created November 9, 2021 09:27
udacity TensorFlow Lite Chap.2-3 example code
import tensorflow as tf
import pathlib
# Load the MobileNet tf.keras model
model = tf.keras.applications.MobileNetV2(weights="imagenet", input_shape=(224,224,3))
# Convert the model
converter = tf.lite.TFLiteConverter.from_keras_model(model)
tflite_model = converter.convert()
@hayunjong83
hayunjong83 / example2_3_1.py
Created November 9, 2021 09:10
udacity TensorFlow Lite Chap.2-3 example code
import tensorflow as tf
# Store data for x and y
x = [-1, 0, 1, 2, 3, 4]
y = [-3,-1, 1, 3, 5, 7]
# Create a simple Keras model
model = tf.keras.models.Sequential(
[tf.keras.layers.Dense(units=1, input_shape=[1])])
model.compile(optimizer='sgd', loss='mean_squared_error')
model.fit(x, y, epochs=500)
@hayunjong83
hayunjong83 / minimum_time_visiting_all_points_1266.cpp
Created January 11, 2021 06:41
Minimum Time Visiting All Points
class Solution {
public:
int minTimeToVisitAllPoints(vector<vector<int>>& points) {
int time = 0;
for(int i = 1; i < points.size() ; i++)
{
int x, y, m;
x = abs(points[i-1][0] - points[i][0]);
y = abs(points[i-1][1] - points[i][1]);
m = min(x, y);
@hayunjong83
hayunjong83 / cdpSimpleQuicksort.cu
Last active March 6, 2020 07:27
quick sort using CUDA dynamic parallelism
#include <iostream>
#include <cstdio>
#include <helper_cuda.h>
#include <helper_string.h>
#define MAX_DEPTH 16
#define SELECTION_SORT 32
__device__ void selection_sort(unsigned int *data, int left, int right)
{
@hayunjong83
hayunjong83 / cdpSimplePrint.cu
Created March 5, 2020 07:59
CUDA dynamic parallelism example 1) cdpSimplePrint
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <helper_cuda.h>
#include <helper_string.h>
__device__ int g_uids = 0;
__device__ void print_info(int depth, int thread, int uid, int parent_uid)
{
@hayunjong83
hayunjong83 / saxpy_time.cu
Created March 4, 2020 04:08
record the kernel execution time with CUDA Event API
#include <iostream>
#include <cuda.h>
#include <cuda_runtime.h>
__global__ void saxpy(int n, float a, float *__restrict__ x, float *__restrict__ y)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
if( i < n )
y[i] = a * x[i] + y[i];
}
@hayunjong83
hayunjong83 / saxpy_cublas.cu
Created March 3, 2020 14:37
SAXPY implementation with cublas library
#include <cublas.h>
int main()
{
int N = 1 << 16;
int size = N * sizeof(float);
float *h_x = (float*)malloc(size);
float *h_y = (float*)malloc(size);
@hayunjong83
hayunjong83 / saxpy.cu
Created March 3, 2020 13:40
simple SAXPY operation
__global__ void saxpy(int n, float a, float *__restrict__ x, float *__restrict__ y)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
if( i < n )
y[i] = a * x[i] + y[i];
}
int main()
{
int N = 1 << 16;
@hayunjong83
hayunjong83 / open_webcam.cpp
Last active February 14, 2020 10:26
Show live webcam by OpenCV c++.
#include <opencv2/opencv.hpp>
#include <iostream>
#include <stdio.h>
using namespace std;
using namespace cv;
int main(int argv, char** argc)
{
Mat frame;