question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[RFC] Relay IR Text Format

See original GitHub issue

Keyword Proposal

The final keywords are:

  • def for global function definitions
  • fn for local function definitions/anonymous functions
  • if and else for if-else expressions
  • let for let bindings
  • True and False for booleans
  • data types are tvm-style. e.g. float32x4

Loose Ends

There are some elements of the text format that didn’t make it into this PR. See #1935 for details.


Please comment on syntax design choices for #1781 here!

Notable Syntax Examples

Functions

Named, Typed

def @foo(%x: int64, %y: int64) -> int64 {
    %x + %y
}

Named, Inferred

def @foo(%x, %y) {
    %x + %y
}

Anonymous, Typed

fn (%x: int64, %y: int64) -> int64 {
    %x + %y
}

Anonymous, Inferred

fn (%x, %y) {
    %x + %y
}

Let Expressions and Mutation

Immutable

let %x = 2;
let %x = 3;
let %y = 4;
%x + %y

Side Effects Only

The following are equivalent

print("hello");
1
let %_ = print("hello");
1

Tuples

()
(0,)
(0, 1)

Types

Base Types

Designed to look like NumPy types.

int32
uint32
float32
bool
int32x4
...

Shape Types

unimplemented

s
(n + 1, 2 * n, 4)

Tensor Annotations

generics unimplemented

def @add(t1: Tensor[s, bt], t2: Tensor[s, bt]) -> Tensor[s,  bt] {
    ...
}

Function Types

fn (int32, int32) -> int32

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:28 (28 by maintainers)

github_iconTop GitHub Comments

3reactions
MarisaKirisamecommented, Oct 21, 2018

This idea just come out of my head: can we pin a version number to every relay source/serialized code? It help to switch from one version to another version.

1reaction
joshpollcommented, Oct 21, 2018

I think using Python conventions for booleans and dtypes is probably the way to go.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[RFC] Relay IR Text Format · Issue #1782 · apache/tvm
True and False for booleans; data types are tvm-style. e.g. float32x4. Loose Ends. There are some elements of the text format that didn't...
Read more >
X.400 Use of Extended Character Sets RFC 1502
RFC stream, Internet Engineering Task Force (IETF). Formats. txt html pdf ... 11 parts of ISO 8859, plus a "supplementary" set, registered as...
Read more >
[IR] Unified TVM IR Infra - pre-RFC
This RFC proposes a unified IR infrastructure for the TVM stack by ... script similar to the meta support in the current relay...
Read more >
rfc7208.txt
The SPF record is expressed as a single string of text found in the RDATA of a ... The record format and the...
Read more >
RFCs 2300 - 2399 Index
RFCs 2300 - 2399s ; Authors: B. Kaliski. ; Date: March 1998 ; Formats: txt html json pdf ; Status: INFORMATIONAL ; DOI:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found