-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Scale and Mask #2738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scale and Mask #2738
Conversation
|
|
||
| // ================================= Internal APIs =========================================== | ||
|
|
||
| private var protobufTest : String = Integer.toHexString(java.util.UUID.randomUUID().hashCode()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this for ?
| (implicit ev: TensorNumeric[T]): Unit = { | ||
|
|
||
| val protobufModel = context.bigdlModule | ||
| module.setProtobufTest(protobufModel.getProtobufTest) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed ?
| // mask == 0 means we use single scales, which will get the max of whole tensor (in/out). | ||
| // scalesOfInput will maintain the max value of input tensor | ||
| // scalesOfOutput will maintain the max value of output tensor | ||
| var scalesOfInput: Int8ScalesAndMask = new Int8ScalesAndMask(Int8ScalesAndMask.SINGLE_SCALE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer not initializing it here as it's only used in Int8, they are null for other cases
|
Please add unit tests for it |
|
I don't think we should put these in |
|
@jason-dai yes, that sounds better |
| * @tparam B Output data type | ||
| * @tparam T The numeric type in this module parameters. | ||
| */ | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's these added blank lines for ?
| * @return Unit | ||
| */ | ||
| private def updateScalesHelper(scales: ArrayBuffer[Array[Float]], | ||
| scale: Array[Float], index: Int): Unit = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indention of scale is not right.
| */ | ||
| protected def createSerializeBigDLModule[T: ClassTag](modelBuilder : BigDLModule.Builder, | ||
| context: SerializeContext[T]) | ||
| (implicit ev: TensorNumeric[T]): SerializeResult = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The syntax is a little strange.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I will modify these syntax issues.
| */ | ||
| trait MklInt8Convertible { | ||
| // input dimension mask | ||
| protected var inDimMask: Int = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By BigDL conversion, I prefer to use inputDimMask, similar below for outputDimMask
|
|
||
| "Saving and loading scale and mask" should "work properly" in { | ||
|
|
||
| val myModel = Linear(3, 4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a unit test for empty scales
|
I think there are other layers that need to implement this new trait. Also for mkl-blas layers, we should add that. @i8run |
What changes were proposed in this pull request?
(Please fill in changes proposed in this patch)
How was this patch tested?
(Please explain how this patch was tested. E.g. unit tests, integration tests, manual tests)
(If it is possible, please attach a screenshot; otherwise, remove this)
Related links or issues (optional)
fixed https://github.com/intel-analytics/BigDL/issues/XXX