-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[max-examples] GUI: Improvements and fixes
- Bert: display top 5 examples by default - Llamma3: use 3.1 models by default - Rag: put example data in `ragdata` folder so it doesn't crash - Stable Diffusion: fix data type being incorrect - Yolo: move yoloconstants.py CLASS_NAMES into yolo.py MODULAR_ORIG_COMMIT_REV_ID: 5567ef1680b1f697f5b1cacbcd897f1d08564301
- Loading branch information
1 parent
70ec6f4
commit 458cfc0
Showing
6 changed files
with
123 additions
and
11 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Mojo Functions | ||
|
||
Mojo functions can be declared with either fn or def. | ||
|
||
The fn declaration enforces type-checking and memory-safe behaviors (Rust style), while def allows no type declarations and dynamic behaviors (Python style). | ||
|
||
For example, this def function doesn't require declaration of argument types or the return type: | ||
|
||
```mojo | ||
def greet(name): | ||
return "Hello, " + name + "!" | ||
``` | ||
|
||
While the same thing as an fn function requires that you specify the argument type and the return type like this: | ||
|
||
```mojo | ||
fn greet2(name: String) -> String: | ||
return "Hello, " + name + "!" | ||
``` | ||
|
||
Both functions have the same result, but the fn function provides compile-time checks to ensure the function receives and returns the correct types. Whereas, the def function might fail at runtime if it receives the wrong type. | ||
|
||
Currently, Mojo doesn't support top-level code in a .mojo (or .🔥) file, so every program must include a function named main() as the entry point. You can declare it with either def or fn: | ||
|
||
```mojo | ||
def main(): | ||
print("Hello, world!") | ||
``` |