diff --git a/deltann/Makefile b/deltann/Makefile index 99569725..b0fedbca 100644 --- a/deltann/Makefile +++ b/deltann/Makefile @@ -61,8 +61,8 @@ CC := gcc CXX := g++ AR := ar -CFLAGS := -g -O2 -CXXFLAGS := -O2 -std=c++11 -fPIC -DDELTANN_VERSION=\"$(shell git rev-parse --short HEAD)\" -DNDEBUG +CFLAGS := -O2 +CXXFLAGS := -O3 -std=c++11 -fPIC -DDELTANN_VERSION=\"$(shell git rev-parse --short HEAD)\" -DNDEBUG LDFLAGS := -Wl,--version-script=deltann_version_script.lds ARFLAGS := -r diff --git a/deltann/api/c_api.cc b/deltann/api/c_api.cc index f4a95989..92c40d45 100644 --- a/deltann/api/c_api.cc +++ b/deltann/api/c_api.cc @@ -19,7 +19,7 @@ limitations under the License. #include "api/c_api.h" #include "core/runtime.h" -#include "core/utils/config.h" +#include "core/config.h" #ifdef __cplusplus extern "C" { diff --git a/deltann/core/base_model.h b/deltann/core/base_model.h index 6a0cbb4c..4c0c6d5e 100644 --- a/deltann/core/base_model.h +++ b/deltann/core/base_model.h @@ -22,7 +22,7 @@ limitations under the License. #include #include "core/data.h" -#include "core/utils/misc.h" +#include "core/misc.h" namespace delta { namespace core { diff --git a/deltann/core/buffer.h b/deltann/core/buffer.h index cfdd48b0..008c2659 100644 --- a/deltann/core/buffer.h +++ b/deltann/core/buffer.h @@ -18,8 +18,8 @@ limitations under the License. #define DELTANN_CORE_BUFFER_H_ #include -#include "core/utils/logging.h" -#include "core/utils/misc.h" +#include "core/logging.h" +#include "core/misc.h" namespace delta { diff --git a/deltann/core/utils/config.cc b/deltann/core/config.cc similarity index 98% rename from deltann/core/utils/config.cc rename to deltann/core/config.cc index ffe76b93..52bf4693 100644 --- a/deltann/core/utils/config.cc +++ b/deltann/core/config.cc @@ -20,11 +20,11 @@ limitations under the License. #include #include "core/io.h" -#include "core/utils/config.h" +#include "core/config.h" #include "yaml-cpp/yaml.h" -using namespace ::delta::core; +// using namespace ::delta::core; namespace delta { diff --git a/deltann/core/utils/config.h b/deltann/core/config.h similarity index 95% rename from deltann/core/utils/config.h rename to deltann/core/config.h index dde6a10b..80f1a50c 100644 --- a/deltann/core/utils/config.h +++ b/deltann/core/config.h @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ -#ifndef DELTANN_UTILS_CONFIG_H_ -#define DELTANN_UTILS_CONFIG_H_ +#ifndef DELTANN_CORE_CONFIG_H_ +#define DELTANN_CORE_CONFIG_H_ #include #include @@ -89,4 +89,4 @@ class RuntimeConfig : public Config { } // namespace delta -#endif // DELTANN_UTILS_CONFIG_H_ +#endif // DELTANN_CORE_CONFIG_H_ diff --git a/deltann/core/data.h b/deltann/core/data.h index 7fd38157..c6f60248 100644 --- a/deltann/core/data.h +++ b/deltann/core/data.h @@ -24,7 +24,7 @@ limitations under the License. #include "core/buffer.h" #include "core/io.h" #include "core/shape.h" -#include "core/utils/misc.h" +#include "core/misc.h" #ifdef USE_TF #include "tensorflow/core/framework/tensor_shape.h" diff --git a/deltann/core/graph.cc b/deltann/core/graph.cc index b832cd20..bb5a087e 100644 --- a/deltann/core/graph.cc +++ b/deltann/core/graph.cc @@ -15,7 +15,7 @@ limitations under the License. ==============================================================================*/ #include "core/graph.h" -#include "core/utils/config.h" +#include "core/config.h" namespace delta { namespace core { diff --git a/deltann/core/graph.h b/deltann/core/graph.h index 07644bd9..16a75939 100644 --- a/deltann/core/graph.h +++ b/deltann/core/graph.h @@ -26,7 +26,7 @@ limitations under the License. #include "core/base_model.h" #include "core/io.h" -#include "core/utils/misc.h" +#include "core/misc.h" namespace delta { namespace core { diff --git a/deltann/core/io.h b/deltann/core/io.h index b96cea28..e826019e 100644 --- a/deltann/core/io.h +++ b/deltann/core/io.h @@ -20,7 +20,7 @@ limitations under the License. #include #include "core/shape.h" -#include "core/utils/misc.h" +#include "core/misc.h" #ifdef USE_TF #include "tensorflow/core/framework/tensor_shape.h" diff --git a/deltann/core/utils/logging.h b/deltann/core/logging.h similarity index 95% rename from deltann/core/utils/logging.h rename to deltann/core/logging.h index 07464a33..5d4ffeb1 100644 --- a/deltann/core/utils/logging.h +++ b/deltann/core/logging.h @@ -14,15 +14,15 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ -#ifndef DELTANN_UTILS_LOGGING_H_ -#define DELTANN_UTILS_LOGGING_H_ +#ifndef DELTANN_CORE_LOGGING_H_ +#define DELTANN_CORE_LOGGING_H_ #include #include #include #include -#include "core/utils/misc.h" +#include "core/misc.h" namespace delta { namespace logging { @@ -100,4 +100,4 @@ class LogMessageFatal : public LogMessage { } // namespace delta -#endif // DELTANN_UTILS_LOGGING_H_ +#endif // DELTANN_CORE_LOGGING_H_ diff --git a/deltann/core/utils/misc.cc b/deltann/core/misc.cc similarity index 96% rename from deltann/core/utils/misc.cc rename to deltann/core/misc.cc index f9ffd8d8..936d0878 100644 --- a/deltann/core/utils/misc.cc +++ b/deltann/core/misc.cc @@ -18,8 +18,8 @@ limitations under the License. #include #include -#include "core/utils/logging.h" -#include "core/utils/misc.h" +#include "core/logging.h" +#include "core/misc.h" namespace delta { @@ -28,7 +28,7 @@ std::size_t delta_sizeof(DataType type) { case DataType::DELTA_FLOAT32: return sizeof(float); case DataType::DELTA_FLOAT16: - return sizeof(short); + return sizeof(float) / 2; case DataType::DELTA_DOUBLE: return sizeof(double); case DataType::DELTA_INT32: diff --git a/deltann/core/utils/misc.h b/deltann/core/misc.h similarity index 97% rename from deltann/core/utils/misc.h rename to deltann/core/misc.h index 761bf7c2..7ddf0e4a 100644 --- a/deltann/core/utils/misc.h +++ b/deltann/core/misc.h @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ -#ifndef DELTANN_UTILS_MISC_H_ -#define DELTANN_UTILS_MISC_H_ +#ifndef DELTANN_CORE_MISC_H_ +#define DELTANN_CORE_MISC_H_ #include #include @@ -118,4 +118,4 @@ std::ostream& operator<<(std::ostream& out, const std::vector& v) { } } // namespace delta -#endif // DELTANN_UTILS_MISC_H_ +#endif // DELTANN_CORE_MISC_H_ diff --git a/deltann/core/runtime.h b/deltann/core/runtime.h index ceaf6cef..5e43eba9 100644 --- a/deltann/core/runtime.h +++ b/deltann/core/runtime.h @@ -27,8 +27,8 @@ limitations under the License. #include "core/tflite_model.h" #include "core/tfmodel.h" #include "core/tfserving_model.h" -#include "core/utils/config.h" -#include "core/utils/misc.h" +#include "core/config.h" +#include "core/misc.h" #ifdef USE_TF #include "tensorflow/c/c_api.h" diff --git a/deltann/core/shape.cc b/deltann/core/shape.cc index 98bcbc96..ab453aa4 100644 --- a/deltann/core/shape.cc +++ b/deltann/core/shape.cc @@ -17,7 +17,7 @@ limitations under the License. #include #include "core/shape.h" -#include "core/utils/logging.h" +#include "core/logging.h" namespace delta { diff --git a/deltann/core/tflite_model.h b/deltann/core/tflite_model.h index 8a33f584..7255cbd1 100644 --- a/deltann/core/tflite_model.h +++ b/deltann/core/tflite_model.h @@ -25,8 +25,8 @@ limitations under the License. #include "core/base_model.h" #include "core/data.h" -#include "core/utils/logging.h" -#include "core/utils/misc.h" +#include "core/logging.h" +#include "core/misc.h" #include "tensorflow/lite/experimental/c/c_api.h" diff --git a/deltann/core/tfmodel.h b/deltann/core/tfmodel.h index 8b891160..de79c5ae 100644 --- a/deltann/core/tfmodel.h +++ b/deltann/core/tfmodel.h @@ -24,8 +24,8 @@ limitations under the License. #include "core/base_model.h" #include "core/data.h" -#include "core/utils/logging.h" -#include "core/utils/misc.h" +#include "core/logging.h" +#include "core/misc.h" #include "tensorflow/cc/saved_model/loader.h" #include "tensorflow/cc/saved_model/tag_constants.h" diff --git a/deltann/core/utils/https.h b/deltann/core/utils/https.h index ca8e8ef3..5be3cb24 100644 --- a/deltann/core/utils/https.h +++ b/deltann/core/utils/https.h @@ -1,4 +1,18 @@ -// https://github.com/HISONA/https_client/blob/master/https.h +// Copyright {yyyy} {HISONA} +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// https://github.com/HISONA/https_client/blob/master/https.h #ifndef HTTPS_CLIENT_HTTPS_H #define HTTPS_CLIENT_HTTPS_H diff --git a/deltann/core/utils/https_client.h b/deltann/core/utils/https_client.h index bf50573f..e4b288a5 100644 --- a/deltann/core/utils/https_client.h +++ b/deltann/core/utils/https_client.h @@ -19,8 +19,10 @@ limitations under the License. #define DELTANN_CORE_UTILS_HTTPS_CLIENT_H_ #ifdef USE_TF_SERVING -#include -#include +#include +#include +#include +#include #include "core/data.h" #include "core/shape.h" diff --git a/deltann/examples/text_cls/test.cc b/deltann/examples/text_cls/test.cc index 7f8bb1f5..753c115e 100644 --- a/deltann/examples/text_cls/test.cc +++ b/deltann/examples/text_cls/test.cc @@ -17,9 +17,19 @@ limitations under the License. #include #include #include +#include +#include #include "api/c_api.h" +float time_run(InferHandel inf){ + struct timespec start, end; + clock_gettime(CLOCK_MONOTONIC, &start); + DeltaRun(inf); + clock_gettime(CLOCK_MONOTONIC, &end); + return (end.tv_sec - start.tv_sec) + (end.tv_nsec - start.tv_nsec) / 1000000000.0; +} + int main(int argc, char** argv) { // const char* yaml_file = "model.yaml"; const char* yaml_file = argv[1]; @@ -37,7 +47,9 @@ int main(int argc, char** argv) { DeltaSetInputs(inf, ins, in_num); - DeltaRun(inf); + // DeltaRun(inf); + float dur = time_run(inf); + fprintf(stderr, "Duration %04f sec.\n", dur); int out_num = DeltaGetOutputCount(inf); fprintf(stderr, "The output num is %d\n", out_num); diff --git a/deltann/targets/linux_makefile.inc b/deltann/targets/linux_makefile.inc index c36cff7e..7d0b613e 100644 --- a/deltann/targets/linux_makefile.inc +++ b/deltann/targets/linux_makefile.inc @@ -3,8 +3,8 @@ ifeq ($(TARGET), linux) CXX := g++ CC := gcc AR := ar - CXXFLAGS += -std=c++11 -fPIC -O3 - CCFLAGS += -fPIC -O3 + CXXFLAGS += -fPIC + CCFLAGS += -fPIC ifeq ($(ENGINE),TF) $(info this will compile with $(ENGINE))