Skip to content

Commit

Permalink
fix sam GM issue (#13870)
Browse files Browse the repository at this point in the history
- remove stablehlo part to reduce size of generated files

ONE-DCO-1.0-Signed-off-by: Chunseok Lee <[email protected]>
  • Loading branch information
chunseoklee authored Sep 3, 2024
1 parent cdcd9ad commit 48fd493
Show file tree
Hide file tree
Showing 2 changed files with 262 additions and 0 deletions.
6 changes: 6 additions & 0 deletions onert-micro/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ else ()

set(SCHEMA_FILE "${NNAS_PROJECT_SOURCE_DIR}/res/CircleSchema/0.8/circle_schema.fbs")

# need patch to circle schema 0.8 to resolve SAM issue
set(PATCH_FILE ${CMAKE_CURRENT_SOURCE_DIR}/remove_stablehlo_from_cir0.8.patch)
execute_process(COMMAND ${CMAKE_COMMAND} -E chdir ${NNAS_PROJECT_SOURCE_DIR} git apply ${PATCH_FILE}
WORKING_DIRECTORY "${NNAS_PROJECT_SOURCE_DIR}"
)

# NOTE Copy circle_schema.fbs as schema.fbs to generate "schema_generated.fbs" instead of "circle_schema_generated.fbs"
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/schema.fbs"
COMMAND ${CMAKE_COMMAND} -E copy "${SCHEMA_FILE}" schema.fbs
Expand Down
256 changes: 256 additions & 0 deletions onert-micro/remove_stablehlo_from_cir0.8.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
diff --git a/res/CircleSchema/0.8/circle_schema.fbs b/res/CircleSchema/0.8/circle_schema.fbs
index 460fa43ee1..be67c3f83c 100644
--- a/res/CircleSchema/0.8/circle_schema.fbs
+++ b/res/CircleSchema/0.8/circle_schema.fbs
@@ -442,52 +442,6 @@ enum BuiltinOperator : int32 {
BITCAST = 159,
BITWISE_XOR = 160,
RIGHT_SHIFT = 161,
- // All Operators start with STABLEHLO_ prefixes are subject to change
- // Many of the ops below can not be executed by runtime
- STABLEHLO_LOGISTIC = 162, // WARNING: Do not have runtime support
- STABLEHLO_ADD = 163, // WARNING: No runtime support yet
- STABLEHLO_DIVIDE = 164, // WARNING: No runtime support yet
- STABLEHLO_MULTIPLY = 165, // WARNING: No runtime support yet
- STABLEHLO_MAXIMUM = 166, // WARNING: No runtime support yet
- STABLEHLO_RESHAPE = 167, // WARNING: No runtime support yet
- STABLEHLO_CLAMP = 168, // WARNING: No runtime support
- STABLEHLO_CONCATENATE = 169, // WARNING: No runtime support
- STABLEHLO_BROADCAST_IN_DIM = 170, // WARNING: No runtime support
- STABLEHLO_CONVOLUTION = 171, // WARNING: No runtime support
- STABLEHLO_SLICE = 172, // WARNING: No runtime support
- STABLEHLO_CUSTOM_CALL = 173, // WARNING: No runtime support
- STABLEHLO_REDUCE = 174, // WARNING: No runtime support
- STABLEHLO_ABS = 175, // WARNING: No runtime support
- STABLEHLO_AND = 176, // WARNING: No runtime support
- STABLEHLO_COSINE = 177, // WARNING: No runtime support
- STABLEHLO_EXPONENTIAL = 178, // WARNING: No runtime support
- STABLEHLO_FLOOR = 179, // WARNING: No runtime support
- STABLEHLO_LOG = 180, // WARNING: No runtime support
- STABLEHLO_MINIMUM = 181, // WARNING: No runtime support
- STABLEHLO_NEGATE = 182, // WARNING: No runtime support
- STABLEHLO_OR = 183, // WARNING: No runtime support
- STABLEHLO_POWER = 184, // WARNING: No runtime support
- STABLEHLO_REMAINDER = 185, // WARNING: No runtime support
- STABLEHLO_RSQRT = 186, // WARNING: No runtime support
- STABLEHLO_SELECT = 187, // WARNING: No runtime support
- STABLEHLO_SUBTRACT = 188, // WARNING: No runtime support
- STABLEHLO_TANH = 189, // WARNING: No runtime support
- STABLEHLO_SCATTER = 190,
- STABLEHLO_COMPARE = 191, // WARNING: No runtime support
- STABLEHLO_CONVERT = 192, // WARNING: No runtime support
- STABLEHLO_DYNAMIC_SLICE = 193, // WARNING: No runtime support
- STABLEHLO_DYNAMIC_UPDATE_SLICE = 194, // WARNING: No runtime support
- STABLEHLO_PAD = 195, // WARNING: No runtime support
- STABLEHLO_IOTA = 196, // WARNING: No runtime support
- STABLEHLO_DOT_GENERAL = 197, // WARNING: No runtime support
- STABLEHLO_REDUCE_WINDOW = 198, // WARNING: No runtime support
- STABLEHLO_SORT = 199, // WARNING: No runtime support
- STABLEHLO_WHILE = 200, // WARNING: No runtime support
- STABLEHLO_GATHER = 201, // WARNING: No runtime support
- STABLEHLO_TRANSPOSE = 202, // WARNING: No runtime support
- DILATE = 203,
- STABLEHLO_RNG_BIT_GENERATOR = 204,
- REDUCE_WINDOW = 205,
}
// LINT.ThenChange(nnapi_linter/linter.proto)

@@ -625,187 +579,8 @@ union BuiltinOptions {
InstanceNormOptions = 254,
}

-union BuiltinOptions2{
- StablehloConcatenateOptions,
- StablehloBroadcastInDimOptions,
- StablehloSliceOptions,
- StablehloConvolutionOptions,
- StablehloCustomCallOptions,
- StablehloReduceOptions,
- StablehloScatterOptions,
- StablehloCompareOptions,
- StablehloDynamicSliceOptions,
- StablehloPadOptions,
- StablehloIotaOptions,
- StablehloDotGeneralOptions,
- StablehloReduceWindowOptions,
- StablehloSortOptions,
- StablehloWhileOptions,
- StablehloGatherOptions,
- StablehloTransposeOptions,
- DilateOptions,
- StablehloRngBitGeneratorOptions,
- ReduceWindowOptions,
-}
-
-table StablehloGatherOptions{
- offset_dims : [long];
- collapsed_slice_dims : [long];
- start_index_map : [long];
- index_vector_dim : long;
- slice_sizes : [long];
- indices_are_sorted : bool;
-}
-
-table StablehloTransposeOptions{
- permutation : [long];
-}
-
-enum StablehloPrecisionConfig : uint {
- DEFAULT,
- HIGH,
- HIGHEST,
-}
-
-table StablehloDotGeneralOptions{
- lhs_batching_dimensions : [long];
- rhs_batching_dimensions : [long];
- lhs_contracting_dimensions : [long];
- rhs_contracting_dimensions : [long];
- precision_config : [StablehloPrecisionConfig];
-}
-
-table StablehloReduceWindowOptions{
- window_dimensions : [long];
- window_strides : [long];
- base_dilations : [long];
- window_dilations : [long];
- padding : [long];
- body_subgraph_index : int;
-}
-
-table StablehloWhileOptions{
- cond_subgraph_index : int;
- body_subgraph_index : int;
-}
-
-table StablehloSortOptions{
- dimension : long;
- is_stable : bool;
- comparator_subgraph_index : int;
-}
-
-table StablehloConcatenateOptions {
- dimension : long;
-}
-
-table StablehloBroadcastInDimOptions{
- broadcast_dimensions : [long];
-}
-
-enum StablehloComparisonDirection : uint {
- STABLEHLO_COMPARISON_DIRECTION_EQ,
- STABLEHLO_COMPARISON_DIRECTION_NE,
- STABLEHLO_COMPARISON_DIRECTION_GE,
- STABLEHLO_COMPARISON_DIRECTION_GT,
- STABLEHLO_COMPARISON_DIRECTION_LE,
- STABLEHLO_COMPARISON_DIRECTION_LT,
-
-}
-
-enum StablehloComparisonType : uint {
- STABLEHLO_COMPARISON_TYPE_NOTYPE,
- STABLEHLO_COMPARISON_TYPE_FLOAT,
- STABLEHLO_COMPARISON_TYPE_FLOAT_TOTAL_ORDER,
- STABLEHLO_COMPARISON_TYPE_SIGNED,
- STABLEHLO_COMPARISON_TYPE_UNSIGNED,
-}
-
-table StablehloCompareOptions{
- comparison_direction : StablehloComparisonDirection;
- compare_type : StablehloComparisonType;
-}
-
-table StablehloDynamicSliceOptions{
- slice_sizes : [long];
-}
-
-table StablehloPadOptions{
- edge_padding_low : [long];
- edge_padding_high : [long];
- interior_padding : [long];
-}
-
-table StablehloIotaOptions{
- iota_dimension : long;
-}
-
-table StablehloCustomCallOptions {
- call_target_name : string;
- has_side_effect : bool;
- backend_config: string;
- api_version : int; // will be decprecated
- called_computations: [int]; // should point to subgraphs of the computations
- custom_attributes : [ubyte];
-}
-
-table StablehloReduceOptions {
- dimensions : [long];
- body_subgraph_index : int;
-}
-
-table StablehloSliceOptions{
- start_indices : [long];
- limit_indices : [long];
- strides : [long];
-}
-
-table StablehloConvolutionOptions{
- window_strides : [long];
- padding : [long];
- lhs_dilation : [long];
- rhs_dilation : [long];
- window_reversal : [bool];
- input_batch_dimension : long;
- input_feature_dimension : long;
- input_spatial_dimensions : [long];
- kernel_input_feature_dimension : long;
- kernel_output_feature_dimension : long;
- kernel_spatial_dimensions : [long];
- output_batch_dimension : long;
- output_feature_dimension : long;
- output_spatial_dimensions : [long];
- feature_group_count : long;
- batch_group_count : long;
- precision_config : [StablehloPrecisionConfig];
-}
-
-table StablehloScatterOptions {
- indices_are_sorted: bool;
- update_window_dims: [long];
- inserted_window_dims: [long];
- scatter_dims_to_operand_dims: [long];
- index_vector_dim: long;
- unique_indices: bool;
- update_computation_subgraph_index: int;
-}
-
-enum RngAlgorithm : byte {
- // An algorithm auto-selected by the system according to device type.
- DEFAULT = 0,
- // The Philox algorithm, as described in paper
- // ['Parallel Random Numbers: As Easy as 1, 2, 3']
- // (https://www.thesalmons.org/john/random123/papers/random123sc11.pdf)
- PHILOX = 1,
- // The ThreeFry algorithm, as described in paper
- // ['Parallel Random Numbers: As Easy as 1, 2, 3']
- // (https://www.thesalmons.org/john/random123/papers/random123sc11.pdf)
- THREEFRY = 2,
-}
-
-table StablehloRngBitGeneratorOptions {
- algorithm:RngAlgorithm;
-}
+//union BuiltinOptions2{
+//}

// LINT.IfChange
enum Padding : byte { SAME, VALID }
@@ -1582,7 +1357,7 @@ table Operator {
// Flatbuffers union struct has a 128 elements limit in JAVA, so a second
// union is added, in the case of where BuitlinOptions2 runs out, a third
// one can be added
- builtin_options_2 : BuiltinOptions2;
+ //builtin_options_2 : BuiltinOptions2;
}

// The root type, defining a subgraph, which typically represents an entire

0 comments on commit 48fd493

Please sign in to comment.