Update branch_mul example Check in the dispatch object file instead of render from the mlir -- no dependency to `iree-compile` The runtime library is relatively stable at this point (no API change in > 16 months), so it should be okay to keep a copy of the generated object file like this. Bug: 294402411 Change-Id: I8f384c1789a5355ba3d24cead6c9c15638b555f1
diff --git a/samples/branch_mul/CMakeLists.txt b/samples/branch_mul/CMakeLists.txt index 5f7b9f8..e45a432 100644 --- a/samples/branch_mul/CMakeLists.txt +++ b/samples/branch_mul/CMakeLists.txt
@@ -1,25 +1,20 @@ -sparrow_static_module( - NAME - branch_mul - SRC - "branch_mul.mlir" - FLAGS - "-iree-input-type=tosa" - # NB: iree seems to step on the input tensors - # without this. - "-iree-flow-trace-dispatch-tensors" - EMITC - RVV_OFF +add_library(samples_branch_mul_branch_mul_lib + STATIC + branch_mul_c.o ) +set_target_properties( + samples_branch_mul_branch_mul_lib + PROPERTIES + LINKER_LANGUAGE C) + sparrow_test( NAME branch_mul_emitc_static SRCS "branch_mul.c" DEPS - ::branch_mul_emitc - ::branch_mul_lib + samples_branch_mul_branch_mul_lib iree::base iree::vm::bytecode::module iree::hal::local::executable_environment
diff --git a/samples/branch_mul/branch_mul.c b/samples/branch_mul/branch_mul.c index 910d655..d25e364 100644 --- a/samples/branch_mul/branch_mul.c +++ b/samples/branch_mul/branch_mul.c
@@ -17,7 +17,6 @@ #include "samples/branch_mul/branch_mul_arg1.h" #include "samples/branch_mul/branch_mul_arg2.h" #include "samples/branch_mul/branch_mul_c.h" -#include "samples/branch_mul/branch_mul_emitc.h" #include "samples/branch_mul/branch_mul_expected.h" static int8_t ret0[3][2][256] = { 0 };
diff --git a/samples/branch_mul/branch_mul.run b/samples/branch_mul/branch_mul.run index 198809c..5f8c701 100644 --- a/samples/branch_mul/branch_mul.run +++ b/samples/branch_mul/branch_mul.run
@@ -1,3 +1 @@ -// TODO(b/294402411): Fix the test -// XFAIL: * // RUN: ${TEST_RUNNER_CMD} %S/branch_mul_emitc_static
diff --git a/samples/branch_mul/branch_mul_arg0.h b/samples/branch_mul/branch_mul_arg0.h index 59aeca6..6e9bdeb 100644 --- a/samples/branch_mul/branch_mul_arg0.h +++ b/samples/branch_mul/branch_mul_arg0.h
@@ -1,5 +1,21 @@ -#ifndef DAREDEVIL_BRANCH_MUL_DAREDEVIL_BRANCH_MUL_ARG0_H_ -#define DAREDEVIL_BRANCH_MUL_DAREDEVIL_BRANCH_MUL_ARG0_H_ +/* + * Copyright 2023 Google LLC + * + * 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. + */ + +#ifndef SAMPLES_BRANCH_MUL_BRANCH_MUL_ARG0_H_ +#define SAMPLES_BRANCH_MUL_BRANCH_MUL_ARG0_H_ int32_t arg0[3][2][256] = { {{49163, 39296, 47490, 46186, 48142, 35193, 34298, 38115, 40865, 31744, @@ -159,4 +175,4 @@ 53209, 42418, 29080, 30075, 32590, 37886, 45749, 35820, 33766, 41844, 47480, 22113, 40931, 31528, 28850, 52826}}}; -#endif // DAREDEVIL_BRANCH_MUL_DAREDEVIL_BRANCH_MUL_ARG0_H_ +#endif // SAMPLES_BRANCH_MUL_BRANCH_MUL_ARG0_H_
diff --git a/samples/branch_mul/branch_mul_arg1.h b/samples/branch_mul/branch_mul_arg1.h index 05ec099..8a45d8a 100644 --- a/samples/branch_mul/branch_mul_arg1.h +++ b/samples/branch_mul/branch_mul_arg1.h
@@ -1,5 +1,21 @@ -#ifndef DAREDEVIL_BRANCH_MUL_DAREDEVIL_BRANCH_MUL_ARG1_H_ -#define DAREDEVIL_BRANCH_MUL_DAREDEVIL_BRANCH_MUL_ARG1_H_ +/* + * Copyright 2023 Google LLC + * + * 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. + */ + +#ifndef SAMPLES_BRANCH_MUL_BRANCH_MUL_ARG1_H_ +#define SAMPLES_BRANCH_MUL_BRANCH_MUL_ARG1_H_ int32_t arg1[256] = { -386, -307, -400, -368, -387, -361, -274, -309, -467, -312, -318, -301, @@ -25,4 +41,4 @@ -416, -359, -288, -250, -273, -323, -384, -284, -372, -359, -384, -206, -385, -284, -247, -503}; -#endif // DAREDEVIL_BRANCH_MUL_DAREDEVIL_BRANCH_MUL_ARG1_H_ +#endif // SAMPLES_BRANCH_MUL_BRANCH_MUL_ARG1_H_
diff --git a/samples/branch_mul/branch_mul_arg2.h b/samples/branch_mul/branch_mul_arg2.h index 19e34e8..795cd73 100644 --- a/samples/branch_mul/branch_mul_arg2.h +++ b/samples/branch_mul/branch_mul_arg2.h
@@ -1,5 +1,21 @@ -#ifndef DAREDEVIL_BRANCH_MUL_DAREDEVIL_BRANCH_MUL_ARG2_H_ -#define DAREDEVIL_BRANCH_MUL_DAREDEVIL_BRANCH_MUL_ARG2_H_ +/* + * Copyright 2023 Google LLC + * + * 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. + */ + +#ifndef SAMPLES_BRANCH_MUL_BRANCH_MUL_ARG2_H_ +#define SAMPLES_BRANCH_MUL_BRANCH_MUL_ARG2_H_ int32_t arg2[3][2][256] = { {{-1147, -1152, -1059, -1130, -1113, -887, -1130, -1109, -736, -910, @@ -160,4 +176,4 @@ -1108, -1037, -935, -1009, -1066, -917}}, }; -#endif // DAREDEVIL_BRANCH_MUL_DAREDEVIL_BRANCH_MUL_ARG2_H_ +#endif // SAMPLES_BRANCH_MUL_BRANCH_MUL_ARG2_H_
diff --git a/samples/branch_mul/branch_mul_c.h b/samples/branch_mul/branch_mul_c.h new file mode 100644 index 0000000..0018fb9 --- /dev/null +++ b/samples/branch_mul/branch_mul_c.h
@@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * 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. + */ + +// === [llvm_module_linked_llvm_cpu] static library === +// +// To use: +// - Include this header and generated object into your program +// - At runtime: retrieve library name from host binary +// - Query library from llvm_module_linked_llvm_cpu_library_query()<< +// - Feed library into static_library_loader +// +// === Automatically generated file. DO NOT EDIT! === + +#ifndef SAMPLES_BRANCH_MUL_BRANCH_MUL_C_H_ +#define SAMPLES_BRANCH_MUL_BRANCH_MUL_C_H_ + +#include "iree/hal/local/executable_library.h" + +#if __cplusplus +extern "C" { +#endif // __cplusplus + +const iree_hal_executable_library_header_t** +llvm_module_linked_llvm_cpu_library_query( + iree_hal_executable_library_version_t max_version, + const iree_hal_executable_environment_v0_t* environment); + +#if __cplusplus +} +#endif // __cplusplus + +#endif // SAMPLES_BRANCH_MUL_BRANCH_MUL_C_H_
diff --git a/samples/branch_mul/branch_mul_c.o b/samples/branch_mul/branch_mul_c.o new file mode 100644 index 0000000..595940f --- /dev/null +++ b/samples/branch_mul/branch_mul_c.o Binary files differ
diff --git a/samples/branch_mul/branch_mul_expected.h b/samples/branch_mul/branch_mul_expected.h index c75b61a..4ef0a17 100644 --- a/samples/branch_mul/branch_mul_expected.h +++ b/samples/branch_mul/branch_mul_expected.h
@@ -1,5 +1,21 @@ -#ifndef DAREDEVIL_BRANCH_MUL_DAREDEVIL_BRANCH_MUL_EXPECTED_H_ -#define DAREDEVIL_BRANCH_MUL_DAREDEVIL_BRANCH_MUL_EXPECTED_H_ +/* + * Copyright 2023 Google LLC + * + * 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. + */ + +#ifndef SAMPLES_BRANCH_MUL_BRANCH_MUL_EXPECTED_H_ +#define SAMPLES_BRANCH_MUL_BRANCH_MUL_EXPECTED_H_ const int8_t expected[3][2][256] = { {{0x38, 0x38, 0x37, 0x37, 0x38, 0x32, 0x38, 0x39, 0x26, 0x3c, 0x38, 0x37, @@ -135,4 +151,4 @@ 0x38, 0x38, 0x41, 0x39, 0x39, 0x38, 0x36, 0x38, 0x23, 0x39, 0x38, 0x38, 0x36, 0x3a, 0x3a, 0x29}}}; -#endif // DAREDEVIL_BRANCH_MUL_DAREDEVIL_BRANCH_MUL_EXPECTED_H_ +#endif // SAMPLES_BRANCH_MUL_BRANCH_MUL_EXPECTED_H_