diff --git a/.bazelrc b/.bazelrc index af0b2fd5985..ec0984ef214 100644 --- a/.bazelrc +++ b/.bazelrc @@ -33,6 +33,15 @@ build --cxxopt -std=c++17 # Treat warnings as errors build --copt -Werror +# Common options for --config=ci +build:ci --curses=no +build:ci --color=no +build:ci --noshow_progress +build:ci --noshow_loading_progress +build:ci --show_timestamps +build:ci --terminal_columns=0 +build:ci --verbose_failures + # When building with the address sanitizer # E.g., bazel build --config asan build:asan --repo_env CC=clang diff --git a/python/tflite_micro/numpy_utils.cc b/python/tflite_micro/numpy_utils.cc index 20f43c984dd..0daabf00347 100644 --- a/python/tflite_micro/numpy_utils.cc +++ b/python/tflite_micro/numpy_utils.cc @@ -41,8 +41,8 @@ int TfLiteTypeToPyArrayType(TfLiteType tf_lite_type) { case kTfLiteFloat16: return NPY_FLOAT16; case kTfLiteBFloat16: - // TODO(b/329491949): NPY_BFLOAT16 currently doesn't exist - return NPY_FLOAT16; + // TODO(b/329491949): Supports other ml_dtypes user-defined types. + return NPY_USERDEF; case kTfLiteFloat64: return NPY_FLOAT64; case kTfLiteInt32: @@ -114,6 +114,10 @@ TfLiteType TfLiteTypeFromPyType(int py_type) { return kTfLiteComplex64; case NPY_COMPLEX128: return kTfLiteComplex128; + case NPY_USERDEF: + // User-defined types are defined in ml_dtypes. (bfloat16, float8, etc.) + // Fow now, we only support bfloat16. + return kTfLiteBFloat16; // Avoid default so compiler errors created when new types are made. } return kTfLiteNoType; diff --git a/tensorflow/lite/micro/tools/ci_build/test_bazel.sh b/tensorflow/lite/micro/tools/ci_build/test_bazel.sh index b76ba6e2625..a43ef5ed658 100755 --- a/tensorflow/lite/micro/tools/ci_build/test_bazel.sh +++ b/tensorflow/lite/micro/tools/ci_build/test_bazel.sh @@ -15,6 +15,7 @@ # ============================================================================== set -e +set -x SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR=${SCRIPT_DIR}/../../../../.. @@ -27,8 +28,10 @@ source tensorflow/lite/micro/tools/ci_build/helper_functions.sh # having build_test but that was removed with #194. CC=clang readable_run bazel build ... \ + --config=ci \ --build_tag_filters=-no_oss CC=clang readable_run bazel test ... \ + --config=ci \ --test_tag_filters=-no_oss --build_tag_filters=-no_oss \ --test_output=errors diff --git a/tensorflow/lite/micro/tools/ci_build/test_bazel_asan.sh b/tensorflow/lite/micro/tools/ci_build/test_bazel_asan.sh index 9e025f523bf..a42fc3840d2 100755 --- a/tensorflow/lite/micro/tools/ci_build/test_bazel_asan.sh +++ b/tensorflow/lite/micro/tools/ci_build/test_bazel_asan.sh @@ -15,6 +15,7 @@ # ============================================================================== set -e +set -x SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR=${SCRIPT_DIR}/../../../../.. @@ -27,8 +28,11 @@ source tensorflow/lite/micro/tools/ci_build/helper_functions.sh # having build_test but that was removed with #194. CC=clang readable_run bazel build tensorflow/lite/micro/... \ + --config=ci \ --config=asan --build_tag_filters=-no_oss,-noasan + CC=clang readable_run bazel test tensorflow/lite/micro/... \ + --config=ci \ --config=asan \ --test_tag_filters=-no_oss,-noasan --build_tag_filters=-no_oss,-noasan \ --test_output=errors diff --git a/tensorflow/lite/micro/tools/ci_build/test_bazel_msan.sh b/tensorflow/lite/micro/tools/ci_build/test_bazel_msan.sh index a0b355a0890..9693f85cd5c 100755 --- a/tensorflow/lite/micro/tools/ci_build/test_bazel_msan.sh +++ b/tensorflow/lite/micro/tools/ci_build/test_bazel_msan.sh @@ -15,6 +15,7 @@ # ============================================================================== set -e +set -x SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR=${SCRIPT_DIR}/../../../../.. @@ -27,8 +28,11 @@ source tensorflow/lite/micro/tools/ci_build/helper_functions.sh # having build_test but that was removed with #194. CC=clang readable_run bazel build tensorflow/lite/micro/... \ + --config=ci \ --config=msan --build_tag_filters=-no_oss,-nomsan + CC=clang readable_run bazel test tensorflow/lite/micro/... \ + --config=ci \ --config=msan \ --test_tag_filters=-no_oss,-nomsan --build_tag_filters=-no_oss,-nomsan \ --test_output=errors diff --git a/tensorflow/lite/micro/tools/ci_build/test_bazel_tflite_tools.sh b/tensorflow/lite/micro/tools/ci_build/test_bazel_tflite_tools.sh index 9556cffd8d7..979d3fdbf55 100755 --- a/tensorflow/lite/micro/tools/ci_build/test_bazel_tflite_tools.sh +++ b/tensorflow/lite/micro/tools/ci_build/test_bazel_tflite_tools.sh @@ -15,6 +15,7 @@ # ============================================================================== set -e +set -x SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR=${SCRIPT_DIR}/../../../../.. @@ -23,4 +24,5 @@ cd "${ROOT_DIR}" source tensorflow/lite/micro/tools/ci_build/helper_functions.sh readable_run bazel test tensorflow/lite/tools/... \ + --config=ci \ --test_output=errors