Commit 0f66b2c3 authored by Federico Rossi's avatar Federico Rossi

....

parent 901cd14c
......@@ -79,9 +79,9 @@ add_library(${project_library_target_name} INTERFACE)
##### INCLUDE POSIT FILES ######
set(CPPPOSIT_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/../../../../cppPosit_private/include)
set(CPPOSIT_SRC_DIR ${PROJECT_SOURCE_DIR}/../../../../cppPosit_private/src)
include_directories(${PROJECT_SOURCE_DIR}/../../../../cppPosit_private/include)
set(CPPPOSIT_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/../../../../cppposit_private/include)
set(CPPOSIT_SRC_DIR ${PROJECT_SOURCE_DIR}/../../../../cppposit_private/src)
include_directories(${PROJECT_SOURCE_DIR}/../../../../cppposit_private/include)
################################
......@@ -262,7 +262,7 @@ if(USE_SVE)
set(USE_SSE OFF)
add_definitions(-DCNN_USE_SVE)
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Ofast -march=armv8-a+sve -fPIC -mcpu=native")
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Ofast -march=armv8-a+sve")
endif(USE_SVE)
......@@ -308,7 +308,8 @@ if(CMAKE_COMPILER_IS_GNUCXX OR MINGW OR
# include extra flags to the compiler
# TODO: add info about those flags.
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS}")
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -O3")
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -O3 ")
list(APPEND REQUIRED_LIBRARIES -lsoftfloat)
set(EXTRA_C_FLAGS_DEBUG "${EXTRA_C_FLAGS_DEBUG} -g3 -pthread")
elseif(MSVC)
if(USE_SSE)
......
......@@ -79,7 +79,7 @@ add_executable(gtrsb_test_p12_0 test.cpp ${tiny_dnn_headers})
add_executable(gtrsb_test_p8_0 test.cpp ${tiny_dnn_headers})
target_link_libraries(gtrsb_test_p8_0
${project_library_target_name} ${REQUIRED_LIBRARIES})
target_compile_definitions(gtrsb_test_p8_0 PRIVATE CNN_USE_POSIT CNN_POS_BITS=8 CNN_EXP_BITS=0 CNN_POS_STORAGE=int8_t CNN_POS_BACKEND=uint8_t)
target_compile_definitions(gtrsb_test_p8_0 PRIVATE CNN_USE_POSIT CNN_POS_BITS=8 CNN_EXP_BITS=0 CNN_POS_STORAGE=int16_t CNN_POS_BACKEND=uint16_t)
add_dependencies(gtrsb_tests_type gtrsb_test_p8_0)
add_executable(gtrsb_test_p7_0 test.cpp ${tiny_dnn_headers})
......
......@@ -32,7 +32,7 @@ static tiny_dnn::network<tiny_dnn::sequential>* construct_net() {
using fc = tiny_dnn::layers::fc;
using conv = tiny_dnn::layers::conv;
using ave_pool = tiny_dnn::layers::ave_pool;
using tanh = tiny_dnn::activation::relu;
using tanh = tiny_dnn::activation::sigmoid;
using smax = tiny_dnn::activation::softmax;
using tiny_dnn::core::connection_table;
using padding = tiny_dnn::padding;
......
......@@ -4,7 +4,7 @@ if(USE_SERIALIZER)
add_custom_target(cifar_tests_type)
add_executable(cifar_train train.cpp ${tiny_dnn_headers})
add_executable(cifar_train train_hard.cpp ${tiny_dnn_headers})
target_link_libraries(cifar_train
${project_library_target_name} ${REQUIRED_LIBRARIES})
add_dependencies(cifar_trains_type cifar_train)
......@@ -14,7 +14,7 @@ if(USE_SERIALIZER)
${project_library_target_name} ${REQUIRED_LIBRARIES})
add_dependencies(cifar_tests_type cifar_test)
add_executable(cifar_train_p16_2 train.cpp ${tiny_dnn_headers})
add_executable(cifar_train_p16_2 train_hard.cpp ${tiny_dnn_headers})
target_link_libraries(cifar_train_p16_2
${project_library_target_name} ${REQUIRED_LIBRARIES})
target_compile_definitions(cifar_train_p16_2 PRIVATE CNN_USE_POSIT CNN_POS_BITS=16 CNN_EXP_BITS=2 CNN_POS_STORAGE=int16_t CNN_POS_BACKEND=uint32_t)
......@@ -32,7 +32,7 @@ if(USE_SERIALIZER)
target_compile_definitions(cifar_test_p16_0 PRIVATE CNN_USE_POSIT CNN_POS_BITS=16 CNN_EXP_BITS=0 CNN_POS_STORAGE=int16_t CNN_POS_BACKEND=uint32_t)
add_dependencies(cifar_tests_type cifar_test_p16_0)
add_executable(cifar_train_p14_2 train.cpp ${tiny_dnn_headers})
add_executable(cifar_train_p14_2 train_hard.cpp ${tiny_dnn_headers})
target_link_libraries(cifar_train_p14_2
${project_library_target_name} ${REQUIRED_LIBRARIES})
target_compile_definitions(cifar_train_p14_2 PRIVATE CNN_USE_POSIT CNN_POS_BITS=14 CNN_EXP_BITS=2 CNN_POS_STORAGE=int16_t CNN_POS_BACKEND=uint32_t)
......@@ -51,7 +51,7 @@ if(USE_SERIALIZER)
add_dependencies(cifar_tests_type cifar_test_p14_0)
add_executable(cifar_train_p12_2 train.cpp ${tiny_dnn_headers})
add_executable(cifar_train_p12_2 train_hard.cpp ${tiny_dnn_headers})
target_link_libraries(cifar_train_p12_2
${project_library_target_name} ${REQUIRED_LIBRARIES})
target_compile_definitions(cifar_train_p12_2 PRIVATE CNN_USE_POSIT CNN_POS_BITS=12 CNN_EXP_BITS=2 CNN_POS_STORAGE=int16_t CNN_POS_BACKEND=uint32_t)
......@@ -107,7 +107,7 @@ add_executable(cifar_test_p12_0 test.cpp ${tiny_dnn_headers})
if(TAB8)
add_executable(cifar_train_posittab8 train.cpp ${TAB_POSIT_LIB8} ${tiny_dnn_headers})
add_executable(cifar_train_posittab8 train_hard.cpp ${TAB_POSIT_LIB8} ${tiny_dnn_headers})
target_link_libraries(cifar_train_posittab8
${project_library_target_name} ${REQUIRED_LIBRARIES})
target_compile_definitions(cifar_train_posittab8 PRIVATE CNN_USE_POSIT CNN_TAB_TYPE=posit8)
......@@ -120,7 +120,7 @@ add_executable(cifar_test_p12_0 test.cpp ${tiny_dnn_headers})
endif(TAB8)
if(TAB10)
add_executable(cifar_train_posittab10 train.cpp ${TAB_POSIT_LIB10} ${tiny_dnn_headers})
add_executable(cifar_train_posittab10 train_hard.cpp ${TAB_POSIT_LIB10} ${tiny_dnn_headers})
target_link_libraries(cifar_train_posittab10
${project_library_target_name} ${REQUIRED_LIBRARIES})
target_compile_definitions(cifar_train_posittab10 PRIVATE CNN_USE_POSIT CNN_TAB_TYPE=posit10)
......@@ -133,7 +133,7 @@ add_executable(cifar_test_p12_0 test.cpp ${tiny_dnn_headers})
endif(TAB10)
if(TAB12)
add_executable(cifar_train_posittab12 train.cpp ${TAB_POSIT_LIB12} ${tiny_dnn_headers})
add_executable(cifar_train_posittab12 train_hard.cpp ${TAB_POSIT_LIB12} ${tiny_dnn_headers})
target_link_libraries(cifar_train_posittab12
${project_library_target_name} ${REQUIRED_LIBRARIES})
target_compile_definitions(cifar_train_posittab12 PRIVATE CNN_USE_POSIT CNN_TAB_TYPE=posit12)
......@@ -147,7 +147,7 @@ add_executable(cifar_test_p12_0 test.cpp ${tiny_dnn_headers})
if(TAB14)
add_executable(cifar_train_posittab14 train.cpp ${TAB_POSIT_LIB14} ${tiny_dnn_headers})
add_executable(cifar_train_posittab14 train_hard.cpp ${TAB_POSIT_LIB14} ${tiny_dnn_headers})
target_link_libraries(cifar_train_posittab14
${project_library_target_name} ${REQUIRED_LIBRARIES})
target_compile_definitions(cifar_train_posittab14 PRIVATE CNN_USE_POSIT CNN_TAB_TYPE=posit14)
......
......@@ -12,34 +12,6 @@
#include "tiny_dnn/tiny_dnn.h"
template <typename N>
void construct_net(N &nn, tiny_dnn::core::backend_t backend_type) {
/*using conv = tiny_dnn::convolutional_layer;
using pool = tiny_dnn::max_pooling_layer;
using fc = tiny_dnn::fully_connected_layer;
using relu = tiny_dnn::activation::ptanh;
using softmax = tiny_dnn::softmax_layer;
const size_t n_fmaps = 32; // number of feature maps for upper layer
const size_t n_fmaps2 = 64; // number of feature maps for lower layer
const size_t n_fc = 64; // number of hidden units in fc layer
nn << conv(32, 32, 5, 3, n_fmaps, tiny_dnn::padding::same, true, 1, 1, 1, 1,
backend_type) // C1
<< pool(32, 32, n_fmaps, 2, false, backend_type) // P2
<< relu() // activation
<< conv(16, 16, 5, n_fmaps, n_fmaps, tiny_dnn::padding::same, true, 1, 1,
1, 1,
backend_type) // C3
<< pool(16, 16, n_fmaps, 2, false, backend_type) // P4
<< relu() // activation
<< conv(8, 8, 5, n_fmaps, n_fmaps2, tiny_dnn::padding::same, true, 1, 1, 1,
1,
backend_type) // C5
<< pool(8, 8, n_fmaps2, 2, false, backend_type) // P6
<< relu() // activation
<< fc(4 * 4 * n_fmaps2, n_fc, true, backend_type) // FC7
<< relu() // activation
<< fc(n_fc, 10, true, backend_type) << relu(); // FC10*/
// connection table [Y.Lecun, 1998 Table.1]
#define O true
#define X false
// clang-format off
......@@ -113,6 +85,7 @@ void train_cifar10(std::string data_dir_path,
std::vector<tiny_dnn::label_t> test_labels(test_labels_o.begin(),test_labels_o.begin()+1000);
std::vector<tiny_dnn::vec_t> test_images(test_images_o.begin(),test_images_o.begin()+1000);
/****************/
vutil::randomShuffle(train_labels,train_images);
tiny_dnn::progress_display disp(train_images.size());
tiny_dnn::timer t;
......
......@@ -12,59 +12,33 @@
#include "tiny_dnn/tiny_dnn.h"
template <typename N>
void construct_net(N &nn, tiny_dnn::core::backend_t backend_type) {
#define O true
#define X false
static const bool tbl[] = {
O, X, X, X, O, O, O, X, X, O, O, O, O, X, O, O,
O, O, X, X, X, O, O, O, X, X, O, O, O, O, X, O,
O, O, O, X, X, X, O, O, O, X, X, O, X, O, O, O,
X, O, O, O, X, X, O, O, O, O, X, X, O, X, O, O,
X, X, O, O, O, X, X, O, O, O, O, X, O, O, X, O,
X, X, X, O, O, O, X, X, O, O, O, O, X, O, O, O
};
#undef O
#undef X
using fc = tiny_dnn::layers::fc;
using conv = tiny_dnn::layers::conv;
using ave_pool = tiny_dnn::layers::max_pool;
using tanh = tiny_dnn::activation::ptanh;
using max_pool = tiny_dnn::layers::max_pool;
using relu = tiny_dnn::activation::relu;
using tiny_dnn::core::connection_table;
using padding = tiny_dnn::padding;
using smax = tiny_dnn::activation::softmax;
using batch = tiny_dnn::batch_norm;
using dropout = tiny_dnn::layers::dropout;
nn << conv(32, 32, 3, 3, 32, // C1, 3@32x32-in, 32@32x32-out
padding::same, true, 1, 1, 1, 1, backend_type)
<< tanh()
<< batch(32*32,32)
<< conv(32, 32, 3, 32, 32, // C2, 32@32x32-in, 32@32x32-out
padding::same, true, 1, 1, 1, 1, backend_type) // S2, 6@28x28-in, 6@14x14-out
<< tanh()
<< batch(32*32,32)
<< ave_pool(32,32,32,2)
<< dropout(16*16*32,0.5)
<< conv(16, 16, 3, 32, 64, // C3, 32@32x32-in, 64@32x32-out
padding::same, true, 1, 1, 1, 1, backend_type)
<< tanh()
<< batch(16*16,64)
<< conv(16, 16, 3, 64, 64, // C4, 6@14x14-in, 16@10x10-out
padding::same, true, 1, 1, 1, 1, backend_type)
<< tanh()
<< batch(16*16,64)
<< ave_pool(16,16,64,2)
<< dropout(8*8*64,0.5)
<< conv(8, 8, 3, 64, 128, // C5, 6@14x14-in, 16@10x10-out
padding::same, true, 1, 1, 1, 1, backend_type)
<< tanh()
<< batch(8*8,128)
<< conv(8, 8, 3, 128, 128, // C6, 6@14x14-in, 16@10x10-out
padding::same, true, 1, 1, 1, 1, backend_type)
<< tanh()
<< batch(8*8,128)
<< ave_pool(8, 8, 128, 2)
<< dropout(4*4*128,0.5)
<< fc(2048, 10, true, backend_type)
<< smax();
using softmax = tiny_dnn::activation::softmax;
// Block 1
nn << conv(32, 32, 3, 3, 3, 64, padding::same) << relu();
nn << conv(32, 32, 3, 3, 64, 64, padding::same) << relu();
nn << max_pool(32, 32, 64, 2) << relu();
// Block 2
nn << conv(16, 16, 3, 3, 64, 128, padding::same) << relu();
nn << conv(16, 16, 3, 3, 128, 128, padding::same) << relu();
nn << max_pool(16, 16, 128, 2) << relu();
// Block 3
nn << conv(8, 8, 3, 3, 128, 256, padding::same) << relu();
nn << conv(8, 8, 3, 3, 256, 256, padding::same) << relu();
nn << conv(8, 8, 3, 3, 256, 256, padding::same) << relu();
nn << max_pool(8, 8, 256, 2) << relu();
nn << fc(4*4*256,4096) << relu();
nn << fc(4096,4096) << relu();
nn << fc(4096,10) << relu() << softmax();
}
void train_cifar10(std::string data_dir_path,
......
......@@ -18,93 +18,46 @@ if(USE_SERIALIZER)
add_executable(mnist_train_p16_0 train.cpp ${tiny_dnn_headers})
target_link_libraries(mnist_train_p16_0
${project_library_target_name} ${REQUIRED_LIBRARIES})
target_compile_definitions(mnist_train_p16_0 PRIVATE CNN_USE_POSIT CNN_POS_BITS=16 CNN_EXP_BITS=0 CNN_POS_STORAGE=int16_t CNN_POS_BACKEND=uint32_t)
target_compile_definitions(mnist_train_p16_0 PRIVATE CNN_USE_POSIT CNN_POS_BITS=16 CNN_EXP_BITS=0 CNN_POS_STORAGE=int_fast16_t CNN_POS_BACKEND=uint_fast16_t)
add_dependencies(mnist_trains_type mnist_train_p16_0)
add_executable(mnist_test_p16_2 test_alt.cpp ${tiny_dnn_headers})
target_link_libraries(mnist_test_p16_2
${project_library_target_name} ${REQUIRED_LIBRARIES})
target_compile_definitions(mnist_test_p16_2 PRIVATE CNN_USE_POSIT CNN_POS_BITS=16 CNN_EXP_BITS=2 CNN_POS_STORAGE=int16_t CNN_POS_BACKEND=uint32_t)
add_dependencies(mnist_tests_type mnist_test_p16_2)
add_executable(mnist_test_p16_0 test_alt.cpp ${tiny_dnn_headers})
target_link_libraries(mnist_test_p16_0
${project_library_target_name} ${REQUIRED_LIBRARIES})
target_compile_definitions(mnist_test_p16_0 PRIVATE CNN_USE_POSIT CNN_POS_BITS=16 CNN_EXP_BITS=0 CNN_POS_STORAGE=int16_t CNN_POS_BACKEND=uint32_t)
target_compile_definitions(mnist_test_p16_0 PRIVATE CNN_USE_POSIT CNN_POS_BITS=16 CNN_EXP_BITS=0 CNN_POS_STORAGE=int_fast16_t CNN_POS_BACKEND=uint_fast16_t)
add_dependencies(mnist_tests_type mnist_test_p16_0)
add_executable(mnist_train_p14_2 train.cpp ${tiny_dnn_headers})
target_link_libraries(mnist_train_p14_2
${project_library_target_name} ${REQUIRED_LIBRARIES})
target_compile_definitions(mnist_train_p14_2 PRIVATE CNN_USE_POSIT CNN_POS_BITS=14 CNN_EXP_BITS=2 CNN_POS_STORAGE=int16_t CNN_POS_BACKEND=uint32_t)
add_dependencies(mnist_trains_type mnist_train_p14_2)
add_executable(mnist_test_p14_2 test_alt.cpp ${tiny_dnn_headers})
target_link_libraries(mnist_test_p14_2
${project_library_target_name} ${REQUIRED_LIBRARIES})
target_compile_definitions(mnist_test_p14_2 PRIVATE CNN_USE_POSIT CNN_POS_BITS=14 CNN_EXP_BITS=2 CNN_POS_STORAGE=int16_t CNN_POS_BACKEND=uint32_t)
add_dependencies(mnist_tests_type mnist_test_p14_2)
add_executable(mnist_test_p14_0 test_alt.cpp ${tiny_dnn_headers})
target_link_libraries(mnist_test_p14_0
${project_library_target_name} ${REQUIRED_LIBRARIES})
target_compile_definitions(mnist_test_p14_0 PRIVATE CNN_USE_POSIT CNN_POS_BITS=14 CNN_EXP_BITS=0 CNN_POS_STORAGE=int16_t CNN_POS_BACKEND=uint32_t)
target_compile_definitions(mnist_test_p14_0 PRIVATE CNN_USE_POSIT CNN_POS_BITS=14 CNN_EXP_BITS=0 CNN_POS_STORAGE=int_fast16_t CNN_POS_BACKEND=uint_fast16_t)
add_dependencies(mnist_tests_type mnist_test_p14_0)
add_executable(mnist_train_p12_2 train.cpp ${tiny_dnn_headers})
target_link_libraries(mnist_train_p12_2
${project_library_target_name} ${REQUIRED_LIBRARIES})
target_compile_definitions(mnist_train_p12_2 PRIVATE CNN_USE_POSIT CNN_POS_BITS=12 CNN_EXP_BITS=2 CNN_POS_STORAGE=int16_t CNN_POS_BACKEND=uint32_t)
add_dependencies(mnist_trains_type mnist_train_p12_2)
add_executable(mnist_test_p12_2 test_alt.cpp ${tiny_dnn_headers})
target_link_libraries(mnist_test_p12_2
${project_library_target_name} ${REQUIRED_LIBRARIES})
target_compile_definitions(mnist_test_p12_2 PRIVATE CNN_USE_POSIT CNN_POS_BITS=12 CNN_EXP_BITS=2 CNN_POS_STORAGE=int16_t CNN_POS_BACKEND=uint32_t)
add_dependencies(mnist_tests_type mnist_test_p12_2)
add_executable(mnist_test_p12_0 test_alt.cpp ${tiny_dnn_headers})
target_link_libraries(mnist_test_p12_0
${project_library_target_name} ${REQUIRED_LIBRARIES})
target_compile_definitions(mnist_test_p12_0 PRIVATE CNN_USE_POSIT CNN_POS_BITS=12 CNN_EXP_BITS=0 CNN_POS_STORAGE=int16_t CNN_POS_BACKEND=uint32_t)
target_compile_definitions(mnist_test_p12_0 PRIVATE CNN_USE_POSIT CNN_POS_BITS=12 CNN_EXP_BITS=0 CNN_POS_STORAGE=int_fast16_t CNN_POS_BACKEND=uint_fast16_t)
add_dependencies(mnist_tests_type mnist_test_p12_0)
add_executable(mnist_test_p10_0 test_alt.cpp ${tiny_dnn_headers})
target_link_libraries(mnist_test_p10_0
${project_library_target_name} ${REQUIRED_LIBRARIES})
target_compile_definitions(mnist_test_p10_0 PRIVATE CNN_USE_POSIT CNN_POS_BITS=10 CNN_EXP_BITS=0 CNN_POS_STORAGE=int16_t CNN_POS_BACKEND=uint32_t)
target_compile_definitions(mnist_test_p10_0 PRIVATE CNN_USE_POSIT CNN_POS_BITS=10 CNN_EXP_BITS=0 CNN_POS_STORAGE=int_fast16_t CNN_POS_BACKEND=uint_fast16_t)
add_dependencies(mnist_tests_type mnist_test_p10_0)
add_executable(mnist_test_p8_0 test_alt.cpp ${tiny_dnn_headers})
target_link_libraries(mnist_test_p8_0
${project_library_target_name} ${REQUIRED_LIBRARIES})
target_compile_definitions(mnist_test_p8_0 PRIVATE CNN_USE_POSIT CNN_POS_BITS=8 CNN_EXP_BITS=0 CNN_POS_STORAGE=int8_t CNN_POS_BACKEND=uint8_t)
target_compile_definitions(mnist_test_p8_0 PRIVATE CNN_USE_POSIT CNN_POS_BITS=8 CNN_EXP_BITS=0 CNN_POS_STORAGE=int_fast16_t CNN_POS_BACKEND=uint_fast16_t)
add_dependencies(mnist_tests_type mnist_test_p8_0)
add_executable(mnist_test_p7_0 test_alt.cpp ${tiny_dnn_headers})
target_link_libraries(mnist_test_p7_0
${project_library_target_name} ${REQUIRED_LIBRARIES})
target_compile_definitions(mnist_test_p7_0 PRIVATE CNN_USE_POSIT CNN_POS_BITS=7 CNN_EXP_BITS=1 CNN_POS_STORAGE=int8_t CNN_POS_BACKEND=uint32_t)
add_dependencies(mnist_tests_type mnist_test_p7_0)
add_executable(mnist_test_p6_0 test_alt.cpp ${tiny_dnn_headers})
target_link_libraries(mnist_test_p6_0
${project_library_target_name} ${REQUIRED_LIBRARIES})
target_compile_definitions(mnist_test_p6_0 PRIVATE CNN_USE_POSIT CNN_POS_BITS=6 CNN_EXP_BITS=0 CNN_POS_STORAGE=int8_t CNN_POS_BACKEND=uint32_t)
add_dependencies(mnist_tests_type mnist_test_p6_0)
add_executable(mnist_test_p5_0 test_alt.cpp ${tiny_dnn_headers})
target_link_libraries(mnist_test_p5_0
${project_library_target_name} ${REQUIRED_LIBRARIES})
target_compile_definitions(mnist_test_p5_0 PRIVATE CNN_USE_POSIT CNN_POS_BITS=5 CNN_EXP_BITS=0 CNN_POS_STORAGE=int8_t CNN_POS_BACKEND=uint32_t)
add_dependencies(mnist_tests_type mnist_test_p5_0)
add_executable(mnist_test_p4_0 test_alt.cpp ${tiny_dnn_headers})
target_link_libraries(mnist_test_p4_0
${project_library_target_name} ${REQUIRED_LIBRARIES})
target_compile_definitions(mnist_test_p4_0 PRIVATE CNN_USE_POSIT CNN_POS_BITS=4 CNN_EXP_BITS=0 CNN_POS_STORAGE=int8_t CNN_POS_BACKEND=uint32_t)
add_dependencies(mnist_tests_type mnist_test_p4_0)
if(TAB8)
......
......@@ -32,7 +32,8 @@ int main(int argc, char **argv) {
auto start = get_time::now();
double stime = 0;
for(unsigned int i = 0; i < test_images.size(); ++i) {
int num = (argc > 3)? atoi(argv[3]):test_images.size();
for(unsigned int i = 0; i < num; ++i) {
auto inner_b = get_time::now();
auto res = net.predict(test_images[i]);
auto inner_e = get_time::now();
......
This diff is collapsed.
######### TEST CONFIGURATION ############
CPP=aarch64-linux-g++
vector_size=$1
run_number=$2
reps=$3
......
......@@ -9,6 +9,7 @@
#include <cstddef>
#include <cstdint>
#include "floats/softfloat.hpp"
#ifdef CNN_USE_POSIT
//#define POSIT_CEREAL
#undef CNN_USE_AVX
......
......@@ -228,7 +228,7 @@ class batch_normalization_layer : public layer {
private:
void calc_stddev(const vec_t &variance) {
for (size_t i = 0; i < in_channels_; i++) {
stddev_[i] = sqrt(variance[i] + eps_);
stddev_[i] = tiny_dnn::sqrt(variance[i] + eps_);
}
}
......
......@@ -89,7 +89,7 @@ class l2_normalization_layer : public layer {
sum_of_square += value * value;
}
sum_of_square = std::max(sum_of_square, eps_);
float_t root_sum_squared = sqrt(sum_of_square);
float_t root_sum_squared = tiny_dnn::sqrt(sum_of_square);
for (size_t k = 0; k < in_channels_; ++k) {
const float_t *inptr_c = inptr + k * in_spatial_size_;
......
......@@ -570,7 +570,7 @@ void fill(T *dst, size_t size, T value) {
#elif defined CNN_USE_DOUBLE
#define CNN_VECTORIZE_TYPE detail::scalar_generic<double>
#else
#define CNN_VECTORIZE_TYPE detail::scalar_generic<float>
#define CNN_VECTORIZE_TYPE detail::scalar_generic<tiny_dnn::float_t>
#endif
#endif
......
......@@ -108,7 +108,7 @@ namespace tiny_dnn {
// 2*sigm(2x)-1
// derivative 2*d(sigm(2x))*2
float_t pseudotanh(float_t x) {
#ifdef CNN_USE_POSIT
#ifdef CNN_USE_POSIT_A
#if(CNN_EXP_BITS == 0)
return x.fastTanh();
#else
......@@ -119,7 +119,7 @@ namespace tiny_dnn {
#endif
}
float_t elu(float_t x,float_t a=1) {
float_t elu(float_t x,float_t a=float_t(1.0)) {
#ifdef CNN_USE_POSIT
#if(CNN_EXP_BITS == 0)
return x.fastELU();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment