Code Monkey home page Code Monkey logo

mlir-emitc's Introduction

MLIR-EmitC

Build and test

MLIR-EmitC provides a way to translate ML models into C++ code. The repository contains scripts and tools to translate Keras and TensorFlow models into the TOSA and StableHLO dialect and to convert those to EmitC. The latter is used to generate calls to a reference implementation.

The EmitC dialect itself, as well as the C++ emitter, are part of MLIR core and are no longer provided via this repository.

The initial EmitC dialect and C++ emitter checked into this repository were forked from https://reviews.llvm.org/D76571.

DISCLAIMER: This is a research project and not intended for everyday use. The code is made available without any support. However, we welcome any kind of feedback via the issue tracker.

Getting Started

Clone

git clone https://github.com/iml130/mlir-emitc.git
cd mlir-emitc
git submodule update --init

Build and Run

There are two variants to build EmitC: As part of an LLVM/MLIR build (via the LLVM external projects mechanism) and against a pre-built LLVM/MLIR.

Building with pre-built LLVM/MLIR

The setup assumes that you have built LLVM and MLIR in $BUILD_DIR and installed them to $PREFIX. You can use the build_tools/build_mlir.sh shell script to configure, build and install LLVM and MLIR.

Note: The hash of the latest tested LLVM version is given in build_tools/llvm_version.txt. Since MLIR evolves fast, it is possible that EmitC fails to build with a newer LLVM.

To build and launch the tests, run

mkdir build && cd build
cmake -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ .. -DMLIR_DIR=$PREFIX/lib/cmake/mlir -DLLVM_EXTERNAL_LIT=$BUILD_DIR/bin/llvm-lit
cmake --build . --target check-emitc

Note: If you don't use build_tools/build_mlir.sh, make sure to pass -DLLVM_INSTALL_UTILS=ON when building LLVM with CMake in order to install FileCheck to the chosen installation prefix.

To additionally build and execute the unittests, run

cmake --build . --target MLIREmitCTests
./reference-implementation/unittests/MLIREmitCTests

Bulding as part of an LLVM/MLIR build

MLIR-EmitC can also be built as part of an LLVM/MLIR build, using the LLVM_EXTERNAL_PROJECTS mechanism (see https://llvm.org/docs/CMake.html).

To build and launch the tests, run

mkdir build && cd build
cmake -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release -DEMITC_ENABLE_HLO=OFF -DLLVM_ENABLE_PROJECTS=mlir -DLLVM_EXTERNAL_PROJECTS="mlir-emitc" -DLLVM_EXTERNAL_MLIR_EMITC_SOURCE_DIR=`realpath ../` -DLLVM_TARGETS_TO_BUILD=host ${ROOT_PATH_TO_llvm-project}/llvm
cmake --build . --target check-emitc

Supported Conversions and Translations

Conversions are supported for StableHLO ops and some ops of the arith and Tensor dialect. In addition, support for converting Tensor Operator Set Architecture (TOSA) dialect to EmitC is emerging. The emitc-opt tool supports the following options:

option
--convert-func-to-emitc Convert Func dialect to EmitC dialect
--convert-scf-to-emitc Convert SCF dialect to EmitC dialect, maintaining structured control flow
--convert-stablehlo-region-ops-to-emitc Convert StableHLO operations containing regions to EmitC dialect.
--convert-stablehlo-to-emitc Convert from StableHLO dialect to EmitC dialect.
--convert-arith-to-emitc-ext Convert arith dialect to EmitC dialect (extended).
--convert-tensor-to-emitc Convert tensor dialect to EmitC dialect.
--convert-tosa-to-emitc Convert TOSA dialect to EmitC dialect.
--insert-emitc-stablehlo-include Insert an EmitC include for the StableHLO dialect.
--insert-emitc-arith-include Insert an EmitC include for the arith dialect.
--insert-emitc-tensor-include Insert an EmitC include for the tensor dialect.
--insert-emitc-tosa-include Insert an EmitC include for the TOSA dialect.
--stablehlo-to-emitc-pipeline Run the StableHLO to EmitC pipeline.
--arith-to-emitc-pipeline Run the Arithmetic to EmitC pipeline.
--tensor-to-emitc-pipeline Run the Tensor to EmitC pipeline.
--tosa-to-emitc-pipeline Run the TOSA to EmitC pipeline.

The currently supported StableHLO ops are listed in the docs/stablehlo-op-coverage.md document. Supported TOSA ops are listed in the docs/tosa-op-coverage.md document.

After converting to EmitC dialect, C++ code can be emitted using emitc-translate --mlir-to-cpp. Furthermore, emitc-translate has specific support to emit code with variables declared at top using --mlir-to-cpp --declare-variables-at-top.

mlir-emitc's People

Contributors

dajuro avatar dependabot[bot] avatar heidebro avatar henri-gruender avatar jacob-hegna avatar jpienaar avatar lucas-camp avatar marbre avatar natashaknk avatar oliverscherf avatar simon-camp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mlir-emitc's Issues

Readme references a missing file

The readme refers to build_tools/build.sh this file does not exists. Instead build_mlir.sh exists. It looks to me as if the readme should be updated to reflect this name. Or is a file missing?

Composing legalizations

It appears as if the legalization passes can't be composed to handle an input file consisting of TOSA and MHLO ops to EmitC.

Refactor types of attributes passed in TOSA reference implementation

As part of #389, MLIR gets upgraded to a version in which the types the attributes of some TOSA operations where changes. Instead of i64, the arguments are now of type i32. This matches the latest TOSA standard. Our reference implementation does not yet reflects this and still expects arguments of type int64_t. The implementation for the following ops should be refactored if necessary:

  • concat
  • argmax
  • reduce_all
  • reduce_any
  • reduce_max
  • reduce_min
  • reduce_prod
  • reduce_sum

C/C++ generated code sample

Hi,

Is it possible to include one or more examples of generated C/C++ from MLIR in the repository or have a link in the README for examples on this?

I am interested in particular with complicated expression trees. For example, how the Pythagoras theorem formula would look. I understand that MLIR has a 3 address operation constraint. How something like this would come out? In multiple lines or a single line of C++ code? It would be nice to see it like the latter, because otherwise it could look like assembly language in C++.

Sorry for writing here, I did not find another way of communicating this.

Thanks,
Ivan

cmake error

Hi,
I tried to build an run emit C, so I followed the steps in README.
I used [build_tools/build_mlir.sh](https://github.com/iml130/mlir-emitc/blob/main/build_tools/build_mlir.sh) to build and install LLVM and MLIR and set BUILD_DIR and PREFIX.
Here is my setting about BUILD_DIR and PREFIX.

setenv BUILD_DIR "/users/student/mr108/cwlu19/ic8/mlir-emitc/llvm/llvm-build"
setenv PREFIX "/users/student/mr108/cwlu19/ic8/mlir-emitc/llvm-install"

After I run the command cmake -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ .. -DMLIR_DIR=$PREFIX/lib/cmake/mlir -DLLVM_EXTERNAL_LIT=$BUILD_DIR/bin/llvm-lit, I met this error.

CMake Error at llvm-install/lib/cmake/llvm/AddLLVM.cmake:512 (add_dependencies):
  The dependency target "MLIRArithmetic" of target "obj.GmlStTilingInterface"
  does not exist.
Call Stack (most recent call first):
  llvm-install/lib/cmake/mlir/AddMLIR.cmake:130 (llvm_add_library)
  third_party/mlir-hlo/lib/Dialect/gml_st/transforms/CMakeLists.txt:20 (add_mlir_library)


CMake Error at llvm-install/lib/cmake/llvm/AddLLVM.cmake:512 (add_dependencies):
  The dependency target "MLIRArithmetic" of target "obj.MhloToLhloConversion"
  does not exist.
Call Stack (most recent call first):
  llvm-install/lib/cmake/mlir/AddMLIR.cmake:130 (llvm_add_library)
  third_party/mlir-hlo/lib/Dialect/mhlo/transforms/CMakeLists.txt:96 (add_mlir_library)


CMake Error at llvm-install/lib/cmake/llvm/AddLLVM.cmake:512 (add_dependencies):
  The dependency target "MLIRArithmeticTransforms" of target
  "obj.MhloToLhloConversion" does not exist.
Call Stack (most recent call first):
  llvm-install/lib/cmake/mlir/AddMLIR.cmake:130 (llvm_add_library)
  third_party/mlir-hlo/lib/Dialect/mhlo/transforms/CMakeLists.txt:96 (add_mlir_library)


CMake Error at llvm-install/lib/cmake/llvm/AddLLVM.cmake:512 (add_dependencies):
  The dependency target "MLIRArithmetic" of target "obj.MLIRMhloUtils" does
  not exist.
Call Stack (most recent call first):
  llvm-install/lib/cmake/mlir/AddMLIR.cmake:130 (llvm_add_library)
  third_party/mlir-hlo/lib/utils/CMakeLists.txt:17 (add_mlir_library)


CMake Error at llvm-install/lib/cmake/llvm/AddLLVM.cmake:939 (add_dependencies):
  The dependency target "MLIRAffineAnalysis" of target "emitc-opt" does not
  exist.
Call Stack (most recent call first):
  tools/emitc-opt/CMakeLists.txt:46 (add_llvm_executable)

Did I misunderstand anything?
Thanks!

Question about test file

Hi,
There are Mobilenetv2 files in MLIR, but these files are not manual.
I wonder that where could I find the original files to generate these MLIR files.
Thanks!

Invalid Pass Pipeline

Hi,
Thanks for reply of last issue.
I tried to use e2e_test.sh to generate model in EmitC dialect.
Here is my command.
./e2e_test_tosa.sh saved_model/my_model/ ../reference-implementation/include/ ../build/bin/ clang 32 0 /workspace/mlir-emitc/scripts/test_e2e/

Here is the error message I got.

File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_mlir.py", line 84, in experimental_run_pass_pipeline
    mlir_txt.encode('utf-8'), pass_pipeline.encode('utf-8'), show_debug_info)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Invalid pass_pipeline: MLIR Textual PassPipeline Parser:1:105: error: 'tf-device-decompose-resource-ops' does not refer to a registered pass or pass pipeline
symbol-dce,tf-standard-pipeline,builtin.func(tf-device-index-selector),inline,canonicalize,builtin.func(tf-device-decompose-resource-ops),builtin.func(tf-functional-control-flow-to-cfg),inline,symbol-dce,canonicalize,tf-saved-model-optimize-global-tensors,tf-saved-model-freeze-global-tensors

Did I misunderstand anything?

I also tried to use savedmodel_to_tf_dialect.py and tf_to_tosa_dialect.py to achieve the goal.
When I ran tf_to_tosa_dialect.py, I got the similar error message.

File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_mlir.py", line 84, in experimental_run_pass_pipeline
    mlir_txt.encode('utf-8'), pass_pipeline.encode('utf-8'), show_debug_info)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Invalid pass_pipeline: MLIR Textual PassPipeline Parser:1:100: error: 'tosa-fuse-bias-tf' does not refer to a registered pass or pass pipeline
inline,canonicalize,cse,builtin.func(affine-loop-fusion),builtin.func(affine-scalrep),builtin.func(tosa-fuse-bias-tf),builtin.func(tosa-legalize-tf),builtin.func(tosa-infer-shapes),builtin.func(tosa-make-broadcastable),inline,symbol-dce

Thanks for helping a lot!

Safe keras models in newer file format

After testing #392 I spotted some warnings about the usage of legacy file formats in our example scripts. The .keras file format if preferred over the plain .h5 format as mentioned in the docs. We should update our scripts accordingly.

Refactor type of shift argument passed to tosa.rescale

With #405, the TOSA spec changed the type of the shift argument from i32 to i8. The reference implementation still expects an int32_t whereas an int8_t is passed in the generated code. Consequently, the type in the reference implementation should be refactored from int32_t to int8_t.

Translating model from tf_saved_model to mhlo fails

I am trying to convert the following tf model using translate_model.py but it fails with the following error:

./tmp2.mlir:4:3: error: is not immutable, try running tf-saved-model-optimize-global-tensors to prove tensors are immutable
  "tf_saved_model.global_tensor"() {is_mutable, sym_name = "__sm_node5__m.conv2d.kernel", tf_saved_model.exported_names = ["m.conv2d.kernel", "m.conv2d.variables.0", "m.conv2d.keras_api.variables.0", "m.conv2d.trainable_variables.0", "m.conv2d.keras_api.trainable_variables.0"],

This comes up when tf_opt is used and tf-saved-model-optimize-global-tensors flag is encountered.
The following is the model for your reference:


class Model(tf.keras.Model):
    def __init__(self):
        super(Model, self).__init__()
        self.conv2d = tf.keras.layers.Conv2D(32, (3, 3), (1, 1), data_format='channels_last', use_bias=False)

    def call(self, input):
        x = self.conv2d(input)
        x = tf.nn.relu(x)
        y = self.conv2d(input)
        y = tf.nn.relu(y)
        return x + y

I also tried converting an mnist model but it fails at translation itself (tf-mlir-translate):

2020-09-24 18:27:21.207388: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.11.0
2020-09-24 18:27:21.260534: I tensorflow/cc/saved_model/bundle_v2.cc:32] Reading SavedModel from: ./tf_mnist/tf_saved_model
2020-09-24 18:27:21.261778: I tensorflow/cc/saved_model/bundle_v2.cc:55] Reading SavedModel debug info (if present) from: ./tf_mnist/tf_saved_model
2020-09-24 18:27:21.300066: E tensorflow/compiler/mlir/tensorflow/translate/tf_mlir_translate.cc:163] SavedModel import failed: Invalid argument: Exported function with exported name(s) 'm.flatten.__call__', 'm.flatten.keras_api.__call__' with multiple concrete functions. Add @tf.function(input_signature=[...]) on this function, or use a narrower list of exported names that excludes this function.

Error building package: gtest CMake "gtest" and "gtest_main" name already exists

I'm trying to build the package off cgo branch and I encountered the following error:

CMake Error at third_party/googletest/googletest/cmake/internal_utils.cmake:150 (add_library):
  add_library cannot create target "gtest" because an imported target with
  the same name already exists.
Call Stack (most recent call first):
  third_party/googletest/googletest/cmake/internal_utils.cmake:206 (cxx_library_with_type)
  third_party/googletest/googletest/CMakeLists.txt:128 (cxx_library)


CMake Error at third_party/googletest/googletest/cmake/internal_utils.cmake:150 (add_library):
  add_library cannot create target "gtest_main" because an imported target
  with the same name already exists.
Call Stack (most recent call first):
  third_party/googletest/googletest/cmake/internal_utils.cmake:206 (cxx_library_with_type)
  third_party/googletest/googletest/CMakeLists.txt:130 (cxx_library)


CMake Error at third_party/googletest/googletest/CMakeLists.txt:143 (target_link_libraries):
  Cannot specify link libraries for target "gtest_main" which is not built by
  this project.

Any help would be appreciated, thanks!

Refactor type of shift argument passed to tosa.mul

With #392, the TOSA spec changed the type of the shift argument from i32 to i8, as evident in the tests (see diff). The reference implementation however still expects an int32_t whereas the generated code passes an int8_t. Thus, the type in the reference implementation could be changed from int32_t to int8_t.

Variadic MHLO reduce support

Currently the converter doesn't support MHLO reduce with variadic reduce, so computations like

%752:2 = mhlo.reduce(%748 init: %750), (%749 init: %751) across dimensions = [1] : (tensor<1x2xf32>, tensor<1x2xi32>, tensor<f32>, tensor<i32>) -> (tensor<1xf32>, tensor<1xi32>)
     reducer(%arg35: tensor<f32>, %arg37: tensor<f32>) (%arg36: tensor<i32>, %arg38: tensor<i32>)  {
      %764 = "mhlo.compare"(%arg35, %arg37) {comparison_direction = "GE"} : (tensor<f32>, tensor<f32>) -> tensor<i1>
      %765 = "mhlo.select"(%764, %arg35, %arg37) : (tensor<i1>, tensor<f32>, tensor<f32>) -> tensor<f32>
      %766 = "mhlo.compare"(%arg35, %arg37) {comparison_direction = "EQ"} : (tensor<f32>, tensor<f32>) -> tensor<i1>
      %767 = mhlo.minimum %arg36, %arg38 : tensor<i32>
      %768 = "mhlo.select"(%764, %arg36, %arg38) : (tensor<i1>, tensor<i32>, tensor<i32>) -> tensor<i32>
      %769 = "mhlo.select"(%766, %767, %768) : (tensor<i1>, tensor<i32>, tensor<i32>) -> tensor<i32>
      "mhlo.return"(%765, %769) : (tensor<f32>, tensor<i32>) -> ()
    }

doesn't convert.

Support missing operations to enable running some standard models

The following operations are missing / need to be updated to support inference of some popular CNNs. (Based on models from tf.keras.Applications)

MobileNet(V2)

  • batch_norm_inference
  • clamp
  • pad
  • reduce
  • convolution (depthwise)

ResNet50

  • batch_norm_inference
  • pad
  • reduce
  • reduce_window

Extend mhlo::concatenate

As previously filled in #41, we need to extend mhlo::concaternate for one of our internally used models. According to @OliverScherf the MLIR snippet

Tensor4D<float, 1, 59, 87, 64> v101 = mhlo::max<>(v100, v74);
Tensor4D<float, 1, 59, 87, 64> v105 = mhlo::max<>(v104, v74);
Tensor4D<float, 1, 59, 87, 128> v106 = mhlo::concatenate<3, Tensor4D<float, 1, 59, 87, 128>>(v101, v105);

results in the error message below:

/home/oliver/git/mlir-emitc/include/emitc/emitc_mhlo.h: In instantiation of ‘Dest mhlo::concatenate(Src1, Src ...) [with long int Dimension = 3; Dest = Tensor<float, 1, 59, 87, 128>; Src1 = Tensor<float, 1, 59, 87, 64>; Src = {Tensor<float, 1, 59, 87, 64>}]’:
model_generated.h:123:104:   required from here
/home/oliver/git/mlir-emitc/include/emitc/emitc_mhlo.h:458:9: error: no type named ‘type’ in ‘struct concat<3, float, Tensor<float, 1, 59, 87, 64> >’
  458 |   using Rest = typename concat<Dimension, ET_Src, Src...>::type;
      |         ^~~~
/home/oliver/git/mlir-emitc/include/emitc/emitc_mhlo.h: In instantiation of ‘Dest mhlo::concatenate(Src1, Src ...) [with long int Dimension = 3; Dest = Tensor<float, 1, 29, 43, 256>; Src1 = Tensor<float, 1, 29, 43, 128>; Src = {Tensor<float, 1, 29, 43, 128>}]’:
model_generated.h:151:104:   required from here
/home/oliver/git/mlir-emitc/include/emitc/emitc_mhlo.h:458:9: error: no type named ‘type’ in ‘struct concat<3, float, Tensor<float, 1, 29, 43, 128> >’
/home/oliver/git/mlir-emitc/include/emitc/emitc_mhlo.h: In instantiation of ‘Dest mhlo::concatenate(Src1, Src ...) [with long int Dimension = 3; Dest = Tensor<float, 1, 14, 21, 384>; Src1 = Tensor<float, 1, 14, 21, 192>; Src = {Tensor<float, 1, 14, 21, 192>}]’:
model_generated.h:179:104:   required from here

Extend mhlo::slice for Tensor3D

As previously filled in #41, we need to extend mhlo::slice for Tensor3D:

model_generated.h:251:114: error: no matching function for call to ‘slice<Tensor3D<float, 1, 882, 1> >(Tensor3D<float, 1, 882, 6>&, <brace-enclosed initializer list>, <brace-enclosed initializer list>, <brace-enclosed initializer list>)’
  251 | Tensor3D<float, 1, 882, 1> v234 = mhlo::slice<Tensor3D<float, 1, 882, 1>>(v233, {0, 0, 5}, {1, 882, 6}, {1, 1, 1});
      |                                                                                                                  ^
In file included from model_generated.h:3,
                 from test.cpp:2:
/home/oliver/git/mlir-emitc/include/emitc/emitc_mhlo.h:498:6: note: candidate: ‘template<class Dest, class Src, typename std::enable_if<is_tensor_of_dim<1, Src, void>::value, bool>::type <anonymous> > Dest mhlo::slice(Src, Tensor1D<long int, 1>, Tensor1D<long int, 1>, Tensor1D<long int, 1>)’
  498 | Dest slice(Src x, Tensor1D<int64_t, 1> start_indices,
      |      ^~~~~
/home/oliver/git/mlir-emitc/include/emitc/emitc_mhlo.h:498:6: note:   template argument deduction/substitution failed:
/home/oliver/git/mlir-emitc/include/emitc/emitc_mhlo.h:497:64: error: no type named ‘type’ in ‘struct std::enable_if<false, bool>’
  497 | template <typename Dest, typename Src, IsTensorOfDim<1, Src> = true>
      |                                                                ^~~~
/home/oliver/git/mlir-emitc/include/emitc/emitc_mhlo.h:512:6: note: candidate: ‘template<class Dest, class Src, typename std::enable_if<is_tensor_of_dim<2, Src, void>::value, bool>::type <anonymous> > Dest mhlo::slice(Src, Tensor1D<long int, 2>, Tensor1D<long int, 2>, Tensor1D<long int, 2>)’
  512 | Dest slice(Src x, Tensor1D<int64_t, 2> start_indices,
      |      ^~~~~
/home/oliver/git/mlir-emitc/include/emitc/emitc_mhlo.h:512:6: note:   template argument deduction/substitution failed:
/home/oliver/git/mlir-emitc/include/emitc/emitc_mhlo.h:511:64: error: no type named ‘type’ in ‘struct std::enable_if<false, bool>’
  511 | template <typename Dest, typename Src, IsTensorOfDim<2, Src> = true>
      |                                                                ^~~~

Missing Operations in emitC MHLO

For a current use-case I need two missing operations in emitC MHLO:

  • mhlo::slice with Tensor3D
model_generated.h:251:114: error: no matching function for call to ‘slice<Tensor3D<float, 1, 882, 1> >(Tensor3D<float, 1, 882, 6>&, <brace-enclosed initializer list>, <brace-enclosed initializer list>, <brace-enclosed initializer list>)’
  251 | Tensor3D<float, 1, 882, 1> v234 = mhlo::slice<Tensor3D<float, 1, 882, 1>>(v233, {0, 0, 5}, {1, 882, 6}, {1, 1, 1});
      |                                                                                                                  ^
In file included from model_generated.h:3,
                 from test.cpp:2:
/home/oliver/git/mlir-emitc/include/emitc/emitc_mhlo.h:498:6: note: candidate: ‘template<class Dest, class Src, typename std::enable_if<is_tensor_of_dim<1, Src, void>::value, bool>::type <anonymous> > Dest mhlo::slice(Src, Tensor1D<long int, 1>, Tensor1D<long int, 1>, Tensor1D<long int, 1>)’
  498 | Dest slice(Src x, Tensor1D<int64_t, 1> start_indices,
      |      ^~~~~
/home/oliver/git/mlir-emitc/include/emitc/emitc_mhlo.h:498:6: note:   template argument deduction/substitution failed:
/home/oliver/git/mlir-emitc/include/emitc/emitc_mhlo.h:497:64: error: no type named ‘type’ in ‘struct std::enable_if<false, bool>’
  497 | template <typename Dest, typename Src, IsTensorOfDim<1, Src> = true>
      |                                                                ^~~~
/home/oliver/git/mlir-emitc/include/emitc/emitc_mhlo.h:512:6: note: candidate: ‘template<class Dest, class Src, typename std::enable_if<is_tensor_of_dim<2, Src, void>::value, bool>::type <anonymous> > Dest mhlo::slice(Src, Tensor1D<long int, 2>, Tensor1D<long int, 2>, Tensor1D<long int, 2>)’
  512 | Dest slice(Src x, Tensor1D<int64_t, 2> start_indices,
      |      ^~~~~
/home/oliver/git/mlir-emitc/include/emitc/emitc_mhlo.h:512:6: note:   template argument deduction/substitution failed:
/home/oliver/git/mlir-emitc/include/emitc/emitc_mhlo.h:511:64: error: no type named ‘type’ in ‘struct std::enable_if<false, bool>’
  511 | template <typename Dest, typename Src, IsTensorOfDim<2, Src> = true>
      |                                                                ^~~~
  • mhlo::concatenate

Code that causes the issue:

Tensor4D<float, 1, 59, 87, 64> v101 = mhlo::max<>(v100, v74);
Tensor4D<float, 1, 59, 87, 64> v105 = mhlo::max<>(v104, v74);
Tensor4D<float, 1, 59, 87, 128> v106 = mhlo::concatenate<3, Tensor4D<float, 1, 59, 87, 128>>(v101, v105);

Error message:

/home/oliver/git/mlir-emitc/include/emitc/emitc_mhlo.h: In instantiation of ‘Dest mhlo::concatenate(Src1, Src ...) [with long int Dimension = 3; Dest = Tensor<float, 1, 59, 87, 128>; Src1 = Tensor<float, 1, 59, 87, 64>; Src = {Tensor<float, 1, 59, 87, 64>}]’:
model_generated.h:123:104:   required from here
/home/oliver/git/mlir-emitc/include/emitc/emitc_mhlo.h:458:9: error: no type named ‘type’ in ‘struct concat<3, float, Tensor<float, 1, 59, 87, 64> >’
  458 |   using Rest = typename concat<Dimension, ET_Src, Src...>::type;
      |         ^~~~
/home/oliver/git/mlir-emitc/include/emitc/emitc_mhlo.h: In instantiation of ‘Dest mhlo::concatenate(Src1, Src ...) [with long int Dimension = 3; Dest = Tensor<float, 1, 29, 43, 256>; Src1 = Tensor<float, 1, 29, 43, 128>; Src = {Tensor<float, 1, 29, 43, 128>}]’:
model_generated.h:151:104:   required from here
/home/oliver/git/mlir-emitc/include/emitc/emitc_mhlo.h:458:9: error: no type named ‘type’ in ‘struct concat<3, float, Tensor<float, 1, 29, 43, 128> >’
/home/oliver/git/mlir-emitc/include/emitc/emitc_mhlo.h: In instantiation of ‘Dest mhlo::concatenate(Src1, Src ...) [with long int Dimension = 3; Dest = Tensor<float, 1, 14, 21, 384>; Src1 = Tensor<float, 1, 14, 21, 192>; Src = {Tensor<float, 1, 14, 21, 192>}]’:
model_generated.h:179:104:   required from here

Target MLIREmitCAllTests does not link with Debug configuration

When Building and Linking the MLIREmitCAllTests target in Debug mode the following linker errors occur:

build] [8/8 100% :: 3.835] Linking CXX executable unittests/MLIREmitCAllTests
[build] FAILED: unittests/MLIREmitCAllTests 
[build] : && /bin/clang++-10  -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough  -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -g   unittests/CMakeFiles/MLIREmitCAllTests.dir/emitc_mhlo.cpp.o unittests/CMakeFiles/MLIREmitCAllTests.dir/emitc_std.cpp.o unittests/CMakeFiles/MLIREmitCAllTests.dir/emitc_tensor.cpp.o  -o unittests/MLIREmitCAllTests  /home/oliver/git/install-mlir/lib/libLLVMSupport.a  /home/oliver/git/install-mlir/lib/libLLVMSupport.a  -lpthread  lib/libgtest_maind.a  lib/libgtestd.a  -lpthread  -lrt  -ldl  -lm  /usr/lib/x86_64-linux-gnu/libz.so  /usr/lib/x86_64-linux-gnu/libtinfo.so  /home/oliver/git/install-mlir/lib/libLLVMDemangle.a  -lpthread && :
[build] /bin/ld: unittests/CMakeFiles/MLIREmitCAllTests.dir/emitc_tensor.cpp.o: in function `(anonymous namespace)::tensor_meta_is_tensor_0d_Test::TestBody()':
[build] /home/oliver/git/mlir-emitc/build/../unittests/emitc_tensor.cpp:358: undefined reference to `is_tensor_of_dim<0ul, Tensor<unsigned short>, void>::value'
[build] /bin/ld: unittests/CMakeFiles/MLIREmitCAllTests.dir/emitc_tensor.cpp.o: in function `(anonymous namespace)::tensor_meta_is_tensor_1d_Test::TestBody()':
[build] /home/oliver/git/mlir-emitc/build/../unittests/emitc_tensor.cpp:377: undefined reference to `is_tensor_of_dim<1ul, Tensor<signed char, 12ul>, void>::value'
[build] /bin/ld: unittests/CMakeFiles/MLIREmitCAllTests.dir/emitc_tensor.cpp.o: in function `(anonymous namespace)::tensor_meta_is_tensor_2d_Test::TestBody()':
[build] /home/oliver/git/mlir-emitc/build/../unittests/emitc_tensor.cpp:396: undefined reference to `is_tensor_of_dim<2ul, Tensor<double, 3ul, 7ul>, void>::value'
[build] /bin/ld: unittests/CMakeFiles/MLIREmitCAllTests.dir/emitc_tensor.cpp.o: in function `(anonymous namespace)::tensor_meta_is_tensor_3d_Test::TestBody()':
[build] /home/oliver/git/mlir-emitc/build/../unittests/emitc_tensor.cpp:415: undefined reference to `is_tensor_of_dim<3ul, Tensor<float, 1ul, 4ul, 6ul>, void>::value'
[build] /bin/ld: unittests/CMakeFiles/MLIREmitCAllTests.dir/emitc_tensor.cpp.o: in function `(anonymous namespace)::tensor_meta_is_tensor_4d_Test::TestBody()':
[build] /home/oliver/git/mlir-emitc/build/../unittests/emitc_tensor.cpp:434: undefined reference to `is_tensor_of_dim<4ul, Tensor<unsigned char, 2ul, 1ul, 1ul, 9ul>, void>::value'

MLIR emitC Commit: d5a5f63a4abb96ef754531bac9a84180a2c04648 (cgo Branch)
LLVM Commit: d4e889f1f5723105dbab12b749503d2462eb1755
LLVM Build Type Release

When I build MLIREmitCAllTests in Release mode, everything compiles and links correctly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.