Skip to content

[RFC][Hybrid Script] Syntax sugars for Hybrid Script #2262

@were

Description

@were

Hybrid Script is still under a very preliminary stage of development.
Comparing with its counterpart in FaceBook, TorchScript, a lot of syntax sugars are not supported yet.

  1. Global function call Done
@script
def foo(a):
    # balah
    return b

@script
def goo(a):
    b = foo(a)
    return b

foo can be found in __global__ dict, so it is not hard to do this I believe.

  1. Tensor level operations
# RFC
# actually, all these tensor operation rules will be hardcoded in the compiler
# i do not want to make it super complicate...
  1. Triple inequity Done
if 0 <= a < n:
    # balah
  1. In-place Operator
#RFC: Is this one good enough? Users are required to explicitly return the tensor with side effect.
@script
def goo(a):
    for i in range(a.shape[0]):
        a[i] += 1
    return a

@kevinthesun Any more suggestions?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions