forked from alibaba/MNN
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request alibaba#1815 from alibaba/feature/sync
[MNN:Sync] Sync internal gitlab
- Loading branch information
Showing
233 changed files
with
14,411 additions
and
3,092 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,10 +33,6 @@ Pod::Spec.new do |s| | |
s.requires_arc = true | ||
|
||
#s.source = { :git => "[email protected]:alibaba/MNN.git", :branch => 'master' } | ||
s.prepare_command = <<-CMD | ||
schema/generate.sh | ||
python source/backend/metal/MetalCodeGen.py source/backend/metal/ source/backend/metal/MetalOPRegister.mm | ||
CMD | ||
s.source = {:git => "/Users/zhang/Development/AliNNPrivate/",:branch=> 'head'} | ||
s.frameworks = 'Metal', 'Accelerate' | ||
s.library = 'c++' | ||
|
@@ -62,6 +58,6 @@ Pod::Spec.new do |s| | |
'express/**/*.{hpp,cpp}' | ||
s.header_mappings_dir = 'include' | ||
|
||
s.pod_target_xcconfig = {'METAL_LIBRARY_FILE_BASE' => 'mnn', 'HEADER_SEARCH_PATHS' => '"$(PODS_TARGET_SRCROOT)/include" "$(PODS_TARGET_SRCROOT)/3rd_party/flatbuffers/include" "$(PODS_TARGET_SRCROOT)/source" "$(PODS_TARGET_SRCROOT)/3rd_party/half"', 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) MNN_CODEGEN_REGISTER=1 MNN_SUPPORT_TFLITE_QUAN=1 MNN_METAL_ENABLED=1 MNN_SUPPORT_BF16=1 MNN_MODEL_AUTH=1'} | ||
s.pod_target_xcconfig = {'METAL_LIBRARY_FILE_BASE' => 'mnn', 'HEADER_SEARCH_PATHS' => '"$(PODS_TARGET_SRCROOT)/include" "$(PODS_TARGET_SRCROOT)/3rd_party/flatbuffers/include" "$(PODS_TARGET_SRCROOT)/source" "$(PODS_TARGET_SRCROOT)/3rd_party/half"', 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) MNN_CODEGEN_REGISTER=1 MNN_SUPPORT_TFLITE_QUAN=1 MNN_METAL_ENABLED=1 MNN_SUPPORT_BF16=1'} | ||
s.user_target_xcconfig = { 'OTHER_LDFLAGS' => '-force_load $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/MNN/libMNN.a', 'HEADER_SEARCH_PATHS' => '"$(PODS_TARGET_SRCROOT)/include"' } | ||
end |
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,32 @@ | ||
#include <metal_stdlib> | ||
|
||
using namespace metal; | ||
|
||
struct PretreatInfo { | ||
int4 outputSize; | ||
float4 mean; | ||
float4 normal; | ||
float4 inputSize; | ||
float4x4 matrix; | ||
}; | ||
|
||
kernel void pretreat(device half4* output [[buffer(0)]], | ||
texture2d<float> input [[texture(0)]], | ||
constant PretreatInfo& info[[buffer(1)]], | ||
uint2 gid[[thread_position_in_grid]]) { | ||
constexpr sampler linearSampler(mip_filter::none, | ||
mag_filter::linear, | ||
min_filter::linear); | ||
if ((int)gid.x < (int)info.outputSize.x && (int)gid.y < (int)info.outputSize.y) { | ||
#ifdef COMMON_MATRIX | ||
float3 pos = float3((float)gid.x, (float)gid.y, 1.0); | ||
pos = pos * info.matrix; | ||
float4 color = input.sample(linearSampler, pos.xy / pos.z); | ||
#else | ||
float2 pos = float2((float)(gid.x - 1) / (float)(info.outputSize.x - 1), (float)(gid.y - 1) / (float)(info.outputSize.y - 1)); | ||
float4 color = input.sample(linearSampler, pos); | ||
#endif | ||
color = (color * float4(255) - info.mean) * info.normal; | ||
output[gid.y * info.outputSize.x + gid.x] = half4(color); | ||
} | ||
} |
Oops, something went wrong.