You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[CodeGenC] Handle GlobalVar callee as internal function call (apache#15103)
Analogous to apache#14901, treat GlobalVar callees as internal function calls in CodeGenC. This specific PR doesn't provide new end-to-end functionality, as the target="c" backend isn't compiled. It does lead into allowing subroutines in any target whose codegen derives from CodeGenC, which will depend on the single-module lowering flow in apache#14985.
* [CodeGenC] Added unit tests for desired behavior
* [CodeGenC] Handle GlobalVar callee as internal function call
* Update CodeGenC subclasses for updated interface
- Call `DeclareFunction` for each `PrimFunc`, prior to any
`AddFunction` calls
- Provide both `GlobalVar` and `PrimFunc` to `AddFunction` calls.
* Updated CRT test to expect forward declaration
* Provide forward declarations for call_extern in cmsis
* Avoid duplicate forward declaration
C's automatic pointer cast (e.g. `void*` to `int*`) means that use of
the arguments to infer the function signature may be incorrect. If a
`call_extern` refers to a function within the same module, only output
a single forward declaration based on the PrimFunc's parameters, not
based on the CallNode's arguments.
* Updated expected ptx cuda
* Cast the AOT pools to the arg type
* Improved tvm::GetType for tvm_access_ptr and address_of
These `Call` instances can return a
`PointerType(PrimType(pointee_dtype))` rather than a
`PrimType(DataType::Handle())`.
* [ARM][Topi] Update micro kernels to use same argument type as caller
Previously, the micro kernels for gemm, avg_pool, max_pool, and
tensordot relied on C's implicit type conversions for the arguments,
when the caller's argument types differ from the signature's parameter
types. This works, except when the codegen has auto-generated a
forward declaration based on the caller's argument types, such as
during AOT, which then causes a conflicting definition.
Since the codegen cannot determine the functions names from the
`"pragma_import_c"` in order to suppress these forward declarations,
this conflict can be more easily resolved by updating the micro kernel
signatures. The three types of mismatches are below.
- Use of `int` or `long` parameters, whose width may vary by compiler,
instead of fixed-width types.
- TIR expecting the data array's integer type to also be used as an
error code's return type, rather than the micro kernels' `int32_t`
error code.
- Pointer conversion done during argument conversion.
Type conversions are done at the start of each micro kernel, to avoid
changing types that are used within the computational sections of each
micro kernel.
* Updated unit tests with private=True
Required for internal functions after PR apache#15214
* Docstring updates from review
0 commit comments