Skip to content

Commit 6828f13

Browse files
committed
Still unable to get the right header for ops_dict selective build API
1 parent 73c7319 commit 6828f13

File tree

3 files changed

+31
-13
lines changed

3 files changed

+31
-13
lines changed

examples/selective_build/test_selective_build.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ test_cmake_select_ops_in_dict() {
172172
retry cmake -DCMAKE_BUILD_TYPE=Release \
173173
-DMAX_KERNEL_NUM=22 \
174174
-DEXECUTORCH_SELECT_OPS_FROM_DICT='{\"aten::add\":[\"v1/3;0,1|3;0,1|3;0,1|3;0,1\"],\"aten::mul\":[],\"aten::bmm\":[\"Float\"]}' \
175+
-DEXECUTORCH_DTYPE_SELECTIVE_BUILD=ON \
175176
-DCMAKE_INSTALL_PREFIX=cmake-out \
176177
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \
177178
-B${build_dir} \
@@ -188,7 +189,7 @@ test_cmake_select_ops_in_dict() {
188189
}
189190

190191
test_cmake_select_ops_in_model() {
191-
local model_name="add_mul"
192+
local model_name="mv3"
192193
local model_export_name="${model_name}.pte"
193194
echo "Exporting ${model_name}"
194195
${PYTHON_EXECUTABLE} -m examples.portable.scripts.export --model_name="${model_name}"
@@ -207,10 +208,8 @@ test_cmake_select_ops_in_model() {
207208
echo "Building ${example_dir}"
208209
cmake --build ${build_dir} -j9 --config $CMAKE_BUILD_TYPE
209210

210-
echo 'Running selective build test'
211-
${build_dir}/selective_build_test --model_path="./${model_export_name}"
212-
213-
echo "Removing ${model_export_name}"
211+
strip ${build_dir}/selective_build_test
212+
echo $(stat --format=%s ${build_dir}/selective_build_test)
214213
rm "./${model_export_name}"
215214
}
216215

@@ -235,8 +234,8 @@ then
235234
#test_cmake_select_all_ops
236235
#test_cmake_select_ops_in_list
237236
#test_cmake_select_ops_in_yaml
238-
#test_cmake_select_ops_in_model
239-
test_cmake_select_ops_in_dict
237+
test_cmake_select_ops_in_model
238+
#test_cmake_select_ops_in_dict
240239
elif [[ $1 == "buck2" ]];
241240
then
242241
test_buck2_select_all_ops

kernels/portable/cpu/selective_build.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,28 @@
1111
#include <executorch/runtime/core/exec_aten/exec_aten.h>
1212

1313
#ifdef EXECUTORCH_SELECTIVE_BUILD_DTYPE
14+
inline constexpr bool should_include_kernel_dtype(
15+
const char *operator_name,
16+
executorch::aten::ScalarType scalar_type
17+
) {
18+
//return ((std::string_view(operator_name).compare("convolution.out") == 0)
19+
return ((std::string_view(operator_name).compare("atan2.out") == 0)
20+
// && (scalar_type == executorch::aten::ScalarType::Byte
21+
// && scalar_type == executorch::aten::ScalarType::Char
22+
// || scalar_type == executorch::aten::ScalarType::Short
23+
// || scalar_type == executorch::aten::ScalarType::Int
24+
// || scalar_type == executorch::aten::ScalarType::Long
25+
// || scalar_type == executorch::aten::ScalarType::Half
26+
// || scalar_type == executorch::aten::ScalarType::Float
27+
// || scalar_type == executorch::aten::ScalarType::Double
28+
// )
29+
);
30+
// && (scalar_type == executorch::aten::ScalarType::Float));
31+
// || ((std::string_view(operator_name).compare("mm.out") == 0)
32+
// && (scalar_type == executorch::aten::ScalarType::Float));
33+
}
1434
// include header generated by
1535
// executorch/codegen/tools/gen_selected_op_variants.py
16-
#include "selected_op_variants.h"
1736
#else
1837
// dummy implementation
1938
inline constexpr bool should_include_kernel_dtype(

tools/cmake/Codegen.cmake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ function(gen_selected_ops)
2626

2727
set(_out_dir ${CMAKE_CURRENT_BINARY_DIR}/${GEN_LIB_NAME})
2828

29-
if(GEN_DTYPE_SELECTIVE_BUILD)
30-
if(NOT GEN_OPS_FROM_MODEL)
31-
message(FATAL_ERROR " DTYPE_SELECTIVE_BUILD is only support with model API, please pass in a model")
32-
endif()
33-
endif()
29+
#if(GEN_DTYPE_SELECTIVE_BUILD)
30+
# if(NOT GEN_OPS_FROM_MODEL)
31+
# message(FATAL_ERROR " DTYPE_SELECTIVE_BUILD is only support with model API, please pass in a model")
32+
# endif()
33+
#endif()
3434

3535
set(_oplist_yaml
3636
${_out_dir}/selected_operators.yaml

0 commit comments

Comments
 (0)