#!/bin/bash
set -x

function main {
  init_params "$@"
  run_tuning
}

# init params
function init_params {
  gpt2_yaml="./gpt2.yaml"
  for var in "$@"
  do
    case $var in
      --topology=*)
          topology=$(echo $var |cut -f2 -d=)
      ;;
      --dataset_location=*)
          data_dir=$(echo $var |cut -f2 -d=)
      ;;
      --input_model=*)
          input_model=$(echo $var |cut -f2 -d=)
      ;;
      --output_model=*)
          output_model=$(echo $var |cut -f2 -d=)
      ;;
    esac
  done

}

# run_tuning
function run_tuning {
    if [ "${topology}" = "gpt2_lm_wikitext2" ];then
      model_type='gpt2'
      model_name_or_path='gpt2'
      test_data='wiki.test.raw'
    fi 
    python gpt2.py --model_path ${input_model} \
                  --eval_data_file ${data_dir}${test_data} \
                  --model_type ${model_type} \
                  --model_name_or_path ${model_name_or_path} \
                  --tune \
                  --config ${gpt2_yaml} \
                  --output_model ${output_model}
}

main "$@"



