Skip to content

Commit

Permalink
Repo Sync (#312)
Browse files Browse the repository at this point in the history
  • Loading branch information
anakinxc authored Aug 18, 2023
1 parent f726019 commit a0feb32
Show file tree
Hide file tree
Showing 33 changed files with 1,036 additions and 489 deletions.
8 changes: 4 additions & 4 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Copyright 2023 Ant Group Co., Ltd.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -17,7 +17,7 @@ common --experimental_repo_remote_exec
# Required by OpenXLA
build --nocheck_visibility

build --incompatible_new_actions_api=false
build --incompatible_new_actions_api=false
build --copt=-fdiagnostics-color=always
build --enable_platform_specific_config

Expand Down
20 changes: 10 additions & 10 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ BasedOnStyle: Google

IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<.*\.h>'
Priority: 1
- Regex: '^<.*'
Priority: 2
- Regex: '.*\.pb\.h"$'
Priority: 5
- Regex: '^"libspu.*'
Priority: 4
- Regex: '^".*'
Priority: 3
- Regex: '^<.*\.h>'
Priority: 1
- Regex: "^<.*"
Priority: 2
- Regex: '.*\.pb\.h"$'
Priority: 5
- Regex: '^"libspu.*'
Priority: 4
- Regex: '^".*'
Priority: 3
3 changes: 1 addition & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,5 @@ CheckOptions:
- key: readability-identifier-naming.FunctionCase
value: "CamelBack"

- key: performance-unnecessary-value-param.AllowedTypes
- key: performance-unnecessary-value-param.AllowedTypes
value: PtBufferView

1 change: 1 addition & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
"ponit",
"pphlo",
"precheck",
"proto",
"PRNG",
"protobuf",
"Prss",
Expand Down
2 changes: 1 addition & 1 deletion bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

SECRETFLOW_GIT = "https://github.com/secretflow"

YACL_COMMIT_ID = "ff20dff1476071ca885c69bee94d2b3bdf85034c"
YACL_COMMIT_ID = "a9c1d7d119c80eb75d5ec63ee6cd77145dff18c2"

def spu_deps():
_bazel_platform()
Expand Down
18 changes: 9 additions & 9 deletions docs/development/ir_dump.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Dump IR to DAG

Introduction
------------
This document provides the demo for how to dump the IR (Intermediate Representation, generated by `XLA <https://www.tensorflow.org/xla/architecture>`_) to a DAG.
This document provides the demo for how to dump the IR (Intermediate Representation, generated by `XLA <https://www.tensorflow.org/xla/architecture>`_) to a DAG.
With the aid of visualized DAG, the execution logic and required operators will be more explicit.


Expand All @@ -33,7 +33,7 @@ Please first have a look at the :spu_code_host:`spu.proto </spu/blob/main/libspu
bool enable_pretty_print = 1;
string pretty_print_dump_dir = 2;
XLAPrettyPrintKind xla_pp_kind = 3;
// Disable sqrt(x) + eps to sqrt(x+eps) rewrite
bool disable_sqrt_plus_epsilon_rewrite = 10;
Expand Down Expand Up @@ -64,7 +64,7 @@ The part of the above code related to dumping IR to DAG is as follows.
// Pretty print
bool enable_pretty_print = 1;
string pretty_print_dump_dir = 2;
XLAPrettyPrintKind xla_pp_kind = 3;
XLAPrettyPrintKind xla_pp_kind = 3;
In general, we require to focus on three variables to control the dump behavior.

Expand All @@ -73,8 +73,8 @@ In general, we require to focus on three variables to control the dump behavior.
- **xla_pp_kind** is a *int* value, of which the range is [0, 1, 2], with each one representing one dump format. To date, we support three kinds of formats: TEXT, DOT and HTML. If you want to obtain the DAG, you should use DOT or HTML.

.. Note::
For **DOT** files, you should use `GraphViz <https://graphviz.org/>`_ to convert them to PDF or PNG to visualize the DAG.
For **DOT** files, you should use `GraphViz <https://graphviz.org/>`_ to convert them to PDF or PNG to visualize the DAG.

While for **HTML** files, you can directly open the them in your Web Browser, which shall render the DAG.

.. code-block:: protobuf
Expand Down Expand Up @@ -105,7 +105,7 @@ First of all, we declare an CompilerOptions object. Note that the **pretty_print
Then we pass the CompilerOptions to the executed SPU code.


The code shall be modified from
The code shall be modified from

.. code-block:: python
:caption: SPU execution without customized compiler options
Expand Down Expand Up @@ -137,15 +137,15 @@ We here provide the code snippet for dumping IR to HTML files. The DAG for the e
Here, we define a `max` function use jax.numpy.
"""
return jnp.maximum(x, y)
def get_data(seed=123):
"""
Any IO function that loads the data.
"""
np.random.seed(seed)
data = np.random.randn(3, 4)
return data
x = get_data(1)
y = get_data(2)
Expand All @@ -162,7 +162,7 @@ We here provide the code snippet for dumping IR to HTML files. The DAG for the e
res_spu = ppd.device("SPU")(func, copts=copts)(x_spu, y_spu)
.. Note::
You may find multiple files in the output directory since XLA has mutliple compile passes and generates multiple IRs, with each corresponding to one DAG.
You may find multiple files in the output directory since XLA has multiple compile passes and generates multiple IRs, with each corresponding to one DAG.
The **HTML** output is rendered as follows.
Expand Down
2 changes: 2 additions & 0 deletions libspu/compiler/core/core.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ void Core::buildPipeline(mlir::PassManager *pm) {
// lowering
auto &optPM = pm->nest<mlir::func::FuncOp>();
if (!options.disable_maxpooling_optimization()) {
// Need a cse before maxpooling
optPM.addPass(mlir::createCSEPass());
optPM.addPass(mlir::pphlo::createOptimizeMaxPoolingPass());
}
optPM.addPass(mlir::pphlo::createDecomposeComparisonPass());
Expand Down
Loading

0 comments on commit a0feb32

Please sign in to comment.