Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lite/backends/metal/metal_kernel/texture/ScaleKernel.metal
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct ScaleParam {
MetalActivationParam activationParam;
};

kernel void scale_before_bias(texture2d_array<ftype, access::read> inTexture[[texture(0)]],
kernel void bias_after_scale(texture2d_array<ftype, access::read> inTexture[[texture(0)]],
texture2d_array<ftype, access::write> outTexture[[texture(1)]],
constant ScaleParam& pm[[buffer(0)]],
uint3 gid[[thread_position_in_grid]]) {
Expand All @@ -38,7 +38,7 @@ kernel void scale_before_bias(texture2d_array<ftype, access::read> inTexture[[te
outTexture.write(relu, gid.xy, gid.z);
}

kernel void scale_after_bias(texture2d_array<ftype, access::read> inTexture[[texture(0)]],
kernel void bias_before_scale(texture2d_array<ftype, access::read> inTexture[[texture(0)]],
texture2d_array<ftype, access::write> outTexture[[texture(1)]],
constant ScaleParam& pm[[buffer(0)]],
uint3 gid[[thread_position_in_grid]]) {
Expand Down
4 changes: 2 additions & 2 deletions lite/kernels/metal/image_op/scale_image_compute.mm
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@
std::make_shared<MetalBuffer>(metal_context_, sizeof(metal_param), &metal_param);

if (param.bias_after_scale) {
function_name_ = "scale_after_bias";
function_name_ = "bias_after_scale";
} else {
function_name_ = "scale_before_bias";
function_name_ = "bias_before_scale";
}
// pipline
auto backend = (__bridge MetalContextImp*)metal_context_->backend();
Expand Down
10 changes: 6 additions & 4 deletions lite/tests/unittest_py/op/test_scale_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def __init__(self, *args, **kwargs):
PrecisionType.FP32,
DataLayoutType.NCHW,
thread=[1, 4])

opencl_places = [
Place(TargetType.OpenCL, PrecisionType.FP16,
DataLayoutType.ImageDefault), Place(
Expand All @@ -55,7 +54,6 @@ def __init__(self, *args, **kwargs):
Place(TargetType.Host, PrecisionType.FP32)
]
self.enable_testing_on_place(places=opencl_places)

metal_places = [
Place(TargetType.Metal, PrecisionType.FP32,
DataLayoutType.MetalTexture2DArray),
Expand All @@ -64,7 +62,7 @@ def __init__(self, *args, **kwargs):
Place(TargetType.ARM, PrecisionType.FP32),
Place(TargetType.Host, PrecisionType.FP32)
]
#self.enable_testing_on_place(places=metal_places)
self.enable_testing_on_place(places=metal_places)

def is_program_valid(self,
program_config: ProgramConfig,
Expand Down Expand Up @@ -149,7 +147,11 @@ def generate_data(*args, **kwargs):
return program_config

def sample_predictor_configs(self):
return self.get_predictor_configs(), ["scale"], (1e-5, 1e-5)
atol, rtol = 1e-5, 1e-5
target_str = self.get_target()
if target_str == "Metal":
atol, rtol = 1e-2, 1e-2
return self.get_predictor_configs(), ["scale"], (atol, rtol)

def add_ignore_pass_case(self):
pass
Expand Down