Skip to content

Commit

Permalink
[cadence][hifi] Fixed all hifi ops and cmake
Browse files Browse the repository at this point in the history
Differential Revision: D69812342

Pull Request resolved: #8551
  • Loading branch information
zonglinpeng authored Feb 19, 2025
1 parent 69ac165 commit 4333d65
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 20 deletions.
11 changes: 8 additions & 3 deletions backends/cadence/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ endif()
include(${EXECUTORCH_ROOT}/build/Utils.cmake)

# Let files say "include <executorch/path/to/header.h>".
set(_common_include_directories ${EXECUTORCH_ROOT}/..)
set(_common_include_directories ${EXECUTORCH_ROOT}/..
${EXECUTORCH_ROOT}/runtime/core/portable_type/c10)

add_compile_definitions(C10_USING_CUSTOM_GENERATED_MACROS)

if(EXECUTORCH_CADENCE_CPU_RUNNER)
include(${EXECUTORCH_ROOT}/build/Codegen.cmake)
Expand Down Expand Up @@ -74,10 +77,12 @@ endif()

if(EXECUTORCH_NNLIB_OPT)
set(TARGET_DIR hifi)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_DIR}/third-party/nnlib)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_DIR}/third-party/nnlib
${EXECUTORCH_ROOT}/runtime/core/portable_type/c10)
elseif(EXECUTORCH_FUSION_G3_OPT)
set(TARGET_DIR fusion_g3)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_DIR}/third-party/nnlib)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_DIR}/third-party/nnlib
${EXECUTORCH_ROOT}/runtime/core/portable_type/c10)
else()
set(TARGET_DIR reference)
endif()
Expand Down
5 changes: 0 additions & 5 deletions backends/cadence/aot/functions_hifi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,6 @@
- arg_meta: null
kernel_name: cadence::impl::HiFi::quantized_relu_per_tensor_out

- func: cadence::quantized_linear.per_tensor_out(Tensor src, Tensor weight, Tensor bias, SymInt src_zero_point, SymInt weight_zero_point, SymInt out_multiplier, SymInt out_shift, SymInt out_zero_point, Tensor? offset, *, Tensor(a!) out) -> Tensor(a!)
kernels:
- arg_meta: null
kernel_name: cadence::impl::HiFi::quantized_linear_per_tensor_out

- func: cadence::quantized_fully_connected.out(Tensor src, Tensor weight, Tensor bias, int src_zero_point, Tensor weight_zero_point, Tensor out_multiplier, Tensor out_shift, int out_zero_point, Tensor? offset, *, Tensor(a!) out) -> Tensor(a!)
kernels:
- arg_meta: null
Expand Down
3 changes: 2 additions & 1 deletion backends/cadence/fusion_g3/operators/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ target_link_libraries(aten_ops_cadence PUBLIC executorch)
target_link_libraries(aten_ops_cadence PRIVATE xa_nnlib)

# Let files say "include <executorch/path/to/header.h>".
set(_common_include_directories ${EXECUTORCH_ROOT}/..)
set(_common_include_directories ${EXECUTORCH_ROOT}/..
${EXECUTORCH_ROOT}/runtime/core/portable_type/c10)

target_include_directories(
aten_ops_cadence PUBLIC ${ROOT_DIR}/.. ${CMAKE_BINARY_DIR}
Expand Down
3 changes: 2 additions & 1 deletion backends/cadence/hifi/kernels/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ add_library(
${EXECUTORCH_ROOT}/backends/cadence/hifi/third-party/nnlib/xa_nn_transpose_32.c
)
# Let files say "include <executorch/path/to/header.h>".
set(_common_include_directories ${EXECUTORCH_ROOT}/..)
set(_common_include_directories ${EXECUTORCH_ROOT}/..
${EXECUTORCH_ROOT}/runtime/core/portable_type/c10)

target_include_directories(
cadence_kernels
Expand Down
5 changes: 3 additions & 2 deletions backends/cadence/hifi/operators/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ target_link_libraries(aten_ops_cadence PUBLIC executorch)
target_link_libraries(aten_ops_cadence PRIVATE cadence_kernels)

# Let files say "include <executorch/path/to/header.h>".
set(_common_include_directories ${EXECUTORCH_ROOT}/..)
set(_common_include_directories ${EXECUTORCH_ROOT}/..
${EXECUTORCH_ROOT}/runtime/core/portable_type/c10)

target_include_directories(
aten_ops_cadence PUBLIC ${ROOT_DIR}/.. ${CMAKE_BINARY_DIR}
Expand All @@ -77,7 +78,7 @@ target_include_directories(
# Custom ops that are needed to run the test model.
add_library(
custom_ops "op_quantized_linear_out.cpp" "op_quantized_layer_norm.cpp"
"op_quantize_per_tensor.cpp" "op_quantized_relu_out.cpp" "op_dequantize_per_tensor.cpp"
"op_quantize_per_tensor.cpp" "op_quantized_relu_out.cpp" "op_dequantize_per_tensor.cpp" "op_quantized_fully_connected_out"
)
target_include_directories(
custom_ops PUBLIC ${ROOT_DIR}/.. ${CMAKE_BINARY_DIR}
Expand Down
2 changes: 1 addition & 1 deletion backends/cadence/hifi/operators/op_clamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ Tensor& clamp_tensor_out(
const executorch::aten::optional<Tensor>& min_opt,
const executorch::aten::optional<Tensor>& max_opt,
Tensor& out) {
clamp_Tensor_out(ctx, in, min_opt, max_opt, out);
return clamp_Tensor_out(ctx, in, min_opt, max_opt, out);
}

} // namespace native
Expand Down
2 changes: 1 addition & 1 deletion backends/cadence/hifi/operators/op_mean.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ Tensor& mean_dim_out(
bool keepdim,
optional<ScalarType> dtype,
Tensor& out) {
mean_out(ctx, in, dim_list, keepdim, dtype, out);
return mean_out(ctx, in, dim_list, keepdim, dtype, out);
}

} // namespace native
Expand Down
6 changes: 3 additions & 3 deletions backends/cadence/hifi/operators/op_quantized_relu_out.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ void quantized_relu_per_tensor_out(
void quantized_relu_out(
KernelRuntimeContext& ctx,
const Tensor& input,
const int64_t in_zero_point,
const Tensor& in_zero_point,
const int64_t out_zero_point,
const int64_t out_multiplier,
const int64_t out_shift,
const Tensor& out_multiplier,
const Tensor& out_shift,
Tensor& output) {
quantized_relu_per_tensor_out(
ctx,
Expand Down
2 changes: 1 addition & 1 deletion backends/cadence/hifi/operators/op_softmax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ Tensor& softmax_out(
int64_t dim,
bool half_to_float,
Tensor& out) {
_softmax_out(ctx, in, dim, half_to_float, out);
return _softmax_out(ctx, in, dim, half_to_float, out);
}

} // namespace native
Expand Down
9 changes: 9 additions & 0 deletions backends/cadence/hifi/operators/op_where.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,15 @@ Tensor& where_self_out(
return out;
}

Tensor& where_out(
RuntimeContext& ctx,
const Tensor& cond,
const Tensor& a,
const Tensor& b,
Tensor& out) {
return where_out(ctx, cond, a, b, out);
}

} // namespace native
} // namespace HiFi
} // namespace impl
Expand Down
3 changes: 2 additions & 1 deletion backends/cadence/reference/kernels/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
add_library(cadence_kernels kernels.cpp)

# Let files say "include <executorch/path/to/header.h>".
set(_common_include_directories ${EXECUTORCH_ROOT}/..)
set(_common_include_directories ${EXECUTORCH_ROOT}/..
${EXECUTORCH_ROOT}/runtime/core/portable_type/c10)

target_include_directories(cadence_kernels PUBLIC .
${_common_include_directories}
Expand Down
3 changes: 2 additions & 1 deletion backends/cadence/reference/operators/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ target_link_libraries(aten_ops_cadence PUBLIC executorch)
target_link_libraries(aten_ops_cadence PRIVATE cadence_kernels)

# Let files say "include <executorch/path/to/header.h>".
set(_common_include_directories ${EXECUTORCH_ROOT}/..)
set(_common_include_directories ${EXECUTORCH_ROOT}/..
${EXECUTORCH_ROOT}/runtime/core/portable_type/c10)

target_include_directories(
aten_ops_cadence PUBLIC ${ROOT_DIR}/.. ${CMAKE_BINARY_DIR}
Expand Down

0 comments on commit 4333d65

Please sign in to comment.