This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Cmath do | |
alias Beaver.MLIR.Type | |
use Beaver.Dialect, name: "cmath" | |
deftype complex(t = any_of(t, [Type.f32(), Type.f64()])) do | |
parameters(t) | |
end | |
defop norm do | |
operands(complex(any())) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/elixir/src/elixir_erl_compiler.erl b/lib/elixir/src/elixir_erl_compiler.erl | |
index a299ab4c2d..98462f7148 100644 | |
--- a/lib/elixir/src/elixir_erl_compiler.erl | |
+++ b/lib/elixir/src/elixir_erl_compiler.erl | |
@@ -50,7 +50,16 @@ compile(Forms, File, Opts) when is_list(Forms), is_list(Opts), is_binary(File) - | |
format_warnings(Opts, CoreWarnings), | |
CompileOpts = [no_spawn_compiler_process, from_core, no_core_prepare, | |
no_auto_import, return, {source, Source} | Opts], | |
- | |
+ case compile:noenv_forms(CoreForms, [dprecg|CompileOpts]) of |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Kinda.ParserHelper do | |
@moduledoc false | |
@doc """ | |
define a parser combinator and variable with same name | |
""" | |
defmacro defcv(name, expr) do | |
quote do | |
defcombinatorp(unquote(name), unquote(expr)) | |
Kernel.var!(unquote({name, [], nil})) = parsec(unquote(name)) | |
_ = Kernel.var!(unquote({name, [], nil})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Kinda.Parser do | |
import NimbleParsec | |
# *** Tokens *** | |
container_doc_comment = | |
string("//!") |> repeat(ascii_char([?^, ?\n])) |> repeat([?\s, ?\n]) |> times(min: 1) | |
doc_comment = | |
string("///") |> repeat(ascii_char([?^, ?\n])) |> repeat([?\s, ?\n]) |> times(min: 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Manx.Lowering do | |
alias Beaver.MLIR | |
import MLIR.Sigils | |
import MLIR.{Transforms, Conversion} | |
alias Beaver.MLIR.Dialect.GPU | |
def tosa_vulkan(op) do | |
op | |
|> MLIR.Operation.verify!(dump_if_fail: true) | |
|> canonicalize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule CfTest do | |
use ExUnit.Case | |
use Beaver | |
alias Beaver.MLIR | |
alias Beaver.MLIR.Type | |
alias Beaver.MLIR.Attribute | |
alias Beaver.MLIR.Dialect.{CF, Arith} | |
@moduletag :smoke | |
defmodule MutCompiler do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module { | |
func.func @"Elixir.Manx.Assert.-all_close_jit/3-fun-0-.126722613"(%arg0: tensor<3xf32>, %arg1: tensor<3xf32>) -> tensor<i8> { | |
%0 = "tosa.const"() {value = dense<9.99999974E-5> : tensor<f32>} : () -> tensor<f32> | |
%1 = "tosa.const"() {value = dense<0x7F800000> : tensor<3xf32>} : () -> tensor<3xf32> | |
%2 = "tosa.abs"(%arg0) : (tensor<3xf32>) -> tensor<3xf32> | |
%3 = "tosa.equal"(%2, %1) : (tensor<3xf32>, tensor<3xf32>) -> tensor<3xi1> | |
%4 = "tosa.cast"(%3) : (tensor<3xi1>) -> tensor<3xi8> | |
%5 = "tosa.abs"(%arg1) : (tensor<3xf32>) -> tensor<3xf32> | |
%6 = "tosa.equal"(%5, %1) : (tensor<3xf32>, tensor<3xf32>) -> tensor<3xi1> | |
%7 = "tosa.cast"(%6) : (tensor<3xi1>) -> tensor<3xi8> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn ResourceKind(comptime ElementType: type, module_name: anytype) type { | |
return struct { | |
pub const T = ElementType; | |
pub const module_name = module_name; | |
pub const resource = struct { | |
pub var t: resource_type = undefined; | |
pub const name = @typeName(ElementType); | |
pub fn make(environment: env, value: T) !term { | |
return make_resource(environment, value, t); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias Beaver.MLIR | |
alias Beaver.MLIR.CAPI.{ | |
MlirModule, | |
MlirOperation, | |
MlirRegion, | |
MlirAttribute, | |
MlirBlock, | |
MlirValue, | |
MlirNamedAttribute, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I’m working on compiling Elixir pattern to MLIR (the PDL dialect), | |
# so that it could be used to manipulate another piece of IR. | |
# If we want to rewrite | |
res = TOSA.add(a, b) >>> Type.ranked_tensor([2, 3], Type.f32()) | |
res1 = TOSA.add(res, b) >>> Type.ranked_tensor([2, 3], Type.f32()) | |
# to | |
res1 = TOSA.sub(res, b) >>> Type.ranked_tensor([2, 3], Type.f32()) | |
# We can declare a pattern like this |
NewerOlder