MCPcopy Create free account
hub / github.com/ROCm/AMDMIGraphX / parse

Method parse

src/targets/gpu/mlir.cpp:766–836  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

764 }
765
766 void parse(const module& m)
767 {
768 validate(m);
769 sym_name = get_symbol_name(m);
770 auto mbody = mlirModuleGetBody(mmodule.get());
771 std::unordered_map<instruction_ref, MlirValue> ins_map;
772 auto fbody = insert(mbody, m, ins_map);
773
774 for(auto ins : iterator_for(m))
775 {
776 if(ins->name() == "@param")
777 continue;
778 if(contains({"contiguous", "unpack_fp4"}, ins->name()))
779 {
780 ins_map[ins] = ins_map[ins->inputs().at(0)];
781 continue;
782 }
783 auto name = get_name(ins);
784 auto ops = create_operation_state(name);
785 ops.add_attribute_value(get_operator_value(ins));
786
787 // handles single output
788 if(ins->name() != "@return")
789 ops.add_results({get_shape_for_mlir(ins)});
790
791 if(ins->name() == "@literal")
792 {
793 literal r = ins->get_literal();
794
795 MlirType shaped_type = make_mlir_shaped(ins->get_shape());
796 MlirType tensor_type = rocmlirMIXRShapedTypeAsTensor(shaped_type);
797 MlirAttribute mlir_value_attr =
798 mlirDenseElementsAttrRawBufferGet(tensor_type, r.get_shape().bytes(), r.data());
799 ops.add_attributes({{"value", mlir_value_attr}});
800 }
801
802 if(ins->name() == "convolution" or ins->name() == "dot")
803 {
804 pp =
805 problem_params{ins->get_operator(), to_shapes(ins->inputs()), ins->get_shape()};
806 }
807
808 std::vector<MlirValue> inputs;
809 transform(
810 ins->inputs(), std::back_inserter(inputs), [&](auto i) { return ins_map.at(i); });
811 if(ins->name() == "quant_dot")
812 {
813 if(ins->inputs().size() == 4)
814 {
815 // Specify operand segment sizes BEFORE creating the operation so MLIR sees it.
816 // Use the canonical MLIR attribute name 'operandSegmentSizes'.
817 const std::vector<int> seg_sizes = {1, 1, 1, 1};
818 ops.set_operand_segment_sizes(seg_sizes);
819 }
820 else if(ins->inputs().size() == 2)
821 {
822 const std::vector<int> seg_sizes = {1, 1, 0, 0};
823 ops.set_operand_segment_sizes(seg_sizes);

Callers 5

is_module_fusibleFunction · 0.45
dump_mlirFunction · 0.45
dump_mlir_to_fileFunction · 0.45
compile_mlirFunction · 0.45
get_tuning_config_mlirFunction · 0.45

Calls 15

insertFunction · 0.85
iterator_forFunction · 0.85
containsFunction · 0.85
get_nameFunction · 0.85
atMethod · 0.80
frontMethod · 0.80
to_shapesFunction · 0.50
transformFunction · 0.50
getMethod · 0.45
nameMethod · 0.45
inputsMethod · 0.45

Tested by

no test coverage detected