Skip to content

Commit

Permalink
Repo sync (#874)
Browse files Browse the repository at this point in the history
  • Loading branch information
anakinxc authored Oct 9, 2024
1 parent 1e67e1e commit 377805a
Show file tree
Hide file tree
Showing 16 changed files with 352 additions and 276 deletions.
6 changes: 3 additions & 3 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ def _yacl():
http_archive,
name = "yacl",
urls = [
"https://github.com/secretflow/yacl/archive/refs/tags/0.4.5b6_nightly_20240923.tar.gz",
"https://github.com/secretflow/yacl/archive/refs/tags/0.4.5b7_nightly_20240930.tar.gz",
],
strip_prefix = "yacl-0.4.5b6_nightly_20240923",
sha256 = "14eaaf7ad4aead7f2244e56453fead4a47973a020e23739ca0fe93873866bb5f",
strip_prefix = "yacl-0.4.5b7_nightly_20240930",
sha256 = "cf8dc7cceb9c5d05df00f1c086feec99d554db3e3cbe101253cf2a5a1adb9072",
)

def _libpsi():
Expand Down
19 changes: 19 additions & 0 deletions libspu/compiler/tests/interpret/dynamic_update_slice.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,22 @@ func.func @dynamic_update_slice() {
pphlo.custom_call @expect_eq (%result, %expected) : (tensor<4x4xi64>,tensor<4x4xi64>)->()
func.return
}

// -----

func.func @dynamic_update_slice() {
%operand = pphlo.constant dense<[[1, 1, 1, 1],
[1, 1, 1, 1],
[1, 2, 2, 2],
[1, 2, 2, 2]]> : tensor<4x4xi64>
%update = pphlo.constant dense<[[1, 1, 1],
[1, 1, 1]]> : tensor<2x3xi64>
%i0 = pphlo.constant dense<4> : tensor<i64>
%start_indices0 = pphlo.convert %i0 : (tensor<i64>) -> tensor<!pphlo.secret<i64>>
%start_indices1 = pphlo.constant dense<4> : tensor<i64>
%result = pphlo.dynamic_update_slice %operand, %update, %start_indices0, %start_indices1 :
(tensor<4x4xi64>, tensor<2x3xi64>, tensor<!pphlo.secret<i64>>, tensor<i64>) -> tensor<4x4x!pphlo.secret<i64>>
%expected = pphlo.constant dense<[[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]> : tensor<4x4xi64>
pphlo.custom_call @expect_eq (%result, %expected) : (tensor<4x4x!pphlo.secret<i64>>, tensor<4x4xi64>)->()
func.return
}
1 change: 0 additions & 1 deletion libspu/core/xt_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,3 @@ NdArrayRef xt_to_ndarray(const xt::xexpression<E>& e) {

template <typename T>
struct fmt::is_range<xt::xarray<T>, char> : std::false_type {};

15 changes: 9 additions & 6 deletions libspu/dialect/pphlo/IR/type_inference.cc
Original file line number Diff line number Diff line change
Expand Up @@ -421,13 +421,16 @@ LogicalResult inferDynamicUpdateSliceOp(

// dynamic_update_slice_c1
TypeTools tools(operand.getContext());
auto common_vis =
tools.computeCommonVisibility({tools.getTypeVisibility(operandType),
tools.getTypeVisibility(updateType)});
auto vis = llvm::map_to_vector(startIndices, [&](mlir::Value v) {
return tools.getTypeVisibility(v.getType());
});
vis.emplace_back(tools.getTypeVisibility(operand.getType()));
vis.emplace_back(tools.getTypeVisibility(update.getType()));

inferredReturnTypes.emplace_back(RankedTensorType::get(
operandType.getShape(),
tools.getType(operandType.getElementType(), common_vis)));
inferredReturnTypes.emplace_back(
RankedTensorType::get(operandType.getShape(),
tools.getType(operandType.getElementType(),
tools.computeCommonVisibility(vis))));
return success();
}

Expand Down
Loading

0 comments on commit 377805a

Please sign in to comment.